我执行了此命令以向成员添加角色,但是它什么也没做。虽然没有错误返回

时间:2019-07-08 13:37:54

标签: python discord.py-rewrite

代码也不返回任何错误,但也不执行任何操作。

我已经更改了将角色从ctx.add_role(角色,成员)添加到member.add_roles(id)的方法。

async def mute(ctx, *roles, member:discord.User = None, reason = None, atomic=True):
    if ctx.message.author.manage_roles:
        if member == None or member == ctx.message.author:
            await ctx.send(f"A Admin of {ctx.guild.name} cannot mute themself.")
            return
        if reason == None:
            reason = "Being a dick."
            message = f"{member}, you have been muted by an admin of {ctx.guild.name} for {reason}. Appeal your mute in the appeal channel."
            await member.send(message)

        await member.add_roles(592817969294475275)
        await ctx.channel.send(f"{member} has been muted by {ctx.message.author}, an admin of {ctx.guild.name}!")
        return
    else:
        user = ctx.message.author
        ctx.send(f"{user}, you lack the proper permissions to mute a member of the server.")
        return

    await ctx.message.delete()```

No results at all, nor any error messages. I expect the command to add the role to the tagged member, then delete the messages containing the command typed. I expect that if someone typed the command without the `manage_roles` permission that an error would be returned, but that doesn't happen either. The message is not deleted, and no roles are added.

1 个答案:

答案 0 :(得分:0)

您需要使用Role对象,而不是其ID:

from discord.utils import get

mute_role = get(ctx.guild.roles, id=592817969294475275)
await member.add_roles(mute_role)