Reputation: 93
I'm making a discord bot and it has a move command that moves all the members in a voice channel to another, well the main problem is this command should only work for those with move members permission but it does not! It doesn't work even if the user has that permission and it always show me an error. Here is the code:
def in_voice_channel():
def predicate(ctx):
return ctx.author.voice and ctx.author.voice.channel
return check(predicate)
@in_voice_channel()
@client.command()
@commands.has_permissions(move_members=True)
async def moveall(ctx, *, channel : discord.VoiceChannel):
author_ch = ctx.author.voice.channel.mention
for members in ctx.author.voice.channel.members:
await members.move_to(channel)
await ctx.send(f'Moved everyone in {author_ch} to {channel.mention}!')
Upvotes: 0
Views: 934
Reputation: 131
@commands.has_permissions()
checks the channel permissions, and text channels do not have move_members or mute_members permissions.
What you are looking for is @commands.has_guild_permissions()
which checks to see if that user has server wide permissions to move/mute members.
This means that to check if the user has move_member
you will need to put @commands.has_guild_permissions(move_members=True)
before your function/command.
Upvotes: 0
Reputation: 26
The problem in this code is not with the permissions setup.
@commands.has_permissions(move_members=True)
is the way to go.
What is the use of @in_voice_channel()
decorator?
As far as I know this is not from discord.py
After testing it myself, even though "Move Members" is the right permission to go for depending on discord.py docs, it does not seem to work properly.
You can instead use another check like @commands.has_role()
to make this work or wait until the bug gets fixed.
Upvotes: 1