discord.js command code example
Example 1: discord.js bot
//first you must install dicord.js by running the command: npm install discord.js
//once u do that copy and paste this into your main file
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () =>{
client.user.setStatus('your status')
console.log('Connected!')
})
//rest of your code
//always remember to never share your token with anyone
client.login('your-token-here')
Example 2: discord.js command prompt notification
bot.on('ready', () => {
console.log('Logged in as TEMPLATE');
});
//link to the dev portal to make your own discord bot here: https://discord.com/developers/applications
Example 3: If statement discord js
<client>.on('message', message => {
if (message.content === '!ping') {
message.channel.send('Pong.');
} else if (message.content.startsWith('beep')) {
message.channel.send('Boop.');
}
});
// The client is the bot itself.
// You would have defined this at the top of your index.js/app.js
// It would look like 'const client = new Discord.Client()'
// Put that in place for '<client>' and remove the <>
Example 4: discord command js
bot.on('message', function(message) {
if(message.author.bot) return;
if(message.content === '/lvl') {
message.channel.send("lvl system.")
}
});