Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add AnyContext.followup #318

Merged
merged 3 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/commands/applications/chatcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import type {
WebhookMessageStructure,
} from '../../client/transformers';
import type { If, MakeRequired, UnionToTuple, When } from '../../common';
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write';
import type {
InteractionCreateBodyRequest,
InteractionMessageUpdateBodyRequest,
MessageWebhookCreateBodyRequest,
} from '../../common/types/write';
import { type AllChannels, ChatInputCommandInteraction, type Message } from '../../structures';
import { MessageFlags } from '../../types';
import { BaseContext } from '../basecontext';
Expand Down Expand Up @@ -54,14 +58,6 @@ export class CommandContext<
metadata: CommandMetadata<UnionToTuple<M>> = {} as never;
globalMetadata: GlobalMetadata = {};

get proxy() {
return this.client.proxy;
}

get t() {
return this.client.t(this.interaction?.locale ?? this.client.langs.defaultLang ?? 'en-US');
}

get fullCommandName() {
return this.resolver.fullCommandName;
}
Expand Down Expand Up @@ -136,6 +132,11 @@ export class CommandContext<
return this.write(body as InteractionCreateBodyRequest, withResponse);
}

followup(body: MessageWebhookCreateBodyRequest) {
if (this.interaction) return this.interaction.followup(body);
return this.messageResponse!.reply(body);
}

async fetchResponse(): Promise<
If<InferWithPrefix, WebhookMessageStructure | MessageStructure, WebhookMessageStructure>
> {
Expand Down
5 changes: 5 additions & 0 deletions src/commands/applications/entrycontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type {
InteractionCreateBodyRequest,
InteractionMessageUpdateBodyRequest,
MakeRequired,
MessageWebhookCreateBodyRequest,
ModalCreateBodyRequest,
UnionToTuple,
When,
Expand Down Expand Up @@ -77,6 +78,10 @@ export class EntryPointContext<M extends keyof RegisteredMiddlewares = never> ex
return this.interaction.editOrReply<WR>(body as InteractionCreateBodyRequest, withResponse);
}

followup(body: MessageWebhookCreateBodyRequest) {
return this.interaction.followup(body);
}

fetchResponse(): Promise<WebhookMessageStructure> {
return this.interaction.fetchResponse();
}
Expand Down
5 changes: 5 additions & 0 deletions src/commands/applications/menucontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
type InteractionCreateBodyRequest,
type InteractionMessageUpdateBodyRequest,
type MakeRequired,
type MessageWebhookCreateBodyRequest,
type ModalCreateBodyRequest,
type UnionToTuple,
type When,
Expand Down Expand Up @@ -101,6 +102,10 @@ export class MenuCommandContext<
return this.interaction.editOrReply<WR>(body as InteractionCreateBodyRequest, withResponse);
}

followup(body: MessageWebhookCreateBodyRequest) {
return this.interaction.followup(body);
}

fetchResponse(): Promise<WebhookMessageStructure> {
return this.interaction.fetchResponse();
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/componentcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
InteractionCreateBodyRequest,
InteractionMessageUpdateBodyRequest,
MakeRequired,
MessageWebhookCreateBodyRequest,
ModalCreateBodyRequest,
UnionToTuple,
When,
Expand Down Expand Up @@ -130,6 +131,10 @@ export class ComponentContext<
return this.interaction.editOrReply<FR>(body as InteractionCreateBodyRequest, fetchReply);
}

followup(body: MessageWebhookCreateBodyRequest) {
return this.interaction.followup(body);
}

/**
* @returns A Promise that resolves to the fetched message
*/
Expand Down
5 changes: 5 additions & 0 deletions src/components/modalcontext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
InteractionCreateBodyRequest,
InteractionMessageUpdateBodyRequest,
MakeRequired,
MessageWebhookCreateBodyRequest,
ModalCreateBodyRequest,
UnionToTuple,
When,
Expand Down Expand Up @@ -99,6 +100,10 @@ export class ModalContext<M extends keyof RegisteredMiddlewares = never> extends
return this.interaction.editOrReply<FR>(body as InteractionCreateBodyRequest, fetchReply);
}

followup(body: MessageWebhookCreateBodyRequest) {
return this.interaction.followup(body);
}

/**
* @returns A Promise that resolves to the fetched message
*/
Expand Down
Loading