This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
Hi, I am adding a cog with the music function to my personal bot, doing &play [URL or name to search] the bot will play that song in the vocal chat, I already made a command for making it join che vocal chat but I can't manage to make it work with playlists and to take as "query" not only a word but even an entire phrase to search on yt. Here you will find the code even if you are in search of a good yt music bot:
def search(query):
with YoutubeDL({'format': 'bestaudio'}) as ydl:
try: requests.get(query)
except: info = ydl.extract_info(f"ytsearch:{query}", download=False)['entries'][0]
else: info = ydl.extract_info(query, download=False)
return (info, info['formats'][0]['url'])
@commands.command()
async def play(self, ctx, query):
FFMPEG_OPTS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
video, source = search(query)
voice = ctx.voice_client
asyncio.sleep(1)
voice.play(discord.FFmpegPCMAudio(source, **FFMPEG_OPTS), after=lambda e: print('done', e))
embed = discord.Embed(title="Riproduco la musica".format(), color=0xffff00)
embed.set_footer(text="BreezyModels © - develop by el3ctro4ndre")
await ctx.channel.send(embed=embed)
Can anybody help me finding a solution to theese 2 issues?
thanks a lot
Andrea
The asterisk tells discord.py that all remaining characters are going to the last arg
Subreddit
Post Details
- Posted
- 2 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/Discord_Bot...
The asterisk tells discord.py that all remaining characters are going to the last arg