2021-06-26 21:38:18 +00:00
|
|
|
/* eslint-disable brace-style */
|
|
|
|
// Variable Assignment
|
|
|
|
const dotenv = require('dotenv');
|
|
|
|
const Discord = require('discord.js');
|
|
|
|
const client = new Discord.Client();
|
|
|
|
const giphy = require('giphy-api')(process.env.giphyAPIKey);
|
2021-06-27 19:23:14 +00:00
|
|
|
const debug = false;
|
2021-06-27 01:24:14 +00:00
|
|
|
const links = require('./links.json');
|
2021-06-26 21:38:18 +00:00
|
|
|
|
|
|
|
dotenv.config();
|
2021-06-27 00:36:57 +00:00
|
|
|
const owner = process.env.ownerID;
|
2021-06-26 21:38:18 +00:00
|
|
|
|
2021-06-27 01:24:14 +00:00
|
|
|
if (debug) {
|
|
|
|
console.log(links);
|
2021-06-26 21:38:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
client.once('ready', () => {
|
|
|
|
console.log('Ready');
|
|
|
|
});
|
|
|
|
|
|
|
|
client.login(process.env.TOKEN);
|
|
|
|
|
|
|
|
client.on('message', message => {
|
2021-06-27 19:23:14 +00:00
|
|
|
if (message.author.bot) return;
|
|
|
|
|
2021-06-26 21:38:18 +00:00
|
|
|
const pre = message.content.slice(0, -4);
|
|
|
|
const ext = message.content.slice(-4);
|
2021-06-27 01:24:14 +00:00
|
|
|
let gifFound = false;
|
2021-06-26 21:38:18 +00:00
|
|
|
|
|
|
|
switch (ext) {
|
|
|
|
case '.gif':
|
2021-06-27 01:24:14 +00:00
|
|
|
if (debug) {
|
|
|
|
console.log('pre: ' + pre);
|
|
|
|
console.log('ext: ' + ext);
|
|
|
|
}
|
|
|
|
for (let index = 0; index < links.gifs.length; index++) {
|
|
|
|
const gif = links.gifs[index];
|
|
|
|
if (gif.name == pre) {
|
|
|
|
message.channel.send(gif.embed_url);
|
|
|
|
gifFound = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (gifFound == false) {
|
|
|
|
try {
|
|
|
|
giphy.search(pre, function(err, res) {
|
|
|
|
if (res.data[0] != undefined) {
|
|
|
|
message.channel.send(res.data[0].embed_url);
|
|
|
|
} else {
|
|
|
|
message.channel.send('Sorry, I was unable to find a gif of ' + pre + '.');
|
|
|
|
}
|
|
|
|
if (err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
}
|
2021-06-26 21:38:18 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
// Admin Commands
|
|
|
|
case '.adm':
|
|
|
|
if (message.member.id == process.env.ownerID) {
|
|
|
|
switch (pre) {
|
|
|
|
case 'kill':
|
|
|
|
client.destroy();
|
|
|
|
process.exit();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case '.req':
|
|
|
|
message.channel.send('Feedback Submitted: ' + pre);
|
2021-06-27 00:36:57 +00:00
|
|
|
client.users.fetch(owner).then(user => { user.send('Feedback/Request: ' + pre);});
|
2021-06-26 21:38:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|