Node.js Discord.js ReferenceError:未定义消息
我正在尝试发出命令以清除我的discord中的消息,但收到的错误消息未定义。在终端内部的错误上方,myNode.js Discord.js ReferenceError:未定义消息,node.js,visual-studio-code,discord.js,Node.js,Visual Studio Code,Discord.js,我正在尝试发出命令以清除我的discord中的消息,但收到的错误消息未定义。在终端内部的错误上方,myreturn下有一个特定部分,对于带有它的第一行,有一个箭头指向它 这是我的主要部分代码 const Discord = require('discord.js'); const client = new Discord.Client(); const prefix = '!'; const fs = require('fs'); client.commands = new Disc
return
下有一个特定部分,对于带有它的第一行,有一个箭头指向它
这是我的主要部分代码
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '!';
const fs = require('fs');
client.commands = new Discord.Collection();
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('Codelyon 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 == 'ping') {
client.commands.get('ping').execute(message, args);
}
else if(command == 'ouryoutube') {
client.commands.get('youtube').execute(message, args);
}
else if(command == 'clear') {
client.commands.get('clear').execute(message, args);
}
});
这是我的命令代码
module.exports = {
name: 'clear',
description: "Clear Messages",
execute(messages, args) {
if(!args[0]) return message.reply("You must enter the number of messages you want to clear");
if(isNaN(args[0])) return message.reply("Please Enter a Real Number.");
if(args[0] > 100) return message.reply("You can't delete more then 100 messages");
if(args[0] < 1) return message.reply("You must delete at least one message");
}
}
module.exports={
名称:“清除”,
说明:“清除消息”,
执行(消息、参数){
if(!args[0])返回message.reply(“必须输入要清除的邮件数”);
if(isNaN(args[0])返回消息。回复(“请输入实数”);
if(args[0]>100)返回message.reply(“您不能删除超过100条的邮件”);
if(args[0]<1)返回message.reply(“您必须删除至少一条邮件”);
}
}
谢谢你,谢谢你的帮助!:) 您在
execute(messages,args){…}
中有一个输入错误。第一个参数应该是message
execute(消息,参数){
//代码
}