Reputation: 3
I have a problem with my discord bot. (discord.py)
Here is my code:
@bot.command()
async def mute(ctx):
muteRole = discord.Guild.get_role(845612659940524032)
if(message.author.kick_members == True):
return
else:
await ctx.send('You don\'t have the permission for that')
Everything seems right to me. But when I test the command, I always get this error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: get_role() missing 1 required positional argument: 'role_id'
Can someone help me?
Upvotes: 0
Views: 1667
Reputation: 2289
I think you've not quite understood how this works. discord.Guild
is a class, not an instance, of which you're calling the function get_role()
. Thats where your error comes from. To fix this, use the instance ctx.guild
instead.
muteRole = ctx.guild.get_role(845612659940524032)
Also message.author.kick_members
won't work here. First of all, because message
isn't defined anywhere, use ctx.message
instead. Furthermore, ctx.message.author
does not have the attribute kick_members
, maybe try using the decorator instead
@bot.command()
@has_permissions(kick_members=True)
async def mute(ctx):
muteRole = ctx.guild.get_role(845612659940524032)
Upvotes: 1