Answer the question
In order to leave comments, you need to log in
How to implement music search by name, not by link?
I have this command, but it can't play music by name, how to do it?
Thank you all in advance!!
Here is the error(discord.ext.commands.errors.CommandInvokeError: Command raised an exception: DownloadError: ERROR: 'pyrokinesis' is not a valid URL. Set --default-search "ytsearch" (or run youtube-dl "ytsearch:pyrokinesis " ) to search YouTube)
@bot.command(name='play')
async def play(ctx, url : str):
if ctx.author.voice is None:
embed = discord.Embed(title=f'', description='подключись к каналу', color='ff0000', timestamp=datetime.now().astimezone(tz=de))
embed.add_field(name='⠀', value='⠀')
embed.set_footer(text=f'Angefordert von {ctx.author.name} • {ctx.author.id}', icon_url=ctx.author.avatar_url)
bot_msg = await ctx.send(embed=embed)
await asyncio.sleep(15)
await bot_msg.delete()
voice_channel = ctx.author.voice.channel
if ctx.voice_client is None:
await voice_channel.connect()
else:
await ctx.voice_client.move_to(voice_channel)
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
YDL_OPTIONS = {'format':"bestaudio"}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
vc.play(source)
Answer the question
In order to leave comments, you need to log in
I would have read the error.
Set --default-search "ytsearch" (or run youtube-dl "ytsearch:pyrokinesis" ) to search YouTube)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question