mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-17 16:19:12 +02:00
Format numbers, style changes, fixes
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const SubredditCommand = require('../../structures/commands/Subreddit');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { list } = require('../../util/Util');
|
||||
const { list, formatNumber } = require('../../util/Util');
|
||||
const subreddits = require('../../assets/json/meme');
|
||||
|
||||
module.exports = class MemeCommand extends SubredditCommand {
|
||||
@@ -34,6 +34,6 @@ module.exports = class MemeCommand extends SubredditCommand {
|
||||
.setImage(post.post_hint === 'image' ? post.url : null)
|
||||
.setURL(`https://www.reddit.com${post.permalink}`)
|
||||
.setTimestamp(post.created_utc * 1000)
|
||||
.setFooter(`⬆ ${post.ups}`);
|
||||
.setFooter(`⬆ ${formatNumber(post.ups)}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const sides = ['NaN', '0', 'null', 'undefined', '\'\''];
|
||||
const sides = [NaN, 0, null, undefined, ''];
|
||||
|
||||
module.exports = class QuantumCoinCommand extends Command {
|
||||
constructor(client) {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const Command = require('../../structures/Command');
|
||||
|
||||
module.exports = class UserRouletteCommand extends Command {
|
||||
module.exports = class RandomUserCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'user-roulette',
|
||||
aliases: ['member-roulette', 'random-user', 'random-member'],
|
||||
name: 'random-user',
|
||||
aliases: ['member-roulette', 'user-roulette', 'random-member'],
|
||||
group: 'random',
|
||||
memberName: 'user-roulette',
|
||||
memberName: 'random-user',
|
||||
description: 'Randomly chooses a member of the server.',
|
||||
guildOnly: true
|
||||
});
|
||||
@@ -1,5 +1,6 @@
|
||||
const SubredditCommand = require('../../structures/commands/Subreddit');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
|
||||
module.exports = class RedditCommand extends SubredditCommand {
|
||||
constructor(client) {
|
||||
@@ -29,6 +30,6 @@ module.exports = class RedditCommand extends SubredditCommand {
|
||||
.setImage(post.post_hint === 'image' ? post.url : null)
|
||||
.setURL(`https://www.reddit.com${post.permalink}`)
|
||||
.setTimestamp(post.created_utc * 1000)
|
||||
.setFooter(`⬆ ${post.ups}`);
|
||||
.setFooter(`⬆ ${formatNumber(post.ups)}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { formatNumber } = require('../../util/Util');
|
||||
|
||||
module.exports = class RollCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -21,6 +22,6 @@ module.exports = class RollCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg, { value }) {
|
||||
return msg.say(`You rolled a ${Math.floor(Math.random() * value) + 1}.`);
|
||||
return msg.say(`You rolled a ${formatNumber(Math.floor(Math.random() * value) + 1)}.`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -15,21 +15,18 @@ module.exports = class SuperpowerCommand extends Command {
|
||||
|
||||
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 });
|
||||
const data = body.sections[0];
|
||||
const id = await this.random();
|
||||
const article = this.fetchSuperpower(id);
|
||||
return msg.reply(stripIndents`
|
||||
Your superpower is... **${data.title}**!
|
||||
_${shorten(data.content.map(section => section.text).join('\n\n'), 1950)}_
|
||||
Your superpower is... **${article.title}**!
|
||||
_${shorten(article.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() {
|
||||
async random() {
|
||||
const { body } = await request
|
||||
.get('http://powerlisting.wikia.com/api.php')
|
||||
.query({
|
||||
@@ -42,4 +39,11 @@ module.exports = class SuperpowerCommand extends Command {
|
||||
});
|
||||
return body.query.random[0].id;
|
||||
}
|
||||
|
||||
async fetchSuperpower(id) {
|
||||
const { body } = await request
|
||||
.get('http://powerlisting.wikia.com/api/v1/Articles/AsSimpleJson/')
|
||||
.query({ id });
|
||||
return body.sections[0];
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user