diff --git a/.env.example b/.env.example index e4291289..a8fe08fe 100644 --- a/.env.example +++ b/.env.example @@ -30,6 +30,7 @@ IMGUR_KEY= OSU_KEY= PERSONAL_GOOGLE_CALENDAR_ID= STACKOVERFLOW_KEY= +TENOR_KEY= TMDB_KEY= TUMBLR_KEY= TWITTER_KEY= diff --git a/README.md b/README.md index 723af145..41e12c9e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Xiao is a Discord bot coded in JavaScript with The bot is no longer available for invite. You can self-host the bot, or use her on the [home server](https://discord.gg/sbMe32W). -## Commands (320) +## Commands (321) ### Utility: * **eval:** Executes JavaScript code. @@ -164,6 +164,7 @@ on the [home server](https://discord.gg/sbMe32W). * **stack-overflow:** Searches Stack Overflow for your query. * **steam:** Searches Steam for your query. * **stocks:** Responds with the current stocks for a specific symbol. +* **tenor:** Searches Tenor for your query. * **tmdb-movie:** Searches TMDB for your query, getting movie results. * **tmdb-tv-show:** Searches TMDB for your query, getting TV show results. * **tumblr:** Responds with information on a Tumblr blog. diff --git a/commands/random/suggest-command.js b/commands/random/suggest-command.js index ded41dda..9fa844ab 100644 --- a/commands/random/suggest-command.js +++ b/commands/random/suggest-command.js @@ -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.' diff --git a/commands/search/tenor.js b/commands/search/tenor.js new file mode 100644 index 00000000..39c4a14b --- /dev/null +++ b/commands/search/tenor.js @@ -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!`); + } + } +}; diff --git a/package.json b/package.json index ba49a2cc..97e72729 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "91.13.1", + "version": "91.14.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {