[英]Discord.js: MessageCollector not collecting
I'm trying to make a Discord bot that collects messages in a DM channel.我正在尝试制作一个在 DM 频道中收集消息的 Discord 机器人。 The
messageCollector
does not collect anything. messageCollector
不收集任何东西。 Take a look at this fragment:看看这个片段:
var dmChannel = message.author.dmChannel;
if (message.author.dmChannel === null) {
console.log(`Created dm channel`);
dmChannel = await message.author.createDM();
}
var filter = m => m.content === 'm' && m.content === 'l' && m.content === 'r' && m.content === 'd' && m.content === 'e' && m.content === 'i';
const actions = dmChannel.createMessageCollector(filter, { time: 600000 });
When I send any of the letters, it does not collect them.当我发送任何信件时,它不会收集它们。 I have a theory that if you create the collector with a command in another server, that that bugs out and doesn't do anything?
我有一个理论,如果您在另一台服务器中使用命令创建收集器,那么它会出错并且什么都不做? I'm really not sure.
我真的不确定。 Please help!
请帮忙!
Hah, I figured out that the fault lies in filter
.哈,我发现问题出在
filter
上。 It's supposed to be this:应该是这样的:
var filter = m => m.content === `m` || m.content === `l`... ;
&&
must be replaced with ||
&&
必须替换为||
because ||
因为
||
means or, not and.意思是或,不是和。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.