Fixing some bugs, adding gif hardcoding json

This commit is contained in:
= 2021-06-26 20:36:57 -04:00
parent d974365f84
commit c39e009df8
2 changed files with 13 additions and 8 deletions

3
gifs.json Normal file
View File

@ -0,0 +1,3 @@
{
"nod": ""
}

View File

@ -4,19 +4,22 @@ const dotenv = require('dotenv');
const Discord = require('discord.js'); const Discord = require('discord.js');
const client = new Discord.Client(); const client = new Discord.Client();
const giphy = require('giphy-api')(process.env.giphyAPIKey); const giphy = require('giphy-api')(process.env.giphyAPIKey);
let owner; const debug = true;
// const gifs = require('gifs.json');
dotenv.config(); dotenv.config();
const owner = process.env.ownerID;
async function getUser(id) { async function getUser(id) {
const user = await client.users.fetch(id).catch(err,() {}); const user = await client.users.fetch(id);
return user.data; if (debug) {
console.log(user);
}
return user;
} }
client.once('ready', () => { client.once('ready', () => {
console.log('Ready'); console.log('Ready');
owner = getUser(process.env.ownerID);
console.log(owner);
}); });
client.login(process.env.TOKEN); client.login(process.env.TOKEN);
@ -28,7 +31,7 @@ client.on('message', message => {
switch (ext) { switch (ext) {
case '.gif': case '.gif':
try { try {
const results = giphy.search(pre, function(err, res) { giphy.search(pre, function(err, res) {
if (res.data[0] != undefined) { if (res.data[0] != undefined) {
message.channel.send(res.data[0].embed_url); message.channel.send(res.data[0].embed_url);
} else { } else {
@ -57,8 +60,7 @@ client.on('message', message => {
break; break;
case '.req': case '.req':
message.channel.send('Feedback Submitted: ' + pre); message.channel.send('Feedback Submitted: ' + pre);
owner.send('Feedback/Request ' + pre); client.users.fetch(owner).then(user => { user.send('Feedback/Request: ' + pre);});
console.log(owner);
break; break;
default: default:
break; break;