我正在用discord.js创建一个Discord bot,我想创建一个可以清除消息的命令。现在,我有这个代码(只有有趣的部分),我不明白为什么它不起作用:Discord.js deleteMessage()不起作用
// Importing discord.js, creating bot and setting the prefix
const Discord = require('discord.js');
const bot = new Discord.Client();
const prefix = "/";
// Array that stores all messages sent
messages = [];
bot.on('message', (message) => {
// Store the new message in the messages array
messages.push(message);
// Split the command so that "/clear all" becames args["clear", "all"]
var args = message.content.substring(prefix.length).split(" ");
// If the command is "/clear all"
if(args[0] == "clear" && args[1] == "all") {
bot.deleteMessages(messages); // Code that doesn't work
// Resets the array
messages = [];
}
}
// CONNECT !!!
bot.login('LOGING TOKEN HERE');
你能帮我吗?
请创建演示您的问题的尽可能最小的代码,然后张贴。你现在发布的代码甚至没有平衡大括号,所以我不能分辨是否有任何引起问题的语法错误。 – wmorrell
好的,我修复了@wmorrell! – Emrio