Superpower Command

This commit is contained in:
Daniel Odendahl Jr
2018-07-09 17:54:36 +00:00
parent d5eae880ea
commit 1b67dd0f43
3 changed files with 47 additions and 2 deletions
+2 -1
View File
@@ -15,7 +15,7 @@ You can invite the bot to your server using
Be sure to also join the [home server](https://discord.gg/sbMe32W) for
information and support.
## Commands (290)
## Commands (291)
### Utility:
* **prefix**: Shows or sets the command prefix.
@@ -85,6 +85,7 @@ information and support.
* **roll**: Rolls a dice with a maximum value of your choice.
* **security-key**: Responds with a random security key.
* **shower-thought**: Responds with a random shower thought, directly from r/Showerthoughts.
* **superpower**: Responds with a random superpower.
* **user-roulette**: Randomly chooses a member of the server.
* **would-you-rather**: Responds with a random "Would you rather ...?" question.
* **xiao**: Responds with a random image of Xiao Pai.
+44
View File
@@ -0,0 +1,44 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { stripIndents } = require('common-tags');
const { shorten } = require('../../util/Util');
module.exports = class SuperpowerCommand extends Command {
constructor(client) {
super(client, {
name: 'superpower',
group: 'random',
memberName: 'superpower',
description: 'Responds with a random superpower.'
});
}
async run(msg) {
try {
const article = await this.randomSuperpower();
const { body } = await request
.get('http://powerlisting.wikia.com/api/v1/Articles/AsSimpleJson/')
.query({ id: article });
return msg.reply(stripIndents`
Your superpower is... **${body.title}**!
_${shorten(body.sections[0].content.map(section => section.text).join('\n\n'), 1950)}_
`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
async randomSuperpower() {
const { body } = await request
.get('http://powerlisting.wikia.com/api.php')
.query({
action: 'query',
list: 'random',
rnnamespace: 0,
rnlimit: 1,
format: 'json',
formatversion: 2
});
return body.query.random[0].id;
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "84.0.0",
"version": "84.1.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {