简体   繁体   English

如何使 discord 机器人对 Discord 频道中的每条消息做出反应

[英]How to make a discord bot react to every message in a Discord channel

I was trying to make my bot react to every message in a discord channel 840211720470265887 but my script does not work as expected.我试图让我的机器人对 discord 频道840211720470265887中的每条消息做出反应,但我的脚本没有按预期工作。

client.on('message', message => {
  client.channels.cache.get('840211720470265887');
    if (message.content === '') {
        message.react('✅');
    }
});

Can someone please tell me how to solve my problem?有人可以告诉我如何解决我的问题吗?

You are checking for an empty message and if it is empty it will react to it.您正在检查一条空消息,如果它是空的,它将对其作出反应。 Remove the if statement that is checking for an empty message and it should react to all incoming messages in that spesific channel.删除正在检查空消息的 if 语句,它应该对该特定通道中的所有传入消息作出反应。

This is how you want it to look.这就是你想要的样子。

client.on('message', message => {
    if (message.channel.id === '840211720470265887') {
        message.react('✅');
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果消息包含 facebook 链接,如何使 Discord Bot 对频道中的消息做出反应? - How to make Discord Bot react to a message in a channel, if the message contains a facebook link? 使不和谐机器人发送消息特定通道 - make discord bot to send message specific channel 如何使用 discord 机器人将消息发送到特定通道? - How to send message to a specific channel with discord bot? 如何在特定频道中发布不和谐机器人帖子? - How to make discord bot post in a specific channel? Discord 使用 bot 创建频道 - Discord make channel using bot 如何使 discord js 机器人在某个时间在 discord 的确切文本通道中发送随机消息(我创建一个列表并发送它) - How to make an discord js bot to send an random message(i make an list and he sends it) at some time in an exact text channel from discord 如何让 discord 机器人发送抓取的消息? - How to make discord bot send scraped message? 如果我的不和谐机器人对发送的每条消息都做出反应,我怎么能让它只对 png、jpg 和 gif 做出反应 - How could I make my discord bot react to only png, jpg and gifs if it's reacting to every message sent 如何使 discord 机器人消息的粗斜体? - How to make bold italics of a discord bot message? 如何让 discord 机器人编辑 dm 消息? - how to make a discord bot edit a dm message?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM