The Perfect Lil' Bot
This bot example is the combined work of members of the Discord.js and Idiot Guide's community. It attempts to provide a "complete" starter example of a simple, one-file bot, with comments and information to properly understand each part and how it works.
Want a better tutorial? Check out AnIdiots.Guide
Setup
Before doing any of this make sure you have a bot account, check this page to know how to create the bot app and your token, as well as how to invite the bot in your guild.
- Create a new folder somewhere, give it a bot name, aka
MyBotorSuperBot - Create a file called
index.js, and paste in the contents of index.js below. - Create a file called
config.jsonand give it the following content, using your real bot token:
{
"token" : "MTg-this-IzNzU3OTA5NjA-is.not-DCeFB-a.real-r4DQlO-t0ken-qerT0",
"prefix" : "+"
}You then need to run a couple of things to make this work. Those things are run in console, which
can be opened by using SHIFT+Right-Click in your folder, and selected Open command prompt here
(your version of windows might say "PowerShell", don't worry it'll work fine!). In console, use
the following commands:
npm init -y
npm install discord.js
node index.js
If you've done things right, that should start the bot.
Support
All support for bot code is offered in the Idiot's Guide Official Server.
COMMENTS BELOW ARE NOT MONITORED AND YOU WILL NOT RECEIVE SUPPORT HERE