feat: premium application subscriptions (#9907)

* feat: premium application subscriptions

* types: readonly array

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* fix: requested changes

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* fix: core client types

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Almeida
2023-12-24 15:49:58 +00:00
committed by GitHub
parent 520d6f64dd
commit c4fcee3ef6
33 changed files with 914 additions and 10 deletions

View File

@@ -1,14 +1,16 @@
/* eslint-disable jsdoc/check-param-names */
import type { RawFile, RequestData, REST } from '@discordjs/rest';
import { InteractionResponseType, Routes } from 'discord-api-types/v10';
import type {
APICommandAutocompleteInteractionResponseCallbackData,
APIInteractionResponseCallbackData,
APIModalInteractionResponseCallbackData,
RESTGetAPIWebhookWithTokenMessageResult,
Snowflake,
APIInteractionResponseDeferredChannelMessageWithSource,
import {
InteractionResponseType,
Routes,
type APICommandAutocompleteInteractionResponseCallbackData,
type APIInteractionResponseCallbackData,
type APIInteractionResponseDeferredChannelMessageWithSource,
type APIModalInteractionResponseCallbackData,
type APIPremiumRequiredInteractionResponse,
type RESTGetAPIWebhookWithTokenMessageResult,
type Snowflake,
} from 'discord-api-types/v10';
import type { WebhooksAPI } from './webhook.js';
@@ -248,4 +250,26 @@ export class InteractionsAPI {
signal,
});
}
/**
* Sends a premium required response to an interaction
*
* @see {@link https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response}
* @param interactionId - The id of the interaction
* @param interactionToken - The token of the interaction
* @param options - The options for sending the premium required response
*/
public async sendPremiumRequired(
interactionId: Snowflake,
interactionToken: string,
{ signal }: Pick<RequestData, 'signal'> = {},
) {
await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), {
auth: false,
body: {
type: InteractionResponseType.PremiumRequired,
} satisfies APIPremiumRequiredInteractionResponse,
signal,
});
}
}