i make a command for my discord bot, that play some sound from video on youtube. This function work good, if you call her one time, but on the second time i get error that my bot already connected into this voice channel. so i tried to disconnect the bot after he play the video, but it didn't work.
The Function:
@bot.command(pass_context=True)
async def video(ctx, msg):
author = ctx.message.author
voice_channel = author.voice_channel
vc = await bot.join_voice_channel(voice_channel)
player = await vc.create_ytdl_player(url)
player.start()
await vc.disconnect() #not good, the video not playing
error without await vc.disconnect()
:
yield from injected(*ctx.args, **ctx.kwargs)
File "/usr/local/lib/python3.6/dist-packages/discord/ext/commands/core.py", line 54, in wrapped
raise CommandInvokeError(e) from e
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: ClientException: Already connected to a voice channel in this server
thank for helpers ^^ have a nice day!