discord.py-rewrite 'VoiceClient' object has no attribute 'ws'

Viewed 897

Here is code:

    @client.command(pass_context=True)
    async def join(ctx):
        global voice1
        global channel1
        channel1 = ctx.author.voice.channel
        voice1 = get(client.voice_clients, guild=ctx.guild)
        if voice1 and voice1.is_connected():
            await voice1.move_to(channel1)
        else:
            await channel1.connect()
            await ctx.send(f"joined {channel1}")

I got this error:

    discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 
    'VoiceClient' object has no attribute 'ws'

I try make a music bot

1 Answers
@bot.command(name='join', invoke_without_subcommand=True)
async def join(ctx):
   destination = ctx.author.voice.channel
   if ctx.voice_state.voice:
     await ctx.voice_state.voice.move_to(destination)
     return

   ctx.voice_state.voice = await destination.connect()
   await ctx.send(f"Joined {ctx.author.voice.channel} Voice Channel")

try using this i think it should be because recently discord changed its documentations and introduced some new features.

Related