Hardcoding Links
This commit is contained in:
parent
c39e009df8
commit
89592c5719
24
index.js
24
index.js
@ -5,17 +5,13 @@ const Discord = require('discord.js');
|
||||
const client = new Discord.Client();
|
||||
const giphy = require('giphy-api')(process.env.giphyAPIKey);
|
||||
const debug = true;
|
||||
// const gifs = require('gifs.json');
|
||||
const links = require('./links.json');
|
||||
|
||||
dotenv.config();
|
||||
const owner = process.env.ownerID;
|
||||
|
||||
async function getUser(id) {
|
||||
const user = await client.users.fetch(id);
|
||||
if (debug) {
|
||||
console.log(user);
|
||||
}
|
||||
return user;
|
||||
if (debug) {
|
||||
console.log(links);
|
||||
}
|
||||
|
||||
client.once('ready', () => {
|
||||
@ -27,9 +23,22 @@ client.login(process.env.TOKEN);
|
||||
client.on('message', message => {
|
||||
const pre = message.content.slice(0, -4);
|
||||
const ext = message.content.slice(-4);
|
||||
let gifFound = false;
|
||||
|
||||
switch (ext) {
|
||||
case '.gif':
|
||||
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) {
|
||||
@ -44,6 +53,7 @@ client.on('message', message => {
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Admin Commands
|
||||
case '.adm':
|
||||
|
24
links.json
Normal file
24
links.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"gifs": [
|
||||
{
|
||||
"name": "nod",
|
||||
"embed_url": "https://tenor.com/view/smile-nod-yes-robert-redford-beard-gif-10489927"
|
||||
},
|
||||
{
|
||||
"name": "psh",
|
||||
"embed_url": "https://tenor.com/view/ed-bassmaster-youtuber-youtube-influencer-psh-gif-10556767"
|
||||
},
|
||||
{
|
||||
"name": "unreal",
|
||||
"embed_url": "https://tenor.com/view/unreall-gif-15193874"
|
||||
},
|
||||
{
|
||||
"name": "lookatit",
|
||||
"embed_url": "https://tenor.com/view/just-look-at-it-gif-11036230"
|
||||
},
|
||||
{
|
||||
"name": "foolme",
|
||||
"embed_url": "https://tenor.com/view/george-bush-fool-me-once-brave-gif-12227074"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user