Skip to content

Instantly share code, notes, and snippets.

@re-masashi
Created August 3, 2021 05:31
Show Gist options
  • Select an option

  • Save re-masashi/dbc85af21a0b542fa596abed99fb681c to your computer and use it in GitHub Desktop.

Select an option

Save re-masashi/dbc85af21a0b542fa596abed99fb681c to your computer and use it in GitHub Desktop.
A boilerplate for Discord.js. Just add functions and get started.
const Discord = require('discord.js');
const client = new Discord.Client();
const botPrefix = "{{prefix}}";
const lengthOfPrefix = len(botPrefix);
/* BotLogin handler */
client.on('ready',()=>{
client.user.setActivity("with Fire");
})
/* Message handler */
client.on('message',(msg) => {
if((msg.author !== client.user)&&(msg.content.startsWith(botPrefix))){
let msgArgs = msg.content.substr().split(' ');
funcList[msgArgs[0]](msg,msgArgs)
}
})
//Define functions that will be called via commands.
//Eg: "ping":pingFunction
const funcList = {
}
/* Area to define functions that will be used in ``funcList`` */
/* End area to define functions */
client.login(process.env.DISCORD_BOT_TOKEN)
/* Extra tasks to be done here */
//End of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment