Created
August 3, 2021 05:31
-
-
Save re-masashi/dbc85af21a0b542fa596abed99fb681c to your computer and use it in GitHub Desktop.
A boilerplate for Discord.js. Just add functions and get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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