Open Slurpity opened 4 years ago
It’s because your bot doesn’t check if the message starts with the prefix
Add this to the command handler: If(!message.content.startsWith(prefix) return;
@Slurpity, a representation of what @MrDiamond64 meant is shown below:
const Discord = require('discord.js'); // Imports discord.js library
const client = new Discord.Client({disableMentions: 'everyone'}); // You can use "bot" instead of "client"
client.on('ready', () => {
console.log(`${client.user.username} is online!`);
// This will get the username of your bot without you having to set it manually
});
client.on('message', (message) => {
var prefix = '!' // This is your bot's prefix, in your case you can use anything
var args = message.content.slice(prefix.length).replace('^\\s*', '').split(' ');
var command = args.shift().toLowerCase();
if (message.content.startsWith(prefix)) {
if (command === 'ping') message.channel.send('pong!');
}
// That's just an example, you can make your own commands
});
client.login(token); // Your Bot's token here
Btw, make sure to close this thread if you're satisfied with your answer. If you have any doubts you may ask us. We are here to help. :+1:
const token = '(token taken out for obvious reasons)';
const PREFIX = '.';
var version = '0.420.69'
bot.on('ready', () =>{ console.log('Slurp Bot is now online!'); })
bot.on('message', message=>{
})
bot.login(token);
Okay, so my bot responds to any prefix... The prefix I use is "." so I should do .(command) for it to work right? no. I can do anything; f(command) y(command) ?(command). Any help? I am a complete noob to this.
(For the screenshot, Slurp-Bot's prefix is ";" and Slurp-Test-Bot's prefix is ".")