James@SCF-GC
151a037e32
All checks were successful
Schedulord/schedulord-discordbot/pipeline/head This commit looks good
28 lines
803 B
JavaScript
28 lines
803 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
|