javascript discord bot commands code example

Example 1: how to code a discord bot in javascript

/* Okay So
1. You need to know the basics of Discord.js (learn on yt)
2. Go to dev portal (https://discord.com/developers/applications) Make a bot
	Invite to your server
3. Start coding the bot in Discord.js
4. Host the bot somewhere like repl.it
5. You're done / Implement the bot
*/

Example 2: 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 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 <>