From 31af4675a38a375af44cc81cec3efedb079126c0 Mon Sep 17 00:00:00 2001 From: MARCROCK22 Date: Wed, 25 Dec 2024 20:01:35 -0400 Subject: [PATCH] fix: free code --- src/commands/applications/chatcontext.ts | 8 ++++---- src/commands/applications/entrycontext.ts | 8 ++++---- src/commands/applications/menucontext.ts | 10 +++++----- src/components/componentcontext.ts | 12 ++++++------ src/components/modalcontext.ts | 12 ++++++------ 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/commands/applications/chatcontext.ts b/src/commands/applications/chatcontext.ts index 95832b3..9fc94b8 100644 --- a/src/commands/applications/chatcontext.ts +++ b/src/commands/applications/chatcontext.ts @@ -144,7 +144,7 @@ export class CommandContext< } channel(mode?: 'rest' | 'flow'): Promise>; - channel(mode?: 'cache'): ReturnCache>; + channel(mode: 'cache'): ReturnCache>; channel(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (this.interaction?.channel && mode === 'cache') return this.client.cache.adapter.isAsync ? Promise.resolve(this.interaction.channel) : this.interaction.channel; @@ -160,7 +160,7 @@ export class CommandContext< } me(mode?: 'rest' | 'flow'): Promise; - me(mode?: 'cache'): ReturnCache; + me(mode: 'cache'): ReturnCache; me(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve(); @@ -176,7 +176,7 @@ export class CommandContext< } guild(mode?: 'rest' | 'flow'): Promise | undefined>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; guild(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return (mode === 'cache' @@ -227,5 +227,5 @@ export class CommandContext< export interface GuildCommandContext extends Omit, 'guildId' | 'member'>, 'guild'> { guild(mode?: 'rest' | 'flow'): Promise>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; } diff --git a/src/commands/applications/entrycontext.ts b/src/commands/applications/entrycontext.ts index 38ff610..5c97be7 100644 --- a/src/commands/applications/entrycontext.ts +++ b/src/commands/applications/entrycontext.ts @@ -82,7 +82,7 @@ export class EntryPointContext ex } channel(mode?: 'rest' | 'flow'): Promise; - channel(mode?: 'cache'): ReturnCache; + channel(mode: 'cache'): ReturnCache; channel(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (this.interaction.channel && mode === 'cache') return this.client.cache.adapter.isAsync ? Promise.resolve(this.interaction.channel) : this.interaction.channel; @@ -90,7 +90,7 @@ export class EntryPointContext ex } me(mode?: 'rest' | 'flow'): Promise; - me(mode?: 'cache'): ReturnCache; + me(mode: 'cache'): ReturnCache; me(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve(); @@ -103,7 +103,7 @@ export class EntryPointContext ex } guild(mode?: 'rest' | 'flow'): Promise | undefined>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; guild(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return ( @@ -145,5 +145,5 @@ export class EntryPointContext ex export interface GuildEntryPointContext extends Omit, 'guildId' | 'member'>, 'guild'> { guild(mode?: 'rest' | 'flow'): Promise>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; } diff --git a/src/commands/applications/menucontext.ts b/src/commands/applications/menucontext.ts index 6ed1acb..e4f1958 100644 --- a/src/commands/applications/menucontext.ts +++ b/src/commands/applications/menucontext.ts @@ -106,15 +106,15 @@ export class MenuCommandContext< } channel(mode?: 'rest' | 'flow'): Promise; - channel(mode?: 'cache'): ReturnCache; + channel(mode: 'cache'): ReturnCache; channel(mode: 'cache' | 'rest' | 'flow' = 'flow') { - if (this.interaction?.channel && mode === 'cache') + if (this.interaction.channel && mode === 'cache') return this.client.cache.adapter.isAsync ? Promise.resolve(this.interaction.channel) : this.interaction.channel; return this.client.channels.fetch(this.channelId, mode === 'rest'); } me(mode?: 'rest' | 'flow'): Promise; - me(mode?: 'cache'): ReturnCache; + me(mode: 'cache'): ReturnCache; me(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve(); @@ -127,7 +127,7 @@ export class MenuCommandContext< } guild(mode?: 'rest' | 'flow'): Promise | undefined>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; guild(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return ( @@ -179,5 +179,5 @@ export interface GuildMenuCommandContext< M extends keyof RegisteredMiddlewares = never, > extends Omit, 'guildId' | 'member'>, 'guild'> { guild(mode?: 'rest' | 'flow'): Promise>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; } diff --git a/src/components/componentcontext.ts b/src/components/componentcontext.ts index 45258b9..e0a11dc 100644 --- a/src/components/componentcontext.ts +++ b/src/components/componentcontext.ts @@ -62,7 +62,7 @@ export class ComponentContext< * Gets the language object for the interaction's locale. */ get t() { - return this.client.t(this.interaction?.locale ?? this.client.langs?.defaultLang ?? 'en-US'); + return this.client.t(this.interaction.locale ?? this.client.langs?.defaultLang ?? 'en-US'); } /** @@ -155,9 +155,9 @@ export class ComponentContext< * @returns A promise that resolves to the channel. */ channel(mode?: 'rest' | 'flow'): Promise; - channel(mode?: 'cache'): ReturnCache; + channel(mode: 'cache'): ReturnCache; channel(mode: 'cache' | 'rest' | 'flow' = 'flow') { - if (this.interaction?.channel && mode === 'cache') + if (this.interaction.channel && mode === 'cache') return this.client.cache.adapter.isAsync ? Promise.resolve(this.interaction.channel) : this.interaction.channel; return this.client.channels.fetch(this.channelId, mode === 'rest'); } @@ -168,7 +168,7 @@ export class ComponentContext< * @returns A promise that resolves to the bot member. */ me(mode?: 'rest' | 'flow'): Promise; - me(mode?: 'cache'): ReturnCache; + me(mode: 'cache'): ReturnCache; me(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve(); @@ -186,7 +186,7 @@ export class ComponentContext< * @returns A promise that resolves to the guild. */ guild(mode?: 'rest' | 'flow'): Promise | undefined>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; guild(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return ( @@ -275,5 +275,5 @@ export interface GuildComponentContext< M extends keyof RegisteredMiddlewares = never, > extends Omit, 'guildId' | 'member'>, 'guild'> { guild(mode?: 'rest' | 'flow'): Promise>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; } diff --git a/src/components/modalcontext.ts b/src/components/modalcontext.ts index 9945b78..e9cd2ef 100644 --- a/src/components/modalcontext.ts +++ b/src/components/modalcontext.ts @@ -53,7 +53,7 @@ export class ModalContext extends * Gets the language object for the interaction's locale. */ get t() { - return this.client.t(this.interaction?.locale ?? this.client.langs.defaultLang ?? 'en-US'); + return this.client.t(this.interaction.locale ?? this.client.langs.defaultLang ?? 'en-US'); } /** @@ -125,9 +125,9 @@ export class ModalContext extends * @returns A promise that resolves to the channel. */ channel(mode?: 'rest' | 'flow'): Promise; - channel(mode?: 'cache'): ReturnCache; + channel(mode: 'cache'): ReturnCache; channel(mode: 'cache' | 'rest' | 'flow' = 'flow') { - if (this.interaction?.channel && mode === 'cache') + if (this.interaction.channel && mode === 'cache') return this.client.cache.adapter.isAsync ? Promise.resolve(this.interaction.channel) : this.interaction.channel; return this.client.channels.fetch(this.channelId, mode === 'rest'); } @@ -138,7 +138,7 @@ export class ModalContext extends * @returns A promise that resolves to the bot member. */ me(mode?: 'rest' | 'flow'): Promise; - me(mode?: 'cache'): ReturnCache; + me(mode: 'cache'): ReturnCache; me(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return mode === 'cache' ? (this.client.cache.adapter.isAsync ? Promise.resolve() : undefined) : Promise.resolve(); @@ -156,7 +156,7 @@ export class ModalContext extends * @returns A promise that resolves to the guild. */ guild(mode?: 'rest' | 'flow'): Promise | undefined>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; guild(mode: 'cache' | 'rest' | 'flow' = 'flow') { if (!this.guildId) return ( @@ -210,5 +210,5 @@ export class ModalContext extends export interface GuildModalContext extends Omit, 'guildId' | 'member'>, 'guild'> { guild(mode?: 'rest' | 'flow'): Promise>; - guild(mode?: 'cache'): ReturnCache | undefined>; + guild(mode: 'cache'): ReturnCache | undefined>; }