【问题标题】:Making a bot that sends a message that you can react to and gives a role. Discord Python制作一个发送消息的机器人,您可以对其做出反应并赋予角色。不和谐的蟒蛇
【发布时间】:2021-07-29 23:14:32
【问题描述】:

我正在尝试编写一个发送带有可反应图标的消息的机器人,您可以单击它会给您一个角色,但如果您取消反应,则删除该角色。

这是我有的,但不实用。

@client.event
async def on_message(message):
    if message.author == client.user:
        return
    if message.content == 'bumper_role':
        role = get(message.server.roles, name='bumper_role')
        await client.add_roles(message.author, role)

【问题讨论】:

    标签: python discord discord.py bots


    【解决方案1】:

    替换role = get(message.server.roles, name='bumper_role') role = discord.utils.get(message.guild.roles, name='bumper_role')

    还将await client.add_roles(message.author, role) 替换为await message.author.add_roles(role)

    祝你有美好的一天:)

    【讨论】:

      猜你喜欢
      • 2021-08-28
      • 1970-01-01
      • 2021-06-25
      • 2020-11-20
      • 2021-05-19
      • 2021-07-04
      • 1970-01-01
      • 2020-10-04
      • 2020-09-13
      相关资源
      最近更新 更多