To code a discord bot you only need three things the Terminal, a good wifi connection, and Nodejs. This can work on Windows, Mac, and Linux.
In this tutorial, you will learn how to make a bot in JavaScript.
This is best for beginners
Token
Open your browser and get into the discord developer portal:
Then:
Next, you need to create a new bot:
Hit create and then:
Click on Bot:
Then click add Bot
And click yes do it
And finally:
Copy the token and Keep it you WILL need it later
Now real quickly make a discord server:
And to add it go to OAuth2 click bot and at the bottom copy the link and paste it into your browser:
WINDOWS
So first you want to make a folder on your desktop called Bot. Then make a file called index.js REMEMBER .js IS VERY IMPORTANT
BTW you need node.js so to get node you need to go to this link.
When you go through installation continue
Next, you want to right-click the index.js file and open it with notepad.
Copy and paste this code
// require the discord.js module
const Discord = require('discord.js');
// create a new Discord client
const client = new Discord.Client();
// when the client is ready, run this code
// this event will only trigger one time after logging in
client.once('ready', () => {
console.log('Ready!');
});
// login to Discord with your app's token
client.login('your-token-goes-here');
Replace ‘your-token-goes-here’ with the token I told you to copy above
Then open up the PowerShell if you need help finding it look it up on the internet.
Enter the command
cd c:\Users\(username)\Desktop
Replace username with you username
Then type:
npm install discord.js
And finally, type
node index.js
MAC OS
To make a discord bot in Mac is pretty much the same
First, you will need to make sure that you have node.js
Next after you install it
- make a folder on your desktop
2. Open the folder
Refer to the link in the caption
And once you have your directory setup in your terminal type the command:
touch index.js
Next
npm install discord.js
Finally right click the file in the folder outside the terminal click open with notepad or editor and copy and past the code.
// require the discord.js module
const Discord = require('discord.js');
// create a new Discord client
const client = new Discord.Client();
// when the client is ready, run this code
// this event will only trigger one time after logging in
client.once('ready', () => {
console.log('Ready!');
});
// login to Discord with your app's token
client.login('your-token-goes-here');
Change the token
your-token-goes-here
With your token That I told you to copy above
Finally type in the terminal this:
node index.js
Linux
When I mean start with Linux we are doing this completely using the terminal
So in the terminal I will do this in ubuntu and debian.
Debian version will work with the rasberry pi
UBUNTU
sudo apt install nodejs
---Next---
sudo apt install npm
---Next---
wget -qO-https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
--Next---
source ~/.profile
--Next---
nvm install 10.15.1
After that you finished installing node
Now type:
mkdir bot
--next--
cd bot
--next--
touch index.js
--next--
npm install discord.js
-----------------------
And Now
sudo apt install vim
--next--
vim index.js
You should be taken to a screen for vim
and press i
After you pressed i
Type in this code
// require the discord.js module
const Discord = require('discord.js');
// create a new Discord client
const client = new Discord.Client();
// when the client is ready, run this code
// this event will only trigger one time after logging in
client.once('ready', () => {
console.log('Ready!');
});
// login to Discord with your app's token
client.login('your-token-goes-here');
After you typed the code and replaced the “Your token goes here” With the token, you got from the beginning of the document.
Press these keys
— — — — — -
- ESC
- w
- q
- enter
— — — — — —
Finally type:
node index.js
And there you have it!!
Conclusion If you liked this follow me its at the top of the do. It would also help so much if you could follow me on GitHub
Thank you for reading. This took a lot of time to make so if you support me thx
Also, email me atvblawing@gmail.com And tell me what you want me to make a tutorial about next