nodbot/commands/gif.js

34 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-07-06 21:37:29 +00:00
const functions = require('../functions');
2021-06-30 22:59:24 +00:00
const giphy = require('giphy-api')(process.env.giphyAPIKey);
module.exports = {
name: 'gif',
description: 'Send a GIF',
execute(message, file) {
const client = message.client;
if (!client.gifs.has(file.name)) {
2021-07-09 23:00:28 +00:00
giphy.search(file.name).then(function (res) {
2021-06-30 22:59:24 +00:00
if (res.data[0] != undefined) {
2021-07-06 21:37:29 +00:00
// message.channel.send(file.name + ' requested by ' + message.author.username + '\n' + res.data[0].embed_url).then().catch(console.error);
const gifInfo = {
'name': file.name,
'embed_url': res.data[0].images.original.url,
'requestor': '@' + message.author.username + '#' + message.author.discriminator,
};
message.channel.send(functions.createGifEmbed(gifInfo));
2021-06-30 22:59:24 +00:00
} else {
message.channel.send('I was unable to find a gif of ' + file.name);
}
2021-07-09 23:00:28 +00:00
})
.catch(err => console.error(err));
2021-06-30 22:59:24 +00:00
} else {
2021-07-06 21:37:29 +00:00
// message.channel.send(file.name + ' requested by ' + message.author.username + '\n' + client.gifs.get(file.name).embed_url);
const gifInfo = {
'name': file.name,
'embed_url': file.embed_url,
'requestor': message.author.username + '#' + message.author.discriminator,
};
message.channel.send(functions.createGifEmbed(gifInfo));
2021-06-30 22:59:24 +00:00
}
}
}