【发布时间】:2020-01-20 19:17:48
【问题描述】:
在我开始使用模块并清理我的代码之前,我从来没有遇到过 say 命令的问题,但是因为我的命令很少有问题。我试图弄清楚为什么它会说这个命令。
const commandFiles = fs
.readdirSync("./commands/")
.filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
bot.commands.set(command.name, command);
}
bot.on("message", async message => {
if (!message.content.startsWith(PREFIX)) return;
let args = message.content.substring(PREFIX.length).split(" ");
switch (args[0]) {
case "say":
bot.commands.get("say").execute(message, args);
break;
const Discord = require("discord.js");
module.exports = {
name: "say",
description: "Show's avatar",
async execute(message, args){
const sayMessage = args.join(" ");
message.delete().catch(O_o => {});
message.channel.send(`${sayMessage} - ${message.author}`);
}
}
提前致谢!
【问题讨论】:
标签: discord discord.js