From 8c6ba57db441fb55380680723ea43e980e0e1ed8 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Fri, 8 Dec 2023 15:15:54 +0200 Subject: [PATCH] Bugfix to displaying missing permissions --- .../components/inhibitors/Permissions.ts | 7 +- .../components/observers/CommandHandler.ts | 209 +----------------- src/client/infractions/Ban.ts | 2 +- 3 files changed, 5 insertions(+), 213 deletions(-) diff --git a/src/client/components/inhibitors/Permissions.ts b/src/client/components/inhibitors/Permissions.ts index 0115bcd..62df4f9 100644 --- a/src/client/components/inhibitors/Permissions.ts +++ b/src/client/components/inhibitors/Permissions.ts @@ -6,19 +6,16 @@ import { PermissionSet } from '../../../../@types/Guild.js'; const safeCommands = [ 'command:settings', 'command:grant', 'command:revoke' ]; -class Permissions extends Inhibitor +class Permissions extends Inhibitor { - - constructor (client: DiscordClient) + constructor (client: DiscordClient) { - super(client, { name: 'permissions', priority: 5, guarded: true, guild: true }); - } async execute (invoker: InvokerWrapper, command: Pick, override: PermissionsString[] | null = null) diff --git a/src/client/components/observers/CommandHandler.ts b/src/client/components/observers/CommandHandler.ts index a97e742..b8696ba 100644 --- a/src/client/components/observers/CommandHandler.ts +++ b/src/client/components/observers/CommandHandler.ts @@ -16,7 +16,7 @@ const flagReg = /(?:^| )(?(?:--[a-z0-9]{3,})|(?:-[a-z]{1,2}))(?:$| )/iu; type ErrorParams = { type: string, inhibitor?: Inhibitor, - args?: FormatParams, + params?: FormatParams | null, error?: CommandError | boolean } @@ -599,211 +599,6 @@ class CommandHandler extends Observer return { options: args, verbose: true }; } - // Should be unnecessary -- moved to commandoption - // async _parseOption (interaction, option) - // { - // const { guild } = interaction; - - // const types = { - // POINTS: (value) => - // { - // return { value }; - // }, - // ROLES: async (string) => - // { - // const args = Util.parseQuotes(string).map(([ str ]) => str); - // const roles = await guild.resolveRoles(args); - // if (!roles.length) - // return { error: true }; - // return { value: roles }; - // }, - // MEMBERS: async (string) => - // { - // const args = Util.parseQuotes(string).map(([ str ]) => str); - // const members = await guild.resolveMembers(args, option.strict); - // if (!members.length) - // return { error: true, message: option.strict ? guild.format('O_COMMANDHANDLER_TYPEMEMBER_STRICT') : null }; - // return { value: members }; - // }, - // USERS: async (string) => - // { - // const args = Util.parseQuotes(string).map(([ str ]) => str); - // const users = await guild.resolveUsers(args, option.strict); - // if (!users.length) - // return { error: true, message: option.strict ? guild.format('O_COMMANDHANDLER_TYPEUSERS_STRICT') : null }; - // return { value: users }; - // }, - // CHANNELS: async (string) => - // { - // const args = Util.parseQuotes(string).map(([ str ]) => str); - // const channels = await guild.resolveChannels(args); - // if (!channels.length) - // return { error: true }; - // return { value: channels }; - // }, - // TEXT_CHANNELS: async (string) => - // { - // const args = Util.parseQuotes(string).map(([ str ]) => str); - // const channels = await guild.resolveChannels(args, null, (channel) => channel.type === ChannelType.GuildText); - // if (!channels.length) - // return { error: true }; - // return { value: channels }; - // }, - // VOICE_CHANNELS: async (string) => - // { - // const args = Util.parseQuotes(string).map(([ str ]) => str); - // const channels = await guild.resolveChannels(args, null, (channel) => channel.type === ChannelType.GuildVoice); - // if (!channels.length) - // return { error: true }; - // return { value: channels }; - // }, - // TIME: (string) => - // { - // const value = this.client.resolver.resolveTime(string); - // if (value === null) - // return { error: true }; - // return { error: false, value }; - // }, - // COMPONENT: (string) => - // { - // const [ component ] = this.client.resolver.components(string, 'any'); - // if (!component) - // return { error: true }; - // return { value: component }; - // }, - // COMPONENTS: (string) => - // { - // const strings = string.split(' '); - // const components = []; - // for (const str of strings) - // { - // const [ component ] = this.client.resolver.components(str, 'any'); - // if (component && !components.includes(component)) - // components.push(component); - // } - // if (!components.length) - // return { error: true }; - // return { value: components }; - // }, - // COMMAND: (string) => - // { - // const [ command ] = this.client.resolver.components(string, 'command'); - // if (!command) - // return { error: true }; - // return { value: command }; - // }, - // COMMANDS: (string) => - // { - // const strings = string.split(' '); - // const commands = []; - // for (const str of strings) - // { - // const [ command ] = this.client.resolver.components(str, 'command'); - // if (command && !commands.includes(command)) - // commands.push(command); - // } - // if (!commands.length) - // return { error: true }; - // return { value: commands }; - // }, - // MODULE: (string) => - // { - // const [ module ] = this.client.resolver.components(string, 'module'); - // if (!module) - // return { error: true }; - // return { value: module }; - // }, - // STRING: (string) => - // { - // return { error: false, value: string }; - // }, - // INTEGER: (integer) => - // { - // if (option.minimum !== undefined && integer < option.minimum) - // return { error: true }; - // if (option.maximum !== undefined && integer > option.maximum) - // return { error: true }; - // return { error: false, value: parseInt(integer) }; - // }, - // BOOLEAN: (boolean) => - // { - // boolean = this.client.resolver.resolveBoolean(boolean); - // return { error: false, value: boolean }; - // }, - // MEMBER: async (user) => - // { - // let member = null; - // try - // { - // member = await guild.members.fetch(user); - // } - // catch (error) - // {} // eslint-disable-line no-empty - // if (!member) - // return { error: true }; - // return { error: false, value: member }; - // }, - // USER: async (user) => - // { - // user = await this.client.users.fetch(user); - // return { error: false, value: user }; - // }, - // TEXT_CHANNEL: async (channel) => - // { - // channel = await guild.resolveChannel(channel); - // if (channel.type !== ChannelType.GuildText) - // return { error: true }; - // return { error: false, value: channel }; - // }, - // VOICE_CHANNEL: async (channel) => - // { - // channel = await guild.resolveChannel(channel); - // if (channel.type !== ChannelType.GuildVoice) - // return { error: true }; - // return { error: false, value: channel }; - // }, - // CHANNEL: async (channel) => - // { - // channel = await guild.resolveChannel(channel); - // return { error: false, value: channel }; - // }, - // ROLE: async (role) => - // { - // role = await guild.roles.fetch(role); - // return { error: false, value: role }; - // }, - // MENTIONABLE: (mentionable) => - // { - // return { error: false, value: mentionable }; - // }, - // NUMBER: (number) => - // { - // if (option.minimum !== undefined && number < option.minimum) - // return { error: true }; - // if (option.maximum !== undefined && number > option.maximum) - // return { error: true }; - // return { error: false, value: number }; - // }, - // FLOAT: (float) => - // { - // if (option.minimum !== undefined && float < option.minimum) - // return { error: true }; - // if (option.maximum !== undefined && float > option.maximum) - // return { error: true }; - // return { error: false, value: parseFloat(float) }; - // }, - // DATE: async (str) => - // { - // const date = await this.client.resolver.resolveDate(str); - // if (!date) - // return { error: true }; - // return { error: false, value: date }; - // } - // }; - - // return types[option.type](option._rawValue); - // } - async _getCommand (message: MessageWrapper) { @@ -880,7 +675,7 @@ class CommandHandler extends Observer inhibitor: () => { return { - content: `${invoker.format(info.inhibitor!.index, { command: invoker.command.resolveable, ...info.args })}\n**\`${info.inhibitor!.resolveable}\`**`, + content: `${invoker.format(info.inhibitor!.index, { command: invoker.command.resolveable, ...info.params })}\n**\`${info.inhibitor!.resolveable}\`**`, ephemeral: !invoker.replied }; } diff --git a/src/client/infractions/Ban.ts b/src/client/infractions/Ban.ts index 82904c3..87845cd 100644 --- a/src/client/infractions/Ban.ts +++ b/src/client/infractions/Ban.ts @@ -61,7 +61,7 @@ class BanInfraction extends Infraction { await this.guild.members.ban(this.target!.id, { reason: this._reason, - deleteMessageDays: days + deleteMessageSeconds: days * 24 * 60 * 60 }); } catch (error)