mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 10:03:31 +01:00
types: Export some core-specific types (#10620)
types: export core-specific types Co-Authored-By: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -16,6 +16,26 @@ import {
|
||||
} from 'discord-api-types/v10';
|
||||
import type { WebhooksAPI } from './webhook.js';
|
||||
|
||||
export interface CreateInteractionResponseOptions
|
||||
extends APIInteractionResponseCallbackData,
|
||||
RESTPostAPIInteractionCallbackQuery {
|
||||
files?: RawFile[];
|
||||
}
|
||||
|
||||
export type CreateInteractionDeferResponseOptions = APIInteractionResponseDeferredChannelMessageWithSource['data'] &
|
||||
RESTPostAPIInteractionCallbackQuery;
|
||||
|
||||
export type CreateInteractionFollowUpResponseOptions = APIInteractionResponseCallbackData & { files?: RawFile[] };
|
||||
export type EditInteractionResponseOptions = APIInteractionResponseCallbackData & { files?: RawFile[] };
|
||||
|
||||
export type CreateInteractionUpdateMessageResponseOptions = APIInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { files?: RawFile[] };
|
||||
|
||||
export type CreateAutocompleteResponseOptions = APICommandAutocompleteInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery;
|
||||
|
||||
export type CreateModalResponseOptions = APIModalInteractionResponseCallbackData & RESTPostAPIInteractionCallbackQuery;
|
||||
|
||||
export class InteractionsAPI {
|
||||
public constructor(
|
||||
private readonly rest: REST,
|
||||
@@ -34,8 +54,7 @@ export class InteractionsAPI {
|
||||
public async reply(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
body: APIInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { files?: RawFile[]; with_response: true },
|
||||
body: CreateInteractionResponseOptions & { with_response: true },
|
||||
options?: Pick<RequestData, 'signal'>,
|
||||
): Promise<RESTPostAPIInteractionCallbackWithResponseResult>;
|
||||
|
||||
@@ -51,19 +70,14 @@ export class InteractionsAPI {
|
||||
public async reply(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
body: APIInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { files?: RawFile[]; with_response?: false },
|
||||
body: CreateInteractionResponseOptions & { with_response?: false },
|
||||
options?: Pick<RequestData, 'signal'>,
|
||||
): Promise<undefined>;
|
||||
|
||||
public async reply(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
{
|
||||
files,
|
||||
with_response,
|
||||
...data
|
||||
}: APIInteractionResponseCallbackData & RESTPostAPIInteractionCallbackQuery & { files?: RawFile[] },
|
||||
{ files, with_response, ...data }: CreateInteractionResponseOptions,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
const response = await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), {
|
||||
@@ -92,8 +106,7 @@ export class InteractionsAPI {
|
||||
public async defer(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
body: APIInteractionResponseDeferredChannelMessageWithSource['data'] &
|
||||
RESTPostAPIInteractionCallbackQuery & { with_response: true },
|
||||
body: CreateInteractionDeferResponseOptions & { with_response: true },
|
||||
options?: Pick<RequestData, 'signal'>,
|
||||
): Promise<RESTPostAPIInteractionCallbackWithResponseResult>;
|
||||
|
||||
@@ -109,18 +122,14 @@ export class InteractionsAPI {
|
||||
public async defer(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
body?: APIInteractionResponseDeferredChannelMessageWithSource['data'] &
|
||||
RESTPostAPIInteractionCallbackQuery & { with_response?: false },
|
||||
body?: CreateInteractionDeferResponseOptions & { with_response?: false },
|
||||
options?: Pick<RequestData, 'signal'>,
|
||||
): Promise<undefined>;
|
||||
|
||||
public async defer(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
{
|
||||
with_response,
|
||||
...data
|
||||
}: APIInteractionResponseDeferredChannelMessageWithSource['data'] & RESTPostAPIInteractionCallbackQuery = {},
|
||||
{ with_response, ...data }: CreateInteractionDeferResponseOptions = {},
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
const response = await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), {
|
||||
@@ -198,7 +207,7 @@ export class InteractionsAPI {
|
||||
public async followUp(
|
||||
applicationId: Snowflake,
|
||||
interactionToken: string,
|
||||
body: APIInteractionResponseCallbackData & { files?: RawFile[] },
|
||||
body: CreateInteractionFollowUpResponseOptions,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
return this.webhooks.execute(applicationId, interactionToken, { ...body, wait: true }, { signal });
|
||||
@@ -218,7 +227,7 @@ export class InteractionsAPI {
|
||||
public async editReply(
|
||||
applicationId: Snowflake,
|
||||
interactionToken: string,
|
||||
callbackData: APIInteractionResponseCallbackData & { files?: RawFile[] },
|
||||
callbackData: EditInteractionResponseOptions,
|
||||
messageId?: Snowflake | '@original',
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
@@ -280,8 +289,7 @@ export class InteractionsAPI {
|
||||
public async updateMessage(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
callbackData: APIInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { files?: RawFile[]; with_response: true },
|
||||
callbackData: CreateInteractionUpdateMessageResponseOptions & { with_response: true },
|
||||
options: Pick<RequestData, 'signal'>,
|
||||
): Promise<RESTPostAPIInteractionCallbackWithResponseResult>;
|
||||
|
||||
@@ -297,19 +305,14 @@ export class InteractionsAPI {
|
||||
public async updateMessage(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
callbackData: APIInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { files?: RawFile[]; with_response?: false },
|
||||
callbackData: CreateInteractionUpdateMessageResponseOptions & { with_response?: false },
|
||||
options: Pick<RequestData, 'signal'>,
|
||||
): Promise<undefined>;
|
||||
|
||||
public async updateMessage(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
{
|
||||
files,
|
||||
with_response,
|
||||
...data
|
||||
}: APIInteractionResponseCallbackData & RESTPostAPIInteractionCallbackQuery & { files?: RawFile[] },
|
||||
{ files, with_response, ...data }: CreateInteractionUpdateMessageResponseOptions,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
const response = await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), {
|
||||
@@ -338,8 +341,7 @@ export class InteractionsAPI {
|
||||
public async createAutocompleteResponse(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
callbackData: APICommandAutocompleteInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { with_response: true },
|
||||
callbackData: CreateAutocompleteResponseOptions & { with_response: true },
|
||||
options?: Pick<RequestData, 'signal'>,
|
||||
): Promise<RESTPostAPIInteractionCallbackWithResponseResult>;
|
||||
|
||||
@@ -355,18 +357,14 @@ export class InteractionsAPI {
|
||||
public async createAutocompleteResponse(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
callbackData: APICommandAutocompleteInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { with_response?: false },
|
||||
callbackData: CreateAutocompleteResponseOptions & { with_response?: false },
|
||||
options: Pick<RequestData, 'signal'>,
|
||||
): Promise<undefined>;
|
||||
|
||||
public async createAutocompleteResponse(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
{
|
||||
with_response,
|
||||
...data
|
||||
}: APICommandAutocompleteInteractionResponseCallbackData & RESTPostAPIInteractionCallbackQuery,
|
||||
{ with_response, ...data }: CreateAutocompleteResponseOptions,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
const response = await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), {
|
||||
@@ -394,8 +392,7 @@ export class InteractionsAPI {
|
||||
public async createModal(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
callbackData: APIModalInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { with_response: true },
|
||||
callbackData: CreateModalResponseOptions & { with_response: true },
|
||||
options?: Pick<RequestData, 'signal'>,
|
||||
): Promise<RESTPostAPIInteractionCallbackWithResponseResult>;
|
||||
|
||||
@@ -411,15 +408,14 @@ export class InteractionsAPI {
|
||||
public async createModal(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
callbackData: APIModalInteractionResponseCallbackData &
|
||||
RESTPostAPIInteractionCallbackQuery & { with_response?: false },
|
||||
callbackData: CreateModalResponseOptions & { with_response?: false },
|
||||
options?: Pick<RequestData, 'signal'>,
|
||||
): Promise<undefined>;
|
||||
|
||||
public async createModal(
|
||||
interactionId: Snowflake,
|
||||
interactionToken: string,
|
||||
{ with_response, ...data }: APIModalInteractionResponseCallbackData & RESTPostAPIInteractionCallbackQuery,
|
||||
{ with_response, ...data }: CreateModalResponseOptions,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
const response = await this.rest.post(Routes.interactionCallback(interactionId, interactionToken), {
|
||||
|
||||
Reference in New Issue
Block a user