Image for post
Image for post
Photo by Rock’n Roll Monkey on Unsplash

Build Your First Discord GIF BOT and Deploy

A Bot that send GIF replies and is deployed on Heroku for free

Shelcia David
Dec 30, 2020 · 7 min read

Pre-requisites :

Step 1: Setting up in Discord Developer Portal

Image for post
Image for post
Discord Developer Portal
Image for post
Image for post
I have hidden Client ID for privacy reasons
Image for post
Image for post
Image for post
Image for post
Final step
Image for post
Image for post
My Bot is on server ;)

Step 2: Setting up Tenor GIF Developer account

Image for post
Image for post
Tenor Developer API key registration.

Step 3: Pre-requisites for Code

npm init
npm install discord.js
npm install node-fetch
npm install dotenv
Image for post
Image for post
TENOR API Key
Image for post
Image for post
Click COPY to copt the BOT Token
DISCORD_BOT_TOKEN = {USE YOUR DISCORD BOT TOKEN}TENOR_KEY = {USE YOUR TENOR KEY}
npm install -g nodemon
node_modules.env
Image for post
Image for post

Step 4: Let’s Code

const Discord = require('discord.js'); 
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!'); }
});
client.login({REPLACE WITH YOUR OWN BOT TOKEN AS A STRING});
nodemon bot.js
Image for post
Image for post
Image for post
Image for post
Hope it is not clumsy. I tried my best to explain the code
Image for post
Image for post
Aww!!. It’s cute.

Step 5: Deployment

{"name": "discord-gif-bot","version": "1.0.0","description": "","main": "Bot.js","scripts": {"start": "node Bot.js"},"author": "Shelcia","license": "MIT","dependencies": {"discord.js": "^12.5.1","dotenv": "^8.2.0","node-fetch": "^2.6.1"}}
worker: node Bot.js
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
You can even change branches and deploy it.
Image for post
Image for post
Image for post
Image for post
Environment variables on Heroku
Image for post
Image for post
Image for post
Image for post
overview after deployement
Image for post
Image for post
click edit and toggle
Image for post
Image for post
GIF Bot After Hosting !!

Conclusion

The Startup

Medium's largest active publication, followed by +771K people. Follow to join our community.

Shelcia David

Written by

I am a final year engineering student designing and developing web applications since 2018 for fun and to feed my belly.

The Startup

Medium's largest active publication, followed by +771K people. Follow to join our community.

Shelcia David

Written by

I am a final year engineering student designing and developing web applications since 2018 for fun and to feed my belly.

The Startup

Medium's largest active publication, followed by +771K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store