有人可以告诉我为什么该命令不起作用吗?当我写前缀和命令时,它可以工作,但显示以下消息:
You did not specify a correct amount of time!
这应该是这样,但是如果我在它旁边写任何其他数字,以便我可以设置慢速模式,它什么也没做。如果有人可以分析代码并告诉我问题,将不胜感激。是的,有一个令牌,但是我删除了它,以免泄漏。
const commandFiles = fs
.readdirSync("./commands/")
.filter((file) => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once("ready", () => {
console.log("ChatSlowMode is Online!");
});
client.on("message", (message) => {
if (message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split();
const command = args.shift().toLowerCase();
if (command === "slowmode") {
if (!message.member.hasPermission("MANAGE_CHANNELS"))
return message.channel.send("You don't have access to this command!");
if (!args[0])
return message.channel.send(
"You did not specify a correct amount of time!"
);
if (isNaN(args[0])) return message.channel.send("That is not a number!");
if (args[0] > 21600)
return message.channel.send(
"Invalid Number! Number must be below 21600."
);
message.channel.setRateLimitPerUser(args[0]);
message.channel.send(`Slowmode Set to **${args[0]}**`);
}
});
client.login("");