因此,与上一个问题(上一个问题)相关的是,该机器人不再会在有人运行命令时吐出很多错误,并且该机器人成功地向用户DM发送了响应提示,但是好像消息收集器没有启动?机器人DM会向用户发送命令,控制台中不会出现任何错误,仅此而已。您可以整天响应该漫游器,它不会收集该漫游器并将其发送到频道ID。有指针吗?
以下是我认为可能涉及的代码:
collector.on('collect', (message, col) => {
console.log("Collected message: " + message.content);
counter++; ```
And here is all of the code (just in case it actually doesn't revolve around that):
``` if(message.content.toLowerCase() === '&reserveupdate') {
message.author.send('**Thanks for updating us on the reserve. Please enter what you are taking from the reserve below this message:**');
let filter = m => !m.author.bot;
let counter = 0;
let collector = new discord.MessageCollector(message.author, m => m.author.id, filter);
let destination = client.channels.cache.get('my channel id');
collector.on('collect', (message, col) => {
console.log("Collected message: " + message.content);
counter++;
if(counter === 1) {
message.author.send("**Thanks for updating us on the reserve, it is highly appreciated.**");
collector.stop();
}
答案 0 :(得分:1)
我认为您在创建消息收集器的方式上可能错了。
根据the docs,您应该这样操作:
const filter = m => !m.author.bot;
// If you are in an async function :
const channel = await message.author.createDM();
// Paste code here
// Otherwise :
message.author.createDM.then(channel => {
// Paste code here
});
// Code to paste :
const collector = channel.createMessageCollector(filter, { max: 1, time: 60000 });
collector.on('collect', msg => {
// ...
});
希望这将帮助您解决问题! :)