有谁知道如何检查某人是否在同一 channel 中发送了两次相同的消息,间隔为 5 秒(两次消息之间可能有其他人发送的其他消息)?
(我是 Javascript 和 Discord.js 新手)
如果有人能帮助我,那就太好了。
最佳答案
您可以使用TextChannel.awaitMessages()
client.on('message', message => {
// this function can check whether the content of the message you pass is the same as this message
let filter = msg => {
return msg.content.toLowerCase() == message.content.toLowerCase() && // check if the content is the same (sort of)
msg.author == message.author; // check if the author is the same
}
message.channel.awaitMessages(filter, {
maxMatches: 1, // you only need that to happen once
time: 5 * 1000 // time is in milliseconds
}).then(collected => {
// this function will be called when a message matches you filter
}).catch(console.error);
});
关于javascript - 使用discord.js 检查是否有人在 5 秒内发送了 2 条相同的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52242926/