Skip to content

Commit

Permalink
feat: add support for interaction#acknowledge for modals
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilloftheshadow committed Sep 6, 2024
1 parent 830fbd4 commit dcf5b44
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/kind-rice-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@buape/carbon": patch
---

feat: add support for interaction#acknowledge for modals
21 changes: 20 additions & 1 deletion packages/carbon/src/internals/ModalInteraction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { APIModalSubmitInteraction } from "discord-api-types/v10"
import {
InteractionResponseType,
Routes,
type APIModalSubmitInteraction
} from "discord-api-types/v10"
import { BaseInteraction } from "../abstracts/BaseInteraction.js"
import type { Client } from "../index.js"
import { FieldsHandler } from "./FieldsHandler.js"
Expand All @@ -13,4 +17,19 @@ export class ModalInteraction extends BaseInteraction<APIModalSubmitInteraction>
this.customId = data.data.custom_id
this.fields = new FieldsHandler(client, data)
}

/**
* Acknowledge the interaction, the user does not see a loading state.
* This can only be used for modals triggered from components
*/
async acknowledge() {
await this.client.rest.post(
Routes.interactionCallback(this.rawData.id, this.rawData.token),
{
body: {
type: InteractionResponseType.DeferredMessageUpdate
}
}
)
}
}

0 comments on commit dcf5b44

Please sign in to comment.