diff options
Diffstat (limited to 'lib/utils')
-rw-r--r-- | lib/utils/Arg.ts | 36 | ||||
-rw-r--r-- | lib/utils/BotClientUtils.ts (renamed from lib/utils/BushClientUtils.ts) | 24 | ||||
-rw-r--r-- | lib/utils/Constants.ts (renamed from lib/utils/BushConstants.ts) | 0 | ||||
-rw-r--r-- | lib/utils/ErrorHandler.ts | 8 | ||||
-rw-r--r-- | lib/utils/FormatResponse.ts | 4 | ||||
-rw-r--r-- | lib/utils/Logger.ts (renamed from lib/utils/BushLogger.ts) | 11 | ||||
-rw-r--r-- | lib/utils/Minecraft.ts | 4 | ||||
-rw-r--r-- | lib/utils/Minecraft_Test.ts | 10 | ||||
-rw-r--r-- | lib/utils/Utils.ts (renamed from lib/utils/BushUtils.ts) | 16 |
9 files changed, 54 insertions, 59 deletions
diff --git a/lib/utils/Arg.ts b/lib/utils/Arg.ts index d362225..99060fb 100644 --- a/lib/utils/Arg.ts +++ b/lib/utils/Arg.ts @@ -1,7 +1,7 @@ import { - type BaseBushArgumentType, - type BushArgumentType, - type BushArgumentTypeCaster, + type BaseBotArgumentType, + type BotArgumentType, + type BotArgumentTypeCaster, type CommandMessage, type SlashMessage } from '#lib'; @@ -160,33 +160,33 @@ export function withInput(type: AT | ATC): ATC { return Argument.withInput(type as any); } -type BushArgumentTypeCasterReturn<R> = R extends BushArgumentTypeCaster<infer S> ? S : R; +type CustomArgumentTypeCasterReturn<R> = R extends BotArgumentTypeCaster<infer S> ? S : R; /** ```ts - * <R = unknown> = BushArgumentTypeCaster<R> + * <R = unknown> = CustomArgumentTypeCaster<R> * ``` */ -type ATC<R = unknown> = BushArgumentTypeCaster<R>; +type ATC<R = unknown> = BotArgumentTypeCaster<R>; /** ```ts - * keyof BaseBushArgumentType + * keyof BaseCustomArgumentType * ``` */ -type KBAT = keyof BaseBushArgumentType; +type KBAT = keyof BaseBotArgumentType; /** ```ts - * <R> = BushArgumentTypeCasterReturn<R> + * <R> = CustomArgumentTypeCasterReturn<R> * ``` */ -type ATCR<R> = BushArgumentTypeCasterReturn<R>; +type ATCR<R> = CustomArgumentTypeCasterReturn<R>; /** ```ts - * BushArgumentType + * CustomArgumentType * ``` */ -type AT = BushArgumentType; +type AT = BotArgumentType; /** ```ts - * BaseBushArgumentType + * BaseCustomArgumentType * ``` */ -type BAT = BaseBushArgumentType; +type BAT = BaseBotArgumentType; /** ```ts - * <T extends BushArgumentTypeCaster> = BushArgumentTypeCaster<BushArgumentTypeCasterReturn<T>> + * <T extends CustomArgumentTypeCaster> = CustomArgumentTypeCaster<CustomArgumentTypeCasterReturn<T>> * ``` */ -type ATCATCR<T extends BushArgumentTypeCaster> = BushArgumentTypeCaster<BushArgumentTypeCasterReturn<T>>; +type ATCATCR<T extends BotArgumentTypeCaster> = BotArgumentTypeCaster<CustomArgumentTypeCasterReturn<T>>; /** ```ts - * <T extends keyof BaseBushArgumentType> = BushArgumentTypeCaster<BaseBushArgumentType[T]> + * <T extends keyof BaseCustomArgumentType> = CustomArgumentTypeCaster<BaseCustomArgumentType[T]> * ``` */ -type ATCBAT<T extends keyof BaseBushArgumentType> = BushArgumentTypeCaster<BaseBushArgumentType[T]>; +type ATCBAT<T extends keyof BaseBotArgumentType> = BotArgumentTypeCaster<BaseBotArgumentType[T]>; diff --git a/lib/utils/BushClientUtils.ts b/lib/utils/BotClientUtils.ts index e468cd7..a251bdf 100644 --- a/lib/utils/BushClientUtils.ts +++ b/lib/utils/BotClientUtils.ts @@ -1,7 +1,7 @@ import { ConfigChannelKey } from '#config'; -import type { BushInspectOptions, CodeBlockLang } from '#lib'; -import { GlobalCache, SharedCache } from '#lib/common/BushCache.js'; -import { CommandMessage } from '#lib/extensions/discord-akairo/BushCommand.js'; +import type { CodeBlockLang, CustomInspectOptions } from '#lib'; +import { GlobalCache, SharedCache } from '#lib/common/BotCache.js'; +import { CommandMessage } from '#lib/extensions/discord-akairo/BotCommand.js'; import { SlashMessage } from '#lib/extensions/discord-akairo/SlashMessage.js'; import { Global, Shared } from '#lib/models/index.js'; import assert from 'assert/strict'; @@ -22,14 +22,14 @@ import { type UserResolvable } from 'discord.js'; import _ from 'lodash'; -import { emojis, Pronoun, PronounCode, pronounMapping, regex } from './BushConstants.js'; -import { addOrRemoveFromArray, formatError, inspect } from './BushUtils.js'; +import { emojis, Pronoun, PronounCode, pronounMapping, regex } from './Constants.js'; import { generateErrorEmbed } from './ErrorHandler.js'; +import { addOrRemoveFromArray, formatError, inspect } from './Utils.js'; /** * Utilities that require access to the client. */ -export class BushClientUtils { +export class BotClientUtils { /** * The hastebin urls used to post to hastebin, attempts to post in order */ @@ -185,14 +185,14 @@ export class BushClientUtils { * (and uploads to hast if the content is too long). * @param input The object to be inspect, redacted, and put into a codeblock. * @param language The language to make the codeblock. - * @param inspectOptions The options for {@link BushClientUtil.inspect}. + * @param inspectOptions The options for {@link CustomClientUtil.inspect}. * @param length The maximum length that the codeblock can be. * @returns The generated codeblock. */ public async inspectCleanRedactCodeblock( input: any, language?: CodeBlockLang | '', - inspectOptions?: BushInspectOptions, + inspectOptions?: CustomInspectOptions, length = 1024 ) { input = inspect(input, inspectOptions ?? undefined); @@ -205,10 +205,10 @@ export class BushClientUtils { /** * Takes an any value, inspects it, redacts credentials, and uploads it to haste. * @param input The object to be inspect, redacted, and upload. - * @param inspectOptions The options for {@link BushClientUtil.inspect}. + * @param inspectOptions The options for {@link BotClientUtils.inspect}. * @returns The {@link HasteResults}. */ - public async inspectCleanRedactHaste(input: any, inspectOptions?: BushInspectOptions): Promise<HasteResults> { + public async inspectCleanRedactHaste(input: any, inspectOptions?: CustomInspectOptions): Promise<HasteResults> { input = inspect(input, inspectOptions ?? undefined); input = this.redact(input); return this.haste(input, true); @@ -217,10 +217,10 @@ export class BushClientUtils { /** * Takes an any value, inspects it and redacts credentials. * @param input The object to be inspect and redacted. - * @param inspectOptions The options for {@link BushClientUtil.inspect}. + * @param inspectOptions The options for {@link BotClientUtils.inspect}. * @returns The redacted and inspected object. */ - public inspectAndRedact(input: any, inspectOptions?: BushInspectOptions): string { + public inspectAndRedact(input: any, inspectOptions?: CustomInspectOptions): string { input = inspect(input, inspectOptions ?? undefined); return this.redact(input); } diff --git a/lib/utils/BushConstants.ts b/lib/utils/Constants.ts index 8e4871b..8e4871b 100644 --- a/lib/utils/BushConstants.ts +++ b/lib/utils/Constants.ts diff --git a/lib/utils/ErrorHandler.ts b/lib/utils/ErrorHandler.ts index 923da75..3f8be89 100644 --- a/lib/utils/ErrorHandler.ts +++ b/lib/utils/ErrorHandler.ts @@ -1,14 +1,14 @@ import { AkairoMessage, Command } from 'discord-akairo'; import { ChannelType, Client, EmbedBuilder, escapeInlineCode, GuildTextBasedChannel, Message } from 'discord.js'; -import { BushCommandHandlerEvents } from '../extensions/discord-akairo/BushCommandHandler.js'; +import { BotCommandHandlerEvents } from '../extensions/discord-akairo/BotCommandHandler.js'; import { SlashMessage } from '../extensions/discord-akairo/SlashMessage.js'; -import { colors } from './BushConstants.js'; -import { capitalize, formatError } from './BushUtils.js'; +import { colors } from './Constants.js'; import { bold, input } from './Format.js'; +import { capitalize, formatError } from './Utils.js'; export async function handleCommandError( client: Client, - ...[error, message, _command]: BushCommandHandlerEvents['error'] | BushCommandHandlerEvents['slashError'] + ...[error, message, _command]: BotCommandHandlerEvents['error'] | BotCommandHandlerEvents['slashError'] ) { try { const isSlash = message.util?.isSlash; diff --git a/lib/utils/FormatResponse.ts b/lib/utils/FormatResponse.ts index f094601..470fea7 100644 --- a/lib/utils/FormatResponse.ts +++ b/lib/utils/FormatResponse.ts @@ -1,8 +1,8 @@ import type { GuildMember } from 'discord.js'; import { unmuteResponse, UnmuteResponse } from '../extensions/discord.js/ExtendedGuildMember.js'; -import { emojis } from './BushConstants.js'; -import { format } from './BushUtils.js'; +import { emojis } from './Constants.js'; import { input } from './Format.js'; +import { format } from './Utils.js'; export function formatUnmuteResponse(prefix: string, member: GuildMember, code: UnmuteResponse): string { const error = emojis.error; diff --git a/lib/utils/BushLogger.ts b/lib/utils/Logger.ts index f575b50..872ff3e 100644 --- a/lib/utils/BushLogger.ts +++ b/lib/utils/Logger.ts @@ -1,12 +1,11 @@ import chalk from 'chalk'; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -import { type SendMessageType } from '#lib/extensions/discord-akairo/BushClient.js'; import { bold, Client, EmbedBuilder, escapeMarkdown, PartialTextBasedChannelFields, type Message } from 'discord.js'; import { stripVTControlCharacters as stripColor } from 'node:util'; import repl, { REPLServer, REPL_MODE_STRICT } from 'repl'; import { WriteStream } from 'tty'; -import { colors } from './BushConstants.js'; -import { inspect } from './BushUtils.js'; +import type { SendMessageType } from '../types/misc.js'; +import { colors } from './Constants.js'; +import { inspect } from './Utils.js'; let REPL: REPLServer; let replGone = false; @@ -25,7 +24,7 @@ export function init() { }); const apply = (stream: WriteStream, symbol: symbol): ProxyHandler<typeof console['log']>['apply'] => - function apply(target, thisArg, args) { + function apply(target, _thisArg, args) { if (stream.isTTY) { stream.moveCursor(0, -1); stream.write('\n'); @@ -121,7 +120,7 @@ function pad(num: number) { /** * Custom logging utility for the bot. */ -export class BushLogger { +export class Logger { /** * @param client The client. */ diff --git a/lib/utils/Minecraft.ts b/lib/utils/Minecraft.ts index 50c44ef..e189b66 100644 --- a/lib/utils/Minecraft.ts +++ b/lib/utils/Minecraft.ts @@ -2,10 +2,6 @@ import { Byte, Int } from '@ironm00n/nbt-ts'; import { BitField } from 'discord.js'; -import path from 'path'; -import { fileURLToPath } from 'url'; - -const __dirname = path.dirname(fileURLToPath(import.meta.url)); export enum FormattingCodes { Black = '§0', diff --git a/lib/utils/Minecraft_Test.ts b/lib/utils/Minecraft_Test.ts index fce9d5b..7dae3f6 100644 --- a/lib/utils/Minecraft_Test.ts +++ b/lib/utils/Minecraft_Test.ts @@ -110,7 +110,7 @@ export class NeuItem { this.petLoreReplacements(); } - private petLoreReplacements(level = -1) { + private petLoreReplacements(_level = -1) { if (/.*?;[0-5]$/.test(this.internalName) && this.displayName.includes('LVL')) { const maxLevel = neuPets?.custom_pet_leveling?.[this.internalName]?.max_level ?? 100; this.displayName = this.displayName.replace('LVL', `1➡${maxLevel}`); @@ -122,14 +122,14 @@ export class NeuItem { const petInfoTier = nums[teir]; if (!petInfoTier) throw new Error(`Pet (${this.internalName}) has no pet nums for ${teir} rarity.`); - const curve = petInfoTier?.stats_levelling_curve?.split(';'); + // const curve = petInfoTier?.stats_levelling_curve?.split(';'); // todo: finish copying from neu - const minStatsLevel = parseInt(curve?.[0] ?? '0'); - const maxStatsLevel = parseInt(curve?.[0] ?? '100'); + // const minStatsLevel = parseInt(curve?.[0] ?? '0'); + // const maxStatsLevel = parseInt(curve?.[0] ?? '100'); - const lore = ''; + // const lore = ''; } } } diff --git a/lib/utils/BushUtils.ts b/lib/utils/Utils.ts index 1922204..f7404e1 100644 --- a/lib/utils/BushUtils.ts +++ b/lib/utils/Utils.ts @@ -1,12 +1,12 @@ import { Arg, - BushClient, CommandMessage, SlashEditMessageType, SlashSendMessageType, + TanzaniteClient, timeUnits, - type BaseBushArgumentType, - type BushInspectOptions, + type BaseBotArgumentType, + type CustomInspectOptions, type SlashMessage } from '#lib'; import { humanizeDuration as humanizeDurationMod } from '@notenoughupdates/humanize-duration'; @@ -117,7 +117,7 @@ export interface UuidRes { * @param options The options to create defaults with. * @returns The default options combined with the specified options. */ -function getDefaultInspectOptions(options?: BushInspectOptions): BushInspectOptions { +function getDefaultInspectOptions(options?: CustomInspectOptions): CustomInspectOptions { return { showHidden: options?.showHidden ?? false, depth: options?.depth ?? 2, @@ -140,7 +140,7 @@ function getDefaultInspectOptions(options?: BushInspectOptions): BushInspectOpti * @param options - The options you would like to use to inspect the object. * @returns The inspected object. */ -export function inspect(object: any, options?: BushInspectOptions): string { +export function inspect(object: any, options?: CustomInspectOptions): string { const optionsWithDefaults = getDefaultInspectOptions(options); if (!optionsWithDefaults.inspectStrings && typeof object === 'string') return object; @@ -497,7 +497,7 @@ export { AkairoUtil as akairo }; /** * The link to invite the bot with all permissions. */ -export function invite(client: BushClient) { +export function invite(client: TanzaniteClient) { return client.generateInvite({ permissions: PermissionsBitField.All - @@ -545,9 +545,9 @@ export interface ParsedDurationRes { * @param message The message that triggered the command. * @returns The casted argument. */ -export async function cast<T extends keyof BaseBushArgumentType>( +export async function cast<T extends keyof BaseBotArgumentType>( type: T, - arg: BaseBushArgumentType[T] | string, + arg: BaseBotArgumentType[T] | string, message: CommandMessage | SlashMessage ) { return typeof arg === 'string' ? await Arg.cast(type, message, arg) : arg; |