From 2d66c896b9ab7fac426061fccd6ffa413242bc6a Mon Sep 17 00:00:00 2001 From: IRONM00N <64110067+IRONM00N@users.noreply.github.com> Date: Thu, 5 Aug 2021 18:48:38 -0400 Subject: remove explicit any and add error for code block --- src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts | 1 - src/lib/extensions/discord-akairo/BushClientUtil.ts | 13 +++++++++---- src/lib/extensions/discord-akairo/BushCommand.ts | 1 - src/lib/extensions/discord-akairo/BushCommandHandler.ts | 1 - src/lib/extensions/discord-akairo/BushInhibitor.ts | 1 - src/lib/extensions/discord.js/BushGuildMemberManager.d.ts | 1 - src/lib/utils/BushLogger.ts | 1 - 7 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src/lib') diff --git a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts index 9afcf8b..42d989c 100644 --- a/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts +++ b/src/lib/extensions/discord-akairo/BushArgumentTypeCaster.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { BushMessage } from '../discord.js/BushMessage'; export type BushArgumentTypeCaster = (message: BushMessage, phrase: string) => any; diff --git a/src/lib/extensions/discord-akairo/BushClientUtil.ts b/src/lib/extensions/discord-akairo/BushClientUtil.ts index d8705a3..aa35edb 100644 --- a/src/lib/extensions/discord-akairo/BushClientUtil.ts +++ b/src/lib/extensions/discord-akairo/BushClientUtil.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import { @@ -462,7 +461,13 @@ export class BushClientUtil extends ClientUtil { if (code.length + formattingLength >= length) hasteOut = 'Too large to display. Hastebin: ' + (await this.haste(code)); const code2 = hasteOut ? code.substring(0, length - (hasteOut.length + '\n'.length + formattingLength)) : code; - return tildes + language + '\n' + code2 + '\n' + tildes + (hasteOut.length ? '\n' + hasteOut : ''); + const code3 = tildes + language + '\n' + code2 + '\n' + tildes + (hasteOut.length ? '\n' + hasteOut : ''); + if (code3.length > length) { + void console.warn(`codeblockError`, `Required Length: ${length}. Actual Length: ${code3.length}`); + void console.warn(`codeblockError`, code3); + throw new Error('I fucked up'); + } + return code3; } #mapCredential(old: string): string { @@ -492,11 +497,11 @@ export class BushClientUtil extends ClientUtil { return text; } - public async inspectCleanRedactCodeblock(input: any, language: 'ts' | 'js', inspectOptions?: InspectOptions) { + public async inspectCleanRedactCodeblock(input: any, language: 'ts' | 'js', inspectOptions?: InspectOptions, length = 1024) { input = typeof input !== 'string' && inspectOptions !== undefined ? inspect(input, inspectOptions) : input; input = Util.cleanCodeBlockContent(input); input = this.redact(input); - return client.util.codeblock(input, 1024, language); + return client.util.codeblock(input, length, language); } public async slashRespond( diff --git a/src/lib/extensions/discord-akairo/BushCommand.ts b/src/lib/extensions/discord-akairo/BushCommand.ts index 6dd5449..0266b1d 100644 --- a/src/lib/extensions/discord-akairo/BushCommand.ts +++ b/src/lib/extensions/discord-akairo/BushCommand.ts @@ -1,5 +1,4 @@ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { ArgumentOptions, ArgumentPromptOptions, ArgumentTypeCaster, Command, CommandOptions } from 'discord-akairo'; import { Snowflake } from 'discord.js'; import { BushMessage } from '../discord.js/BushMessage'; diff --git a/src/lib/extensions/discord-akairo/BushCommandHandler.ts b/src/lib/extensions/discord-akairo/BushCommandHandler.ts index 7eca05b..cf49f4f 100644 --- a/src/lib/extensions/discord-akairo/BushCommandHandler.ts +++ b/src/lib/extensions/discord-akairo/BushCommandHandler.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { Category, CommandHandler, CommandHandlerEvents, CommandHandlerOptions } from 'discord-akairo'; import { Collection, PermissionString } from 'discord.js'; import { BushConstants } from '../../utils/BushConstants'; diff --git a/src/lib/extensions/discord-akairo/BushInhibitor.ts b/src/lib/extensions/discord-akairo/BushInhibitor.ts index 8a199fc..d689a72 100644 --- a/src/lib/extensions/discord-akairo/BushInhibitor.ts +++ b/src/lib/extensions/discord-akairo/BushInhibitor.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { Inhibitor } from 'discord-akairo'; import { BushMessage } from '../discord.js/BushMessage'; import { BushClient } from './BushClient'; diff --git a/src/lib/extensions/discord.js/BushGuildMemberManager.d.ts b/src/lib/extensions/discord.js/BushGuildMemberManager.d.ts index b3f2b1b..cd74fff 100644 --- a/src/lib/extensions/discord.js/BushGuildMemberManager.d.ts +++ b/src/lib/extensions/discord.js/BushGuildMemberManager.d.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ import { AddGuildMemberOptions, BanOptions, diff --git a/src/lib/utils/BushLogger.ts b/src/lib/utils/BushLogger.ts index cf5969c..27c8cd1 100644 --- a/src/lib/utils/BushLogger.ts +++ b/src/lib/utils/BushLogger.ts @@ -1,4 +1,3 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable @typescript-eslint/explicit-module-boundary-types */ import chalk from 'chalk'; import { MessageEmbed, Util } from 'discord.js'; -- cgit