Reddit User Command

This commit is contained in:
Daniel Odendahl Jr
2018-09-23 15:48:42 +00:00
parent c5b33b6254
commit d6aa321412
3 changed files with 51 additions and 2 deletions
+2 -1
View File
@@ -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.
+48
View File
@@ -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!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "91.9.1",
"version": "91.10.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {