【问题标题】:How to add reaction to a message that bot sends in discord.py? [duplicate]如何对机器人在 discord.py 中发送的消息添加反应? [复制]
【发布时间】:2020-12-02 14:18:46
【问题描述】:

我的代码是这样的,我想让它发送消息并对其做出反应,但是运行之后,通道中没有任何反应,也没有错误。

@client.event
async def on_ready():
    Channel = client.get_channel(775355712271941647)
    Text = "React to get role"
    moji = await Channel.send(Text)
    await moji.add_reaction(emoji='????')

【问题讨论】:

  • 您的机器人是否有权发送消息、添加反应以及访问频道?您使用的是机器人还是客户端?代码本身没有任何问题。
  • 你启用了哪些意图?

标签: python-3.x discord.py


【解决方案1】:

我发现问题是我有两个on_ready,我也应该使用bot.event而不是client.event(因为我将客户端命名为bot)。

所以如果你和我有同样的问题,下面的代码会起作用:

@bot.event
async def on_ready():
    print('We have logged in as {0.user}'.format(bot))
    moji = await bot.get_channel(775355712271941647).send("bot is online")
    await moji.add_reaction(emoji='?')

【讨论】:

    猜你喜欢
    • 2021-04-11
    • 1970-01-01
    • 2022-01-05
    • 2021-09-12
    • 2022-01-05
    • 2022-01-03
    • 1970-01-01
    • 2021-01-26
    • 2020-09-08
    相关资源
    最近更新 更多