【发布时间】:2021-01-22 15:34:06
【问题描述】:
module.exports = {
name: 'cleartextchats',
description:
'clears desired amount of text chats created by the bot. usage: cleartextchats <amount>',
execute(message, args) {
var channelAmount = args[0];
console.log('executing cleartextchats');
for (var i = 0; i < channelAmount; i++) {
var textChat = message.guild.channels.cache
.filter((ch) => ch.type === 'text')
.find(
(targetch) => targetch.topic == 'volturnbot' && targetch.deleted == false
);
message.channel.send(`deleting ` + textChat.name);
textChat.delete();
}
},
};
for 循环不会越过第一个删除的通道。 我认为这是因为缓存不会更新,除非我使用不同的/新消息,但该命令应该从消息中运行。我想不出一种适用于任何数量的渠道的方法。
目前,每当我的机器人创建文本频道时,它都会更新主题以包含“volturnbot”,这样它就可以在没有类别的情况下删除自己的频道。
【问题讨论】:
标签: javascript node.js discord discord.js