v1 Code Base

This commit is contained in:
= 2021-06-26 17:38:18 -04:00
parent 2950cc3e87
commit d974365f84
3 changed files with 73 additions and 1 deletions

View File

@ -0,0 +1,66 @@
/* 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);
let owner;
dotenv.config();
async function getUser(id) {
const user = await client.users.fetch(id).catch(err,() {});
return user.data;
}
client.once('ready', () => {
console.log('Ready');
owner = getUser(process.env.ownerID);
console.log(owner);
});
client.login(process.env.TOKEN);
client.on('message', message => {
const pre = message.content.slice(0, -4);
const ext = message.content.slice(-4);
switch (ext) {
case '.gif':
try {
const results = 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);
}
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);
owner.send('Feedback/Request ' + pre);
console.log(owner);
break;
default:
break;
}
});

5
package-lock.json generated
View File

@ -548,6 +548,11 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true
},
"giphy-api": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/giphy-api/-/giphy-api-2.0.1.tgz",
"integrity": "sha512-6FKx6y26W1OqPtEOohvr3MOqCcYWajmz/svrjWm6XW2eP9mHvcQoi4aFg5afCakVF2b7zVllP0aNF45CGHZn+A=="
},
"glob": {
"version": "7.1.7",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz",

View File

@ -5,7 +5,8 @@
"main": "index.js",
"dependencies": {
"discord.js": "^12.5.3",
"dotenv": "^10.0.0"
"dotenv": "^10.0.0",
"giphy-api": "^2.0.1"
},
"devDependencies": {
"eslint": "^7.29.0"