diff --git a/README.md b/README.md index 7182115d..4b58710a 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 (315) +## Commands (316) ### Utility: * **eval:** Executes JavaScript code. @@ -154,6 +154,7 @@ on the [home server](https://discord.gg/sbMe32W). * **periodic-table:** Finds an element on the periodic table. * **pokedex:** Searches the Pokédex for a Pokémon. * **recipe:** Searches for recipes based on your query. +* **reddit-user:** Responds with information on a Reddit user. * **rotten-tomatoes:** Searches Rotten Tomatoes for your query. * **rule-of-the-internet:** Responds with a rule of the internet. * **safebooru:** Responds with an image from Safebooru, with optional query. diff --git a/commands/search/reddit-user.js b/commands/search/reddit-user.js new file mode 100644 index 00000000..a4183c15 --- /dev/null +++ b/commands/search/reddit-user.js @@ -0,0 +1,48 @@ +const Command = require('../../structures/Command'); +const { MessageEmbed } = require('discord.js'); +const request = require('node-superfetch'); +const moment = require('moment'); + +module.exports = class RedditUserCommand extends Command { + constructor(client) { + super(client, { + name: 'reddit-user', + aliases: ['reddit-u', 'u/', 'karma', 'reddit-karma'], + group: 'search', + memberName: 'reddit-user', + description: 'Responds with information on a Reddit user.', + clientPermissions: ['EMBED_LINKS'], + args: [ + { + key: 'user', + prompt: 'What user would you like to get information on?', + type: 'string', + parse: user => encodeURIComponent(user) + } + ] + }); + } + + async run(msg, { user }) { + try { + const { body } = await request.get(`https://www.reddit.com/user/${user}/about.json`); + const { data } = body; + const embed = new MessageEmbed() + .setColor(0xFF4500) + .setAuthor('Reddit', 'https://i.imgur.com/DSBOK0P.png', 'https://www.reddit.com/') + .setThumbnail(data.icon_img) + .addField('❯ Username', data.name, true) + .addField('❯ ID', data.id, true) + .addField('❯ Karma', data.link_karma + data.comment_karma, true) + .addField('❯ Creation Date', moment.utc(data.created * 1000).format('MM/DD/YYYY h:mm A'), true) + .addField('❯ Gold?', data.is_gold ? 'Yes' : 'No', true) + .addField('❯ Verified?', data.verified ? 'Yes' : 'No', true) + .addField('❯ Suspended?', data.is_suspended ? 'Yes' : 'No', true) + .addField('❯ Over 18?', data.over_18 ? 'Yes' : 'No', true); + return msg.embed(embed); + } catch (err) { + if (err.status === 404) return msg.say('Could not find any results.'); + return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`); + } + } +}; diff --git a/package.json b/package.json index 9a83ceae..453d861b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "91.9.1", + "version": "91.10.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {