如何制作可以停止的全局消息侦听器 discord.js

时间:2021-02-22 07:15:33

标签: javascript discord discord.js

如何制作一个消息监听器,它不仅可以在一个频道中工作,而且可以在使用某个命令时停止。

我试过了:

const collector = message.channel.createMessageCollector(()=>true);
 collector.on("collect", (collected, collector) => {
 message.author.send(collected.content)
});
bot.map.set(message.author.id, collector)

收集器可以通过以下方式停止: bot.map.get(message.author.id).stop();

消息侦听器仅适用于一个频道,不适用于多个频道,有没有办法创建一个适用于每个机器人频道并且可以停止的侦听器?谢谢!

0 个答案:

没有答案
相关问题