Tenor Command

This commit is contained in:
Daniel Odendahl Jr
2018-09-27 00:08:01 +00:00
parent 0dfec03104
commit b8915dc299
5 changed files with 45 additions and 3 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ module.exports = class SuggestCommandCommand extends Command {
constructor(client) {
super(client, {
name: 'suggest-command',
aliases: ['command-suggestion', 'command-suggest'],
aliases: ['command-suggestion', 'command-suggest', 'suggest'],
group: 'random',
memberName: 'suggest-command',
description: 'Suggests a random command for you to try.'
+40
View File
@@ -0,0 +1,40 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { TENOR_KEY } = process.env;
module.exports = class TenorCommand extends Command {
constructor(client) {
super(client, {
name: 'tenor',
aliases: ['tenor-gif'],
group: 'search',
memberName: 'tenor',
description: 'Searches Tenor for your query.',
args: [
{
key: 'query',
prompt: 'What GIF would you like to search for?',
type: 'string'
}
]
});
}
async run(msg, { query }) {
try {
const { body } = await request
.get('https://api.tenor.com/v1/search')
.query({
q: query,
key: TENOR_KEY,
limit: 50,
contentfilter: msg.channel.nsfw ? 'off' : 'high',
media_filter: 'minimal'
});
if (!body.results.length) return msg.say('Could not find any results.');
return msg.say(body.results[Math.floor(Math.random() * body.results.length)].media[0].gif.url);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};