I need help with this discord.js command

Please someone can tell me why this isn’t working

const Discord = require(‘discord.js’);
const client = new Discord.Client();

const prefix = '!p ’

client.once(‘ready’, () => {
console.log(‘Ready!’);
});

client.on(‘message’, message =>{
if (!message.content.startWith(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(‘YOU CANT SEE MY TOKEN HEHE’);

If you copied your code verbatim and I’ll guess that you did then it is likely prefix.lenght which should be prefix.length.

If you want a developer’s hint, be very liberal with console.log messages as you try to debug things. console.log prefix, prefix.lenght, args, command, etc. to see if in each case it doesn’t generate an error and outputs what you expect. You can comment them out or remove them when you are happy that it works.

Thanks you

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.