所以我正在制作一个discordbot,但我不想让一些命令只能由特定角色使用这是代码:
@client.command()
async def mute(ctx,member : discord.Member):
muted_role = ctx.guild.get_role(I don't know if i should share this role id so just imagine there is a role id here)
await member.add_roles(muted_role)
await ctx.send(member.mention + " has been muted")
您可以简单地使用has_role
装饰器
@client.command()
@commands.has_role(198723981723) # Or the role name
async def mute(ctx, member: discord.Member):
参考:
commands.has_role