Hi! I have a problem. This discord bot can join, play music, pause resune and leave. When i run the bot it can play songs but when i tell him to leave, join again and play something i get this error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotConnectedToVoice: Cannot create the player because bot is not connected to voice
music = DiscordUtils.Music()
@client.command(pass_context = True)
async def play(ctx,*,url):
player = music.get_player(guild_id = ctx.guild.id)
if not player:
player = music.create_player(ctx, ffmpeg_error_betterfix = True)
if not ctx.voice_client.is_playing():
await player.queue(url, search = True)
song = await player.play()
else:
song = await player.queue(url, search = True)
@client.command(pass_context = True)
async def pause(ctx):
player = music.get_player(guild_id = ctx.guild.id)
song = await player.pause()
Hi! I have a problem. This discord bot can join, play music, pause resune and leave. When i run the bot it can play songs but when i tell him to leave, join again and play something i get this error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: NotConnectedToVoice: Cannot create the player because bot is not connected to voice
music = DiscordUtils.Music()
@client.command(pass_context = True) async def play(ctx,*,url): player = music.get_player(guild_id = ctx.guild.id) if not player: player = music.create_player(ctx, ffmpeg_error_betterfix = True) if not ctx.voice_client.is_playing(): await player.queue(url, search = True) song = await player.play() else: song = await player.queue(url, search = True)
@client.command(pass_context = True) async def pause(ctx): player = music.get_player(guild_id = ctx.guild.id) song = await player.pause()
@client.command(pass_context = True) async def join(ctx): channel = ctx.message.author.voice.channel voice = await channel.connect()
@client.command(pass_context = True) async def resume(ctx): player = music.get_player(guild_id = ctx.guild.id) song = await player.resume()
@client.command(pass_context = True) async def queue(ctx): player = music.get_player(guild_id = ctx.guild.id)
@client.command(pass_context = True) async def leave(ctx): await ctx.voice_client.disconnect()