如果您有成员角色 discord py,则静音命令

时间:2021-04-02 19:41:33

标签: python discord discord.py

即使我在频道和权限中有所有设置,我的静音命令也不起作用。如何覆盖成员角色

@client.command(aliases=['m'])
@commands.has_permissions(kick_members = True)
async def mute(ctx, member : discord.Member):
    muted_role = ctx.guild.get_role(muted role id)

    await member.add_roles(muted_role)
    await ctx.send(member.mention +" has been muted")

1 个答案:

答案 0 :(得分:-1)

您将无法覆盖该角色,但可以移除该角色。将成员角色替换为静音角色。并且但是查看频道的成员角色权限

@commands.has_permissions(kick_members = True)
async def mute(ctx, member : discord.Member):
    muted_role = ctx.guild.get_role(muted role id)
    member_role = ctx.guild.get_role(member role id)

    await member.add_roles(muted_role)
    await member.remove_roles(member_role)
    await ctx.send(member.mention +" has been muted")

如果你想取消静音命令,只需反向操作

@client.command(aliases=['um'])
@commands.has_permissions(kick_members = True)
async def unmute(ctx, member : discord.Member):
    muted_role = ctx.guild.get_role(muted role id)
    member_role = ctx.guild.get_role(member role id)

    await member.remove_roles(muted_role)
    await member.add_roles(member_role)
    await ctx.send(member.mention +" has been unmuted")