discordjs / voice

Implementation of the Discord Voice API for discord.js and other JS/TS libraries
Apache License 2.0
328 stars 112 forks source link

Discord bot issue #223

Closed Purple0wl closed 2 years ago

Purple0wl commented 2 years ago

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()

iCrawl commented 2 years ago

This looks very much like a lot of python code, this is a JavaScript library.