[英]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.