[英]How do i get the size of the collection
我正在使用 discord.js 消息收集器。 如何检查是否没有发送消息并给出时间已到的错误? 因为到目前为止,如果在结束事件中没有收集到消息,则不会发送任何消息。
let filter = m => m.author.id === message.author.id
const collector = new MessageCollector(message.channel, filter, {max: 1, time: 1000 * 20})
collector.on('end', async m => { ...........
MessageCollector
class 通过end
事件为我们提供了collected
元素的参数。 我们可以使用它来确定收集了多少消息,只需键入:
collector.on('end', async m => console.log(m.size))
collector.on('end', async m => { if(m.size === 0){ // Do stuff here if no messages have been collected } else { // Do stuff here if at least 1 message has been collected } })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.