如何使收集者停止收集来自用户的相同消息,因此示例是,如果有人键入catch
,则该漫游器将收集该消息,但是如果他再次说catch
,则该漫游器将不再收集
这是我的代码
if (command === 'coinrain') {
message.channel.send('Coin rain has started please type `CATCH`')
let filter = m => m.content.toLowerCase() === 'catch';
const collector = message.channel.createMessageCollector(filter, {max: 10, time: 10000});
collector.on('collect', m => {
console.log(m.content);
})
collector.on('end', m => {
message.channel.send({embed: {
color: '#33FFF0',
title: 'Event is over!',
description: `${m.map(member => `${member.author.username}`).join(', ')}`
}})
})
}
```
答案 0 :(得分:0)
如discord.js文档中所述, MessageCollector 具有 Collected 属性,描述为: 此收藏家收集的物品
您可以使用 collector.collected.includes({Object-to-check})。 在您的情况下,您应该检查是否已发送 catch 消息的用户。您可以借助消息
的属性 author 和 content 来执行此检查