diff --git a/packages/core/src/structures/interactions.ts b/packages/core/src/structures/interactions.ts index 8a9d553..a7b6bda 100644 --- a/packages/core/src/structures/interactions.ts +++ b/packages/core/src/structures/interactions.ts @@ -306,6 +306,13 @@ export abstract class BaseInteraction implements Model { return this.sendFollowUp(data); } + /** + * internal usage only, same as respond but doesn't tries to follow up + * */ + async respond_(resp: InteractionResponse): Promise { + if (!this.responded) return this.respond(resp) as Promise; + } + // start custom methods async respondWith( @@ -328,6 +335,31 @@ export abstract class BaseInteraction implements Model { }); } + /** + * taken from Detritus + * try respond, try edit, try follow up + * */ + async editOrReply(resp: InteractionResponseWithData & EditWebhookMessage) { + if (this.responded) { + return this.editReply(resp); + } + + let type: InteractionResponseTypes = InteractionResponseTypes.ChannelMessageWithSource; + + switch (this.type) { + case InteractionTypes.ApplicationCommand: + type = InteractionResponseTypes.ChannelMessageWithSource; + break; + case InteractionTypes.MessageComponent: + type = InteractionResponseTypes.UpdateMessage; + break; + } + + const result = await this.respond({ type, data: resp }); + + return result; + } + // end custom methods } diff --git a/packages/core/src/structures/webhook.ts b/packages/core/src/structures/webhook.ts index 821bdc9..317ee7e 100644 --- a/packages/core/src/structures/webhook.ts +++ b/packages/core/src/structures/webhook.ts @@ -21,6 +21,7 @@ import { WEBHOOK_MESSAGE, WEBHOOK_MESSAGE_ORIGINAL, } from '@biscuitland/api-types'; +import { NewEmbed } from './embed'; export type ExecuteWebhookOptions = WebhookOptions & CreateMessage & { avatarUrl?: string; username?: string }; @@ -87,7 +88,7 @@ export class Webhook implements Model { const data = { content: options?.content, - embeds: options?.embeds, + embeds: options?.embeds?.map(NewEmbed), tts: options?.tts, allowed_mentions: options?.allowedMentions, components: options?.components, @@ -158,7 +159,7 @@ export class Webhook implements Model { : WEBHOOK_MESSAGE_ORIGINAL(this.id, this.token), { content: options?.content, - embeds: options?.embeds, + embeds: options?.embeds?.map(NewEmbed), file: options?.files, components: options?.components, allowed_mentions: options?.allowedMentions && {