Fix various bugs, more aliases

This commit is contained in:
Dragon Fire
2020-04-23 18:18:15 -04:00
parent bca96c594f
commit 0e29e8c74b
13 changed files with 49 additions and 64 deletions
+1 -1
View File
@@ -13,7 +13,7 @@ module.exports = class BirthstoneCommand extends Command {
args: [
{
key: 'month',
prompt: 'What month would you like to get the Zodiac Sign for?',
prompt: 'What month would you like to get the birthstone for?',
type: 'month'
}
]
+1 -1
View File
@@ -32,7 +32,7 @@ module.exports = class GenderCommand extends Command {
.get(`https://api.genderize.io/`)
.query({ name });
if (!body.gender) return msg.say(`I have no idea what gender ${body.name} is.`);
return msg.say(`I'm ${body.probability * 100}% sure ${body.name} is a ${body.gender} name.`);
return msg.say(`I'm ${Math.round(body.probability * 100)}% sure ${body.name} is a ${body.gender} name.`);
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
+3 -3
View File
@@ -40,7 +40,7 @@ module.exports = class HoroscopeCommand extends Command {
const embed = new MessageEmbed()
.setColor(0x9797FF)
.setTitle(`Horoscope for ${firstUpperCase(sign)}...`)
.setURL(`https://new.theastrologer.com/${sign}/`)
.setURL(`https://astrology.tv/horoscope/signs/${sign}/`)
.setFooter('© Kelli Fox, The Astrologer')
.setTimestamp()
.setDescription(horoscope);
@@ -51,8 +51,8 @@ module.exports = class HoroscopeCommand extends Command {
}
async fetchHoroscope(sign) {
const { text } = await request.get(`https://new.theastrologer.com/${sign}/`);
const { text } = await request.get(`https://astrology.tv/horoscope/signs/${sign}/`);
const $ = cheerio.load(text);
return $('#today').find('p').first().text();
return $('div[class="ct-text-block day-tabs-content_horoscope"]').eq(1).text();
}
};
+1 -1
View File
@@ -20,6 +20,6 @@ module.exports = class IDCommand extends Command {
}
run(msg, { user }) {
return msg.say(`${user.username}'s ID is ${user.id}.`);
return msg.reply(`${user.id === msg.author.id ? 'Your' : `${user.username}'s`} ID is ${user.id}.`);
}
};
+12 -16
View File
@@ -1,7 +1,6 @@
const Command = require('../../structures/Command');
const moment = require('moment');
const { MessageEmbed } = require('discord.js');
const { stripIndents } = require('common-tags');
const filterLevels = {
DISABLED: 'Off',
MEMBERS_WITHOUT_ROLES: 'No Role',
@@ -33,21 +32,18 @@ module.exports = class ServerCommand extends Command {
const embed = new MessageEmbed()
.setColor(0x00AE86)
.setThumbnail(msg.guild.iconURL({ format: 'png' }))
.setAuthor(msg.guild.name)
.setDescription(stripIndents`
**General Info:**
• ID: ${msg.guild.id}
• Owner: ${msg.guild.owner.user.tag}
• Region: ${msg.guild.region.toUpperCase()}
• Creation Date: ${moment.utc(msg.guild.createdAt).format('MM/DD/YYYY h:mm A')}
Explicit Filter: ${filterLevels[msg.guild.explicitContentFilter]}
Verification Level: ${verificationLevels[msg.guild.verificationLevel]}
**Server Stats:**
• Members: ${msg.guild.memberCount}
• Roles: ${msg.guild.roles.cache.size}
• Channels: ${msg.guild.channels.cache.filter(channel => channel.type !== 'category').size}
`);
.addField(' Name', msg.guild.name, true)
.addField(' ID', msg.guild.id, true)
.addField(' Creation Date', moment.utc(msg.guild.createdAt).format('MM/DD/YYYY h:mm A'), true)
.addField(' Owner', msg.guild.owner.user.tag, true)
.addField(' Boost Count', msg.guild.premiumSubscriptionCount || 0, true)
.addField(' Boost Tier', msg.guild.premiumTier ? `Tier ${msg.guild.premiumTier}` : 'None', true)
.addField(' Region', msg.guild.region.toUpperCase(), true)
.addField(' Explicit Filter', filterLevels[msg.guild.explicitContentFilter], true)
.addField(' Verification Level', verificationLevels[msg.guild.verificationLevel], true)
.addField(' Members', msg.guild.memberCount, true)
.addField(' Roles', msg.guild.roles.cache.size, true)
.addField(' Channels', msg.guild.channels.cache.filter(channel => channel.type !== 'category').size, true);
return msg.embed(embed);
}
};
+14 -23
View File
@@ -1,7 +1,6 @@
const Command = require('../../structures/Command');
const moment = require('moment');
const { MessageEmbed } = require('discord.js');
const { stripIndents } = require('common-tags');
const { trimArray } = require('../../util/Util');
const flags = {
DISCORD_EMPLOYEE: 'Discord Employee',
@@ -40,17 +39,14 @@ module.exports = class UserCommand extends Command {
}
async run(msg, { user }) {
const embed = new MessageEmbed()
.setAuthor(user.tag)
.setThumbnail(user.displayAvatarURL({ format: 'png', dynamic: true }));
const userFlags = user.flags.toArray();
let description = stripIndents`
**General User Info:**
• ID: ${user.id}
Discord Join Date: ${moment.utc(user.createdAt).format('MM/DD/YYYY h:mm A')}
${user.bot ? 'Bot' : 'Not a Bot'}
• Flags: ${userFlags.length ? userFlags.map(flag => flags[flag]).join(', ') : 'None'}
`;
const embed = new MessageEmbed()
.setThumbnail(user.displayAvatarURL({ format: 'png', dynamic: true }))
.setAuthor(user.tag)
.addField(' Discord Join Date', moment.utc(user.createdAt).format('MM/DD/YYYY h:mm A'), true)
.addField(' ID', user.id, true)
.addField(' Bot?', user.bot ? 'Yes' : 'No', true)
.addField(' Flags', userFlags.length ? userFlags.map(flag => flags[flag]).join(', ') : 'None');
if (msg.guild) {
try {
const member = await msg.guild.members.fetch(user.id);
@@ -59,18 +55,13 @@ module.exports = class UserCommand extends Command {
.filter(role => role.id !== defaultRole.id)
.sort((a, b) => b.position - a.position)
.map(role => role.name);
description += '\n\n';
description += stripIndents`
**Server Member Info:**
• Nickname: ${member.nickname || 'None'}
• Server Join Date: ${moment.utc(member.joinedAt).format('MM/DD/YYYY h:mm A')}
• Highest Role: ${member.roles.highest.id === defaultRole.id ? 'None' : member.roles.highest.name}
• Hoist Role: ${member.roles.hoist ? member.roles.hoist.name : 'None'}
**Roles (${roles.length})**
${roles.length ? trimArray(roles, 6).join(', ') : 'None'}
`;
embed.setColor(member.displayHexColor);
embed
.addField(' Server Join Date', moment.utc(member.joinedAt).format('MM/DD/YYYY h:mm A'), true)
.addField(' Highest Role',
member.roles.highest.id === defaultRole.id ? 'None' : member.roles.highest.name, true)
.addField(' Hoist Role', member.roles.hoist ? member.roles.hoist.name : 'None', true)
.addField(` Roles (${roles.length})`, roles.length ? trimArray(roles, 6).join(', ') : 'None')
.setColor(member.displayHexColor);
} catch {
embed.setFooter('Failed to resolve member, showing basic user information instead.');
}
+1 -1
View File
@@ -36,7 +36,7 @@ module.exports = class DrawCardsCommand extends Command {
if (!this.deck) this.deck = this.generateDeck();
let cards = this.deck;
if (!jokers) cards = cards.filter(card => !card.includes('Joker'));
return msg.reply(shuffle(cards).slice(0, amount).join('\n'));
return msg.reply(`${amount === 1 ? '' : '\n'}${shuffle(cards).slice(0, amount).join('\n')}`);
}
generateDeck() {
+1
View File
@@ -5,6 +5,7 @@ module.exports = class NumberFactCommand extends Command {
constructor(client) {
super(client, {
name: 'number-fact',
aliases: ['num-fact'],
group: 'random-res',
memberName: 'number-fact',
description: 'Responds with a random fact about a specific number.',
+1 -1
View File
@@ -4,7 +4,7 @@ module.exports = class ShowerThoughtCommand extends SubredditCommand {
constructor(client) {
super(client, {
name: 'shower-thought',
aliases: ['shower-thoughts'],
aliases: ['shower-thoughts', 'shower', 's-thought', 'shower-t'],
group: 'random-res',
memberName: 'shower-thought',
description: 'Responds with a random shower thought, directly from r/Showerthoughts.',
+1 -1
View File
@@ -5,7 +5,7 @@ module.exports = class SuggestCommandCommand extends Command {
constructor(client) {
super(client, {
name: 'suggest-command',
aliases: ['command-suggestion', 'command-suggest'],
aliases: ['command-suggestion', 'command-suggest', 'suggest-cmd', 'cmd-suggest'],
group: 'random-res',
memberName: 'suggest-command',
description: 'Suggests a random command for you to try.'
+11 -13
View File
@@ -27,9 +27,9 @@ module.exports = class DerpibooruCommand extends Command {
async run(msg, { query }) {
try {
const id = await this.search(query);
if (!id) return msg.say('Could not find any results.');
const url = await this.fetchImage(id);
const url = await this.search(query, msg.channel.nsfw || false);
if (!url) return msg.say('Could not find any results.');
if (url === 'nsfw') return msg.say('The image I found was NSFW, and this isn\'t the channel for that.');
return msg.say(url);
} catch (err) {
if (err.status === 404) return msg.say('Could not find any results.');
@@ -37,19 +37,17 @@ module.exports = class DerpibooruCommand extends Command {
}
}
async search(query) {
async search(query, nsfw) {
const { body } = await request
.get('https://derpibooru.org/search.json')
.get('https://derpibooru.org/api/v1/json/search')
.query({
q: query,
random_image: 1
per_page: 1,
sf: 'random'
});
if (!body) return null;
return body.id;
}
async fetchImage(id) {
const { body } = await request.get(`https://derpibooru.org/images/${id}.json`);
return `http:${body.representations.full}`;
if (!body || !body.images || !body.images.length) return null;
const image = body.images[0];
if (!image.tags.includes('safe') && !nsfw) return 'nsfw';
return image.representations.full;
}
};
+1 -2
View File
@@ -59,8 +59,7 @@ module.exports = class LeagueOfLegendsCommand extends Command {
.addField(' Armor', `${data.stats.armor} (${data.stats.armorperlevel}/level)`, true)
.addField(' Attack Damage', `${data.stats.attackdamage} (${data.stats.attackdamageperlevel}/level)`, true)
.addField(' Attack Range', data.stats.attackrange, true)
.addField(' Attack Speed Offset',
`${data.stats.attackspeedoffset} (${data.stats.attackspeedperlevel}/level)`, true)
.addField(' Attack Speed', `${data.stats.attackspeed} (${data.stats.attackspeedperlevel}/level)`, true)
.addField(' Crit', `${data.stats.crit} (${data.stats.critperlevel}/level)`, true)
.addField(' Move Speed', data.stats.movespeed, true)
.addField(' Spell Block', `${data.stats.spellblock} (${data.stats.spellblockperlevel}/level)`, true)
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "113.15.2",
"version": "113.15.3",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {