nodbot/commands/gif.js

34 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-07-06 21:37:29 +00:00
const functions = require('../functions');
2021-07-18 19:47:31 +00:00
const tenor = require('tenorjs').client({
"Key": process.env.tenorAPIKey, // https://tenor.com/developer/keyregistration
"Filter": "off", // "off", "low", "medium", "high", not case sensitive
"Locale": "en_US", // Your locale here, case-sensitivity depends on input
"MediaFilter": "minimal", // either minimal or basic, not case sensitive
"DateFormat": "D/MM/YYYY - H:mm:ss A" // Change this accordingly
});
2021-07-18 18:56:45 +00:00
2021-06-30 22:59:24 +00:00
module.exports = {
name: 'gif',
description: 'Send a GIF',
execute(message, file) {
const client = message.client;
if (!client.gifs.has(file.name)) {
2021-07-18 19:47:31 +00:00
tenor.Search.Query(file.name, 1).then(res => {
if (res[0] == undefined) return;
const gifInfo = {
'name': file.name,
'embed_url': res[0].media[0].gif.url
};
message.channel.send(functions.createGifEmbed(gifInfo, message.author, `${file.name}.${file.extension} - Tenor`));
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,
2021-07-14 00:57:37 +00:00
'embed_url': client.gifs.get(file.name).embed_url
2021-07-06 21:37:29 +00:00
};
message.channel.send(functions.createGifEmbed(gifInfo, message.author, `${file.name}.${file.extension} - Saved`));
2021-06-30 22:59:24 +00:00
}
}
}