mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Superpower Command
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "84.0.0",
|
||||
"version": "84.1.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user