From 342b01c7f51dbe8beef1d3deb37822080ed6097f Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Sat, 1 Jan 2022 17:03:48 -0500 Subject: a few things --- src/commands/moulberry-bush/capePermissions.ts | 79 ++++++++++++++++++++++++++ src/commands/moulberry-bush/capePerms.ts | 79 -------------------------- src/commands/moulberry-bush/capes.ts | 5 +- src/commands/moulberry-bush/report.ts | 2 + src/commands/moulberry-bush/serverStatus.ts | 2 + 5 files changed, 87 insertions(+), 80 deletions(-) create mode 100644 src/commands/moulberry-bush/capePermissions.ts delete mode 100644 src/commands/moulberry-bush/capePerms.ts (limited to 'src/commands/moulberry-bush') diff --git a/src/commands/moulberry-bush/capePermissions.ts b/src/commands/moulberry-bush/capePermissions.ts new file mode 100644 index 0000000..c873095 --- /dev/null +++ b/src/commands/moulberry-bush/capePermissions.ts @@ -0,0 +1,79 @@ +import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; +import { MessageEmbed } from 'discord.js'; +import got from 'got'; + +export default class CapePermissionsCommand extends BushCommand { + public constructor() { + super('capePermissions', { + aliases: ['cape-permissions', 'cape-perms', 'cape-perm'], + category: "Moulberry's Bush", + description: 'A command to see what capes someone has access to.', + usage: ['cape-permissions '], + examples: ['cape-permissions IRONM00N'], + args: [ + { + id: 'ign', + description: 'The ign of the player you would like to view the capes permissions of.', + type: 'string', + prompt: 'Who would you like to see the cape permissions of?', + retry: '{error} Choose someone to see the capes their available capes.', + slashType: 'STRING' + } + ], + slash: true, + clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), + userPermissions: [], + channel: 'guild' + }); + } + + public override async exec(message: BushMessage | BushSlashMessage, args: { ign: ArgType<'string'> }) { + interface CapePerms { + success: boolean; + perms: User[]; + } + + interface User { + _id: string; + perms: string[]; + } + + let capePerms: CapePerms | null, uuid: string; + try { + uuid = await util.mcUUID(args.ign); + } catch (e) { + return await message.util.reply(`${util.emojis.error} \`${args.ign}\` doesn't appear to be a valid username.`); + } + + try { + capePerms = await got.get('http://moulberry.codes/permscapes.json').json(); + } catch (error) { + capePerms = null; + } + if (capePerms == null) { + return await message.util.reply(`${util.emojis.error} There was an error finding cape perms for \`${args.ign}\`.`); + } else { + if (capePerms?.perms) { + let index = null; + + for (let i = 0; i < capePerms.perms.length; i++) { + if (capePerms.perms[i]._id == uuid) { + index = i; + break; + } + continue; + } + if (index == null) + return await message.util.reply(`${util.emojis.error} \`${args.ign}\` does not appear to have any capes.`); + const userPerm: string[] = capePerms.perms[index].perms; + const embed = new MessageEmbed() + .setTitle(`${args.ign}'s Capes`) + .setDescription(userPerm.join('\n')) + .setColor(util.colors.default); + await message.util.reply({ embeds: [embed] }); + } else { + return await message.util.reply(`${util.emojis.error} There was an error finding cape perms for ${args.ign}.`); + } + } + } +} diff --git a/src/commands/moulberry-bush/capePerms.ts b/src/commands/moulberry-bush/capePerms.ts deleted file mode 100644 index 71ca78e..0000000 --- a/src/commands/moulberry-bush/capePerms.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { BushCommand, type ArgType, type BushMessage, type BushSlashMessage } from '#lib'; -import { MessageEmbed } from 'discord.js'; -import got from 'got'; - -export default class CapePermissionsCommand extends BushCommand { - public constructor() { - super('capePermissions', { - aliases: ['cape-perms', 'cape-perm', 'cape-permissions'], - category: "Moulberry's Bush", - description: 'A command to see what capes someone has access to.', - usage: ['cape-perms '], - examples: ['cape-perms IRONM00N'], - args: [ - { - id: 'ign', - description: 'The ign of the player you would like to view the capes permissions of.', - type: 'string', - prompt: 'Who would you like to see the cape permissions of?', - retry: '{error} Choose someone to see the capes their available capes.', - slashType: 'STRING' - } - ], - slash: true, - clientPermissions: (m) => util.clientSendAndPermCheck(m, ['EMBED_LINKS'], true), - userPermissions: [], - channel: 'guild' - }); - } - - public override async exec(message: BushMessage | BushSlashMessage, args: { ign: ArgType<'string'> }) { - interface CapePerms { - success: boolean; - perms: User[]; - } - - interface User { - _id: string; - perms: string[]; - } - - let capePerms: CapePerms | null, uuid: string; - try { - uuid = await util.mcUUID(args.ign); - } catch (e) { - return await message.util.reply(`${util.emojis.error} \`${args.ign}\` doesn't appear to be a valid username.`); - } - - try { - capePerms = await got.get('http://moulberry.codes/permscapes.json').json(); - } catch (error) { - capePerms = null; - } - if (capePerms == null) { - return await message.util.reply(`${util.emojis.error} There was an error finding cape perms for \`${args.ign}\`.`); - } else { - if (capePerms?.perms) { - let index = null; - - for (let i = 0; i < capePerms.perms.length; i++) { - if (capePerms.perms[i]._id == uuid) { - index = i; - break; - } - continue; - } - if (index == null) - return await message.util.reply(`${util.emojis.error} \`${args.ign}\` does not appear to have any capes.`); - const userPerm: string[] = capePerms.perms[index].perms; - const embed = new MessageEmbed() - .setTitle(`${args.ign}'s Capes`) - .setDescription(userPerm.join('\n')) - .setColor(util.colors.default); - await message.util.reply({ embeds: [embed] }); - } else { - return await message.util.reply(`${util.emojis.error} There was an error finding cape perms for ${args.ign}.`); - } - } - } -} diff --git a/src/commands/moulberry-bush/capes.ts b/src/commands/moulberry-bush/capes.ts index ab6910a..117fd1c 100644 --- a/src/commands/moulberry-bush/capes.ts +++ b/src/commands/moulberry-bush/capes.ts @@ -1,7 +1,10 @@ import { BushCommand, ButtonPaginator, DeleteButton, type BushMessage, type OptionalArgType } from '#lib'; +import assert from 'assert'; import { AutocompleteInteraction, type MessageEmbedOptions } from 'discord.js'; import Fuse from 'fuse.js'; import got from 'got'; +assert(Fuse); +assert(got); export default class CapesCommand extends BushCommand { public constructor() { @@ -9,7 +12,7 @@ export default class CapesCommand extends BushCommand { aliases: ['capes', 'cape'], category: "Moulberry's Bush", description: 'A command to see what a cape looks like.', - usage: ['cape [cape]'], + usage: ['capes [cape]'], examples: ['capes', 'cape space'], args: [ { diff --git a/src/commands/moulberry-bush/report.ts b/src/commands/moulberry-bush/report.ts index ae67e00..90abc97 100644 --- a/src/commands/moulberry-bush/report.ts +++ b/src/commands/moulberry-bush/report.ts @@ -1,6 +1,8 @@ import { AllowedMentions, BushCommand, type ArgType, type BushMessage } from '#lib'; +import assert from 'assert'; import { MessageEmbed } from 'discord.js'; import moment from 'moment'; +assert(moment); export default class ReportCommand extends BushCommand { public constructor() { diff --git a/src/commands/moulberry-bush/serverStatus.ts b/src/commands/moulberry-bush/serverStatus.ts index 790ac09..3d8e780 100644 --- a/src/commands/moulberry-bush/serverStatus.ts +++ b/src/commands/moulberry-bush/serverStatus.ts @@ -1,6 +1,8 @@ import { BushCommand, type BushMessage } from '#lib'; +import assert from 'assert'; import { MessageEmbed } from 'discord.js'; import got from 'got'; +assert(got); export default class ServerStatusCommand extends BushCommand { public constructor() { -- cgit