javascript - 为什么我的消息收集器收集相同的消息?
问题描述
所以我正在尝试制作一个 modmail 系统,但由于某种原因,频道收集器正在收集相同的消息。任何帮助都会很棒!
const discord = require("discord.js")
module.exports = {
name: 'modmail',
aliases: ['mail'],
execute: async (client, message, args) => {
const mes = await message.channel.send("I have sent you a dm.")
const config = require("/home/runner/Bot2/Handlers/config.json")
message.author.send("Start typing to chat with the moderators.")
.then(async (msg) => {
const filter = m => !m.author.bot;
const collector = await msg.channel.createMessageCollector({
filter,
});
const channel = await message.guild.channels.create(`${message.author.username}s-modmail`, {
permissionOverwrites: [{
id: config.mainrole,
deny: ["VIEW_CHANNEL"],
}, ],
})
collector.on("collect", m => {
channel.send(`${m.author.tag}: ${m.content}`)
const filter = mm => !mm.author.bot;
const channelcollect = channel.createMessageCollector({
filter,
max: 1,
});
if (m.content == "?mmclose") {
m.reply("Modmail will be closing.")
collector.stop()
}
channelcollect.on("collect", async mm => {
if (mm.content == "?mmclose") {
return channel.delete()
}
m.author.send(`${mm.author.tag}: ${mm.content}`)
console.log(mm.content)
})
})
})
.catch(error => {
mes.delete()
message.reply("Something went wrong. Make sure your dms are open. If this happens if when your dms are on then dm !Kweeper#8053")
})
}
}
我不知道为什么会发生这种情况,因为我已将最大消息设置为 1,将 dm 收集器最大值设置为 1,但它破坏了代码。
解决方案
推荐阅读
- sql - 不是 GROUP BY 表达式 - 我应该注意什么?
- sql - 使用 XRMToolbox 的简单查询帮助
- c# - 动态表创建 - ef 核心迁移
- javascript - Mongo node js,如何不返回整个对象文档?
- apache-kafka - 如何捕获流经 MQ -> App -> Kafka -> App -> Kafka 的消息的处理时间
- python - 加载数据:TypeError:无法将系列转换为
- azure - Azure IoT 中心 - 批量创建或更新 REST API 返回错误
- javascript - 使用服务器幻灯片 JavaScript 转换 MarkLogic 中的搜索片段?
- vue.js - 是否可以创建一个在 Vue 中添加标记的“HOC”?
- javascript - 如何遍历 Postman 中的每个 JSON 键值对