Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 消息收集器discord.js_Javascript_Discord.js - Fatal编程技术网

Javascript 消息收集器discord.js

Javascript 消息收集器discord.js,javascript,discord.js,Javascript,Discord.js,如何让收集器停止收集来自用户的相同消息,例如,如果有人键入catch,机器人将收集该消息,但如果他再次说catch,机器人将不再收集该消息 这是我的密码 if (command === 'coinrain') { message.channel.send('Coin rain has started please type `CATCH`') let filter = m => m.content.toLowerCase() === 'catch';

如何让收集器停止收集来自用户的相同消息,例如,如果有人键入
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(', ')}`
            }})
        })
    }
    ```
如文档中所述,MessageCollector具有一个Collected属性,描述如下: 此收集器收集的项目

您可以使用收集器.collected.includes({Object to check})。 在您的情况下,您应该检查是否有用户已发送catch消息。由于消息的属性authorcontent,您可以执行此检查