机器人在用户点击反应后发送消息,当他删除他的反应时(python,discord)

时间:2021-04-11 18:11:14

标签: python discord bots

我有两个直流通道:

  • Channel_a
  • 频道_b

Channel_a 对用户关闭。 他们可以看到这个频道,但他们不能写。他们只能点击反应。 Screen 1

我需要一个机器人,当有人点击响应:one: 时,机器人将在 channel_b 中发送消息,@nick 是点击此响应的用户。

例如。昵称@Professore 的用户点击反应:一:。在 channel_a 中,我们有

Screen 2

此机器人在 channel_b 中发送消息后:

Screen

当昵称@Professor 的用户删除他在 channel_a 中的反应时,bot 将在 channel_b 中发送另一条消息。

Screen

谁能帮我完成这个?

1 个答案:

答案 0 :(得分:0)

@client.command(aliases=['click']) 异步定义游戏(ctx): 表情符号 = ':one:'

def check(reaction, user):
    return user == ctx.author && str(reaction) == emoji
message = await ctx.send("Just click here:")
await message.add_reaction(emoji)

try:
    await client.wait_for('reaction_add', timeout = 30.0, check = check)
    await ctx.send('Hello @rs10 user')
except:
    await message.delete()  # The message will be deleted if the user doesn't react with :one: within 30 second

我发现了类似的东西,并尝试使用它。这很难;/