'Context' object has no attribute 'voice'

380 Views Asked by At

can someone help me I just do it like a tutorial on youtube but it shows 'Context' object has no attribute 'voice' I think Error is from the 74-76 lines ( maybe ) I'm a newbie Thanks for help :) enter image description here

1

There are 1 best solutions below

0
Mathis Kirchner On

Its cause (what the error says) the context object has no attribute voice, so you cannot use context.voice (context is in your case ctx). As you can see here the context object has an attribute voice_client and voice_client has an attribute disconnect() So to do what you want do:

@bot.command()
async def dis(ctx):
    await ctx.voice_client.disconnect()

Also you often forgot to use await in your code. Discord.py is an async wrapper for discord bots, so make sure to get into async programming in python or general python programming first, then async py programming and then use discord.py.