Toribash
Original Post
[TBA] | Creating a Discord bot
Hey everyone, I'm mitch.

I'm here to teach you how to make a basic discord bot in JavaScript!

First off you're going to have to make a new discord application.

1



You can name this anything you want.

After creating your discord application, you'll be taken to this screen.

2



On the left side of your screen choose bot.

3



Ok, We're done with creating our bot account!

Now, even though you can use notepad to edit javascript I'd recommend getting an IDE (Integrated Development Environment). I use Visual Studio Code. You can also use other text editors such as Notepad++.

Alright! The last thing we have to do is get Node.js. When installing this, make sure to "Add To PATH".

4



Now time to install Discord.js, The module that will allow us to interact with Discord's API!

Make a new folder in anywhere you want, I'll use my desktop! Inside this folder, we're going to hold down SHIFT and RIGHT-CLICK. It should bring up a drop-down menu, like this.

5



Press "Open PowerShell window here". If there is no option for this, Take a look for "Open Command Prompt window here". If none of these options are available. Goto Command Prompt (or Terminal) and find where your file is, I put mine on the desktop so I'll type "cd Desktop\bot". Once you are here you can type node -v and npm -v to check if you have Node installed. After you know you have Node installed you can type "npm install discord.js". Let that install, once it's done you can exit command prompt!

Now we're going to create the file where all our bots code will be stored! RIGHT-CLICK in the folder where you want your bot to be created.

6



Rename that file you just created to "bot.js" and make sure there is no .txt extension on the end.

If you can't see file extensions then do what is shown in the image below.

7



If you can see file extensions and renaming the file to bot.js worked for you, you can skip the above step.

RIGHT-CLICK this file and if you can see open with Notepad++ or Visual Studio Code, open it with those. If not search for one of them and open the one you searched for. After opening one of them press CTRL + O and find your bot.js file in the folder you created it in.

Once you're inside we can finally start typing up our base code!

javascript code:
const Discord = require('discord.js');
const bot = new Discord.Client();

bot.on('ready', () => {
console.log('Once the bot is ready this message will show!');
});

bot.on('message', async (message) => {
console.log('A message was sent');
});

bot.login(TOKEN);


Where you see "TOKEN" we're going to have to go to our bot account again. You're going to want to press copy on this page. If you can't find your way here, refer to the other steps.

8



After copying this you can come back to your code and copy paste it where I have put "TOKEN". Once you have done this your bot is ready to go!

Time to add it to your discord server for testing! Let's get our invite link.

9



Once you've done this, paste it into your browser and select your server here.

10



Once that's done go to the Command Prompt again and find the folder where your bot.js is. After that, type "node bot.js". This will start your bot, check the Discord server your bot is in and it should be online! Try sending a message and checking your console. It should say "A message was sent". If not, either my tutorial was garbage or you messed something up. Try recreating the steps, or posting on this thread for help.

Take a look at the Discord.js Documentation.

Terminology Used



Please post any CnC below.
Last edited by mitch; Jan 13, 2019 at 09:36 PM.
Works How its meant to
Not had any problems as of yet
Tho the Thing of It disapeering After a few seconds
Can be a bit annoying At times
Otherwise it works well
What disappears after a few seconds?

Are you talking about my discord bot? If so this is the wrong thread...