-
Notifications
You must be signed in to change notification settings - Fork 265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My bot responds to any prefix??? #41
Comments
It’s because your bot doesn’t check if the message starts with the prefix Add this to the command handler: |
@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. 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 ".")
![poop](https://user-images.githubusercontent.com/61891466/76130713-6bd2c480-5fd1-11ea-83b1-fef81078ef7a.PNG)
The text was updated successfully, but these errors were encountered: