A simple discord bot that helps you send gif in your server using command !gif
command
- Create node project and install discord.js module.
$ npm init
$ npm install discord.js
-
Create an application - optionally set name, description, avatar.
-
Select Bot from left navigation and "Add Bot" - set name and icon.
-
Add bot to the your server with the url:
https://discord.com/oauth2/authorize?client_id=YOUR_CLIENT_ID&scope=bot
-
Write the code!
Login to bot account:
const Discord = require('discord.js');
const client = new Discord.Client();
client.login('YOUR BOT TOKEN');
Callback for when the bot is connected and ready:
client.once('ready', () => {
console.log('Ready!');
});
Callback for when a message is posted:
client.on('message', gotMessage);
function gotMessage(msg) {
console.log(msg.content);
}
- Run the bot!
$ node index.js
- Install dotenv package.
$ npm install dotenv
- Create
.env
file (get reference from .env.example file):
BOT_TOKEN=123456789
CHANNEL_TOKEN=123456789
API_KEY=123456789
This project follows the MIT License.