Я сделал эту команду, чтобы добавить роль к члену, но она ничего не делает. Хотя ошибки не возвращаются - PullRequest
0 голосов
/ 08 июля 2019

Код не возвращает никаких ошибок, но также не выполняет никаких действий.

Я изменил метод добавления роли с ctx.add_role (role, member) на 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 голосов
/ 08 июля 2019

Вам необходимо использовать объект Role, а не его идентификатор:

from discord.utils import get

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