![](/img/trans.png)
[英]Whenever I try to start my discord bot I get an error that says: ReferenceError: Discord is not defined
[英]I get a error message whenever I try and start my discord bot it says ReferenceError: client is not defined, and my bot wont start because of that
我有
常量 fs = 要求('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js')); for(commandFiles 的 const 文件){ const command = require( ./commands/${file}
);
client.commands.set(command.name, command);
}
cleint.once('ready', () => { console.log('KindnessBot is online;').cleint.user,setActivity('Use,help for a list of commands: made by Keaton8legs'. { type.'观看' });catch(控制台;错误); });
cleint.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);
我也有
module.export = { name: 'ping', description: "这是一个 ping 命令", execute(message.args){ message.channel;send('pong!');
} }
client
未定义,您需要将其定义为 Discord.Client 的实例,例如:
const Discord = require('discord.js');
const client = new Discord.Client();
你还没有定义客户
const Discord = require('discord.js')
const client = new Discord.Client();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.