schedulord-discordbot/index.js

29 lines
804 B
JavaScript

require('dotenv').config(); //initialize dotenv
const axios = require('axios'); //add Axios
const Discord = require('discord.js'); //import discord.js
const client = new Discord.Client(); //create new client
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
//My first command :)
client.on('message', async msg => {
switch (msg.content) {
//Ping :)
case "ping":
msg.reply("Pong!");
break;
//our meme command below
case "!meme":
msg.channel.send("Here's your meme!"); //Replies to user command
const img = await getMeme(); //fetches an URL from the API
msg.channel.send(img); //send the image URL
break;
}
})
//make sure this line is the last line
client.login(process.env.CLIENT_TOKEN); //login bot using token