我尝试处理该代码,但没有发现代码有什么问题,我多次尝试使该代码无能为力
这是代码
const Discord = require('discord.js');
const client = new Discord.Client();
const prefix = '^';
client.once('ready', () => {
console.log('MEMEbot has gone online');
})
client.on('message', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.lenght).split(/ +/);
const command = args.shift().toLowerCase();
if(command === 'ping') {
message.channel.send('pong!');
}
});
client.login('my token');
答案 0 :(得分:0)
您有错字:
const args = message.content.slice(prefix.lenght).split(/ +/);
^^
应该是
const args = message.content.slice(prefix.length).split(/ +/);
^^