【发布时间】:2021-01-26 15:05:50
【问题描述】:
这是我的代码,所有 clearChat 功能都可以正常工作。它不会引发错误,但不会删除消息。
const bot = new Discord.Client();
bot.on('message', msg => {
const args = msg.content.substring(config.prefix.length).split(' ');
switch (args[0]) {
case 'clear':
if(isNaN(args[1])) return msg.reply('Define the amount of messages you want to clear!');
else if(args[1] > 101 ) return msg.reply('Cannot clear more than 100 messages!');
else if(args[1] < 1)) return msg.reply('Must clear at least 1 message!');
else {
clearChat = async(msg, args) => {
let deleteAmount = +args[1] + 1;
messages = await msg.channel.messages.fetch({ limit: deleteAmount }).then(async(messages) => {
await msg.channel.bulkDelete(messages);
});
};
};
break;
};
});
【问题讨论】:
标签: javascript node.js discord.js