diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index 874bf8b..0000000 --- a/.editorconfig +++ /dev/null @@ -1,2 +0,0 @@ -[*] -end_of_line = lf \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json index e5496c2..8ef5cdf 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -248,7 +248,6 @@ "warn", "before" ], - "padding-line-between-statements": "warn", "padded-blocks": [ "warn", { diff --git a/package.json b/package.json index 9a4a860..a0a9bd9 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "type": "module", "scripts": { "start": "yarn build && node --enable-source-maps build/index.js", - "dev": "nodemon --signal SIGINT --delay 5 -e js --trace-warnings --unhandled-rejections=strict build/index.js", + "dev": "nodemon --delay 5 -e js --trace-warnings --unhandled-rejections=strict build/index.js", "debug": "node --trace-warnings --inspect index.js", "update": "git pull && cd api && yarn update", "test": "jest --detectOpenHandles", @@ -18,7 +18,7 @@ "type": "git", "url": "git+https://github.com/Navy-gif/New-GBot.git" }, - "author": "Navy.gif & Nolan", + "author": "Navy.gif", "license": "ISC", "bugs": { "url": "https://github.com/Navy-gif/New-GBot/issues" diff --git a/src/client/components/commands/moderation/Lockdown.ts b/src/client/components/commands/moderation/Lockdown.ts index 6c169b7..a18e23f 100644 --- a/src/client/components/commands/moderation/Lockdown.ts +++ b/src/client/components/commands/moderation/Lockdown.ts @@ -7,7 +7,6 @@ import InvokerWrapper from '../../wrappers/InvokerWrapper.js'; class LockdownCommand extends ModerationCommand { - constructor (client: DiscordClient) { super(client, { @@ -30,23 +29,21 @@ class LockdownCommand extends ModerationCommand clientPermissions: [ 'ManageChannels', 'ManageRoles' ], skipOptions: [ 'users', 'points', 'expiration', 'force', 'silent' ] }); - } async execute (invoker: InvokerWrapper, { channels, ...args }: CommandParams) { - if (!channels) throw new CommandError(invoker, { index: 'MODERATION_MISSING_CHANNELS' }); await invoker.reply({ content: 'Working...', emoji: 'loading' }); - return this.client.moderation.handleInfraction(Lockdown, invoker, { + const content = await this.client.moderation.handleInfraction(Lockdown, invoker, { targets: channels?.asChannels as TextChannel[], args }); - + if (typeof content === 'string') + await invoker.reply({ content, edit: true }); } - } export default LockdownCommand; \ No newline at end of file diff --git a/src/client/components/commands/moderation/Unlockdown.ts b/src/client/components/commands/moderation/Unlockdown.ts index 8f6812e..9888f1b 100644 --- a/src/client/components/commands/moderation/Unlockdown.ts +++ b/src/client/components/commands/moderation/Unlockdown.ts @@ -31,16 +31,16 @@ class UnlockdownCommand extends ModerationCommand async execute (invoker: InvokerWrapper, { channels, ...args }: CommandParams) { - if (!channels) throw new CommandError(invoker, { index: 'MODERATION_MISSING_CHANNELS' }); await invoker.reply({ content: 'Working...', emoji: 'loading' }); - return this.client.moderation.handleInfraction(Unlockdown, invoker, { + const content = await this.client.moderation.handleInfraction(Unlockdown, invoker, { targets: channels?.asChannels as TextChannel[], args }); - + if (typeof content === 'string') + await invoker.reply({ content, edit: true }); } } diff --git a/src/client/components/observers/CommandHandler.ts b/src/client/components/observers/CommandHandler.ts index 4736894..5d1a4ac 100644 --- a/src/client/components/observers/CommandHandler.ts +++ b/src/client/components/observers/CommandHandler.ts @@ -54,7 +54,7 @@ class CommandHandler extends Observer } // - async messageCreate (message: ExtendedMessage) + private async messageCreate (message: ExtendedMessage) { if (!this.client.ready || message.webhookId @@ -103,7 +103,7 @@ class CommandHandler extends Observer await this._executeCommand(invoker, result.options ?? {}); } - async interactionCreate (interaction: InteractionWrapper) + private async interactionCreate (interaction: InteractionWrapper) { if (!interaction.isCommand() && !interaction.isContextMenu()) @@ -144,7 +144,7 @@ class CommandHandler extends Observer } } - async _parseResult (invoker: InvokerWrapper, response: ParseResult) + private async _parseResult (invoker: InvokerWrapper, response: ParseResult) { // Ensure option dependencies outer: @@ -215,7 +215,7 @@ class CommandHandler extends Observer } } - async _handleInhibitors (invoker: InvokerWrapper) + private async _handleInhibitors (invoker: InvokerWrapper) { const inhibitors = this.client.registry.components.filter((comp): comp is Inhibitor => comp.type === 'inhibitor' && !comp.disabled); if (!inhibitors.size) @@ -236,7 +236,7 @@ class CommandHandler extends Observer return errors.sort((a, b) => b.inhibitor.priority - a.inhibitor.priority); } - async _executeCommand (invoker: InvokerWrapper, options: { [key: string]: CommandOption }) + private async _executeCommand (invoker: InvokerWrapper, options: { [key: string]: CommandOption }) { let response = null; if (this.client.developmentMode && !this.client.developers.includes(invoker.user.id)) @@ -295,7 +295,7 @@ class CommandHandler extends Observer return invoker.reply({ index: 'O_COMMANDHANDLER_COMMAND_NORESPONSE', ephemeral: !invoker.replied }); } - async _parseInteraction (invoker: InvokerWrapper, command: Command): Promise + private async _parseInteraction (invoker: InvokerWrapper, command: Command): Promise { const { subcommand, guild } = invoker; const interaction = invoker.target as InteractionWrapper; @@ -354,7 +354,7 @@ class CommandHandler extends Observer } // eslint-disable-next-line max-lines-per-function - async _parseMessage (invoker: InvokerWrapper, params: (string | null)[]): Promise + private async _parseMessage (invoker: InvokerWrapper, params: (string | null)[]): Promise { const { command, guild } = invoker; const message = invoker.target as MessageWrapper; @@ -599,7 +599,7 @@ class CommandHandler extends Observer return { options: args, verbose: true }; } - async _getCommand (message: MessageWrapper) + private async _getCommand (message: MessageWrapper) { if (!this.#mentionPattern) this.#mentionPattern = new RegExp(`^(<@!?${this.client.user!.id}>)`, 'iu'); @@ -634,13 +634,13 @@ class CommandHandler extends Observer } - _matchCommand (commandName: string) + private _matchCommand (commandName: string) { const [ command ] = this.client.resolver.components(commandName, 'command', true); return command || null; } - _generateError (invoker: InvokerWrapper, info: ErrorParams) + private _generateError (invoker: InvokerWrapper, info: ErrorParams) { const messages: {[key: string]: () => object} = { command: () => diff --git a/src/client/components/wrappers/InvokerWrapper.ts b/src/client/components/wrappers/InvokerWrapper.ts index 6701316..5e521c1 100644 --- a/src/client/components/wrappers/InvokerWrapper.ts +++ b/src/client/components/wrappers/InvokerWrapper.ts @@ -222,8 +222,7 @@ class InvokerWrapper + async reply (content: string | ReplyOptions = {}, opts: ReplyOptions = {}) : Promise { let options = opts; if (typeof content === 'object')