【问题标题】:Problem making a discord reaction role bot in discord在不和谐中制作不和谐反应角色机器人的问题
【发布时间】:2021-11-01 18:59:14
【问题描述】:

所以我目前正在制作一个不和谐的机器人,它赋予对消息做出反应的特定角色我遇到了一些我无法解决的问题

   @client.event
    async def on_ready():
            Channel = client.get_channel('904620745462804520')
            Text= "React to get Verified!"
            Moji = await client.send_message(Channel, Text)
            await client.add_reaction(Moji, emoji='✅')
    @client.event
    async def on_reaction_add(reaction, user):
            Channel = client.get_channel('904620745462804520')
            if reaction.message.channel.id != Channel:
                    return
            if reaction.emoji == "✅":
                  Role = discord.utils.get(user.server.roles, name="Verified")
                  await client.add_roles(user, Role)

【问题讨论】:

  • 请分享您在问题中遇到的问题的信息。这将使人们更容易提供有用的答案。

标签: discord.py


【解决方案1】:

请仔细阅读documentation

@client.event
async def on_ready():
    Channel = client.get_channel('904620745462804520')
    Text = "React to get Verified!"
    Moji = await Channel.send(Text)
    await Moji.add_reaction(emoji='✅')


@client.event
async def on_reaction_add(reaction, user):
    if reaction.message.channel.id != '904620745462804520' or user == client.user:
        return
    if reaction.emoji == "✅":
        guild = await client.fetch_guild('GUILD_ID_HERE')
        Role = discord.utils.get(guild.roles, name="Verified")
        await user.add_roles(Role)

【讨论】:

    猜你喜欢
    • 2021-05-22
    • 2021-04-19
    • 2022-11-10
    • 2019-02-02
    • 2020-12-15
    • 1970-01-01
    • 1970-01-01
    • 2021-10-27
    • 2018-03-20
    相关资源
    最近更新 更多