mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(api): various fixes for overlooked stuff (#9588)
* types(GuildsAPI): fix `getWidgetSettings()` result type * types(GuildsAPI): fix `beginPrune()` result type * types(GuildsAPI): fix `editAutoModerationRule()` result type * types(ApplicationCommandsAPI): fix guild application types * types(GuildsAPI): fix `createTemplate()` body type * fix(InteractionsAPI): make `followUp()` return the message According to the Discord docs, creating a followup message is the same as executing a webhook, but *wait is always true*, meaning we always get the message. * types(WebhooksAPI): fix result types
This commit is contained in:
@@ -5,18 +5,26 @@ import {
|
||||
Routes,
|
||||
type RESTGetAPIApplicationCommandPermissionsResult,
|
||||
type RESTGetAPIApplicationCommandResult,
|
||||
type RESTGetAPIApplicationCommandsQuery,
|
||||
type RESTGetAPIApplicationCommandsResult,
|
||||
type RESTGetAPIApplicationGuildCommandResult,
|
||||
type RESTGetAPIApplicationGuildCommandsQuery,
|
||||
type RESTGetAPIApplicationGuildCommandsResult,
|
||||
type RESTGetAPIGuildApplicationCommandsPermissionsResult,
|
||||
type RESTPatchAPIApplicationCommandJSONBody,
|
||||
type RESTPatchAPIApplicationCommandResult,
|
||||
type RESTPatchAPIApplicationGuildCommandJSONBody,
|
||||
type RESTPatchAPIApplicationGuildCommandResult,
|
||||
type RESTPostAPIApplicationCommandsJSONBody,
|
||||
type RESTPostAPIApplicationCommandsResult,
|
||||
type RESTPostAPIApplicationGuildCommandsJSONBody,
|
||||
type RESTPostAPIApplicationGuildCommandsResult,
|
||||
type RESTPutAPIApplicationCommandPermissionsJSONBody,
|
||||
type RESTPutAPIApplicationCommandPermissionsResult,
|
||||
type RESTPutAPIApplicationCommandsJSONBody,
|
||||
type RESTGetAPIApplicationCommandsQuery,
|
||||
type RESTPutAPIApplicationCommandsResult,
|
||||
type RESTGetAPIApplicationGuildCommandsQuery,
|
||||
type RESTPutAPIApplicationGuildCommandsJSONBody,
|
||||
type RESTPutAPIApplicationGuildCommandsResult,
|
||||
type Snowflake,
|
||||
} from 'discord-api-types/v10';
|
||||
|
||||
@@ -153,7 +161,7 @@ export class ApplicationCommandsAPI {
|
||||
return this.rest.get(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||
query: makeURLSearchParams(query),
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIApplicationCommandsResult>;
|
||||
}) as Promise<RESTGetAPIApplicationGuildCommandsResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,13 +176,13 @@ export class ApplicationCommandsAPI {
|
||||
public async createGuildCommand(
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
body: RESTPostAPIApplicationCommandsJSONBody,
|
||||
body: RESTPostAPIApplicationGuildCommandsJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
return this.rest.post(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPostAPIApplicationCommandsResult>;
|
||||
}) as Promise<RESTPostAPIApplicationGuildCommandsResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +202,7 @@ export class ApplicationCommandsAPI {
|
||||
) {
|
||||
return this.rest.get(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIApplicationCommandResult>;
|
||||
}) as Promise<RESTGetAPIApplicationGuildCommandResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -211,13 +219,13 @@ export class ApplicationCommandsAPI {
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
commandId: Snowflake,
|
||||
body: RESTPatchAPIApplicationCommandJSONBody,
|
||||
body: RESTPatchAPIApplicationGuildCommandJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
return this.rest.patch(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPatchAPIApplicationCommandResult>;
|
||||
}) as Promise<RESTPatchAPIApplicationGuildCommandResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,13 +258,13 @@ export class ApplicationCommandsAPI {
|
||||
public async bulkOverwriteGuildCommands(
|
||||
applicationId: Snowflake,
|
||||
guildId: Snowflake,
|
||||
body: RESTPutAPIApplicationCommandsJSONBody,
|
||||
body: RESTPutAPIApplicationGuildCommandsJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
return this.rest.put(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPutAPIApplicationCommandsResult>;
|
||||
}) as Promise<RESTPutAPIApplicationGuildCommandsResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,8 +47,10 @@ import type {
|
||||
RESTGetAPIGuildWelcomeScreenResult,
|
||||
RESTGetAPIGuildWidgetImageResult,
|
||||
RESTGetAPIGuildWidgetJSONResult,
|
||||
RESTGetAPIGuildWidgetSettingsResult,
|
||||
RESTGetAPITemplateResult,
|
||||
RESTPatchAPIAutoModerationRuleJSONBody,
|
||||
RESTPatchAPIAutoModerationRuleResult,
|
||||
RESTPatchAPIGuildChannelPositionsJSONBody,
|
||||
RESTPatchAPIGuildEmojiJSONBody,
|
||||
RESTPatchAPIGuildEmojiResult,
|
||||
@@ -78,6 +80,7 @@ import type {
|
||||
RESTPostAPIGuildEmojiJSONBody,
|
||||
RESTPostAPIGuildEmojiResult,
|
||||
RESTPostAPIGuildPruneJSONBody,
|
||||
RESTPostAPIGuildPruneResult,
|
||||
RESTPostAPIGuildRoleJSONBody,
|
||||
RESTPostAPIGuildRoleResult,
|
||||
RESTPostAPIGuildScheduledEventJSONBody,
|
||||
@@ -85,8 +88,8 @@ import type {
|
||||
RESTPostAPIGuildsJSONBody,
|
||||
RESTPostAPIGuildsMFAResult,
|
||||
RESTPostAPIGuildsResult,
|
||||
RESTPostAPIGuildTemplatesJSONBody,
|
||||
RESTPostAPIGuildTemplatesResult,
|
||||
RESTPostAPITemplateCreateGuildJSONBody,
|
||||
RESTPutAPIGuildBanJSONBody,
|
||||
RESTPutAPIGuildTemplateSyncResult,
|
||||
Snowflake,
|
||||
@@ -446,7 +449,7 @@ export class GuildsAPI {
|
||||
body,
|
||||
reason,
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIGuildPruneCountResult>;
|
||||
}) as Promise<RESTPostAPIGuildPruneResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,7 +509,9 @@ export class GuildsAPI {
|
||||
* @param options - The options for fetching the widget settings
|
||||
*/
|
||||
public async getWidgetSettings(guildId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
|
||||
return this.rest.get(Routes.guildWidgetSettings(guildId), { signal }) as Promise<RESTGetAPIGuildWidgetImageResult>;
|
||||
return this.rest.get(Routes.guildWidgetSettings(guildId), {
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIGuildWidgetSettingsResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1051,7 +1056,7 @@ export class GuildsAPI {
|
||||
reason,
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPatchAPIAutoModerationRuleJSONBody>;
|
||||
}) as Promise<RESTPatchAPIAutoModerationRuleResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1196,7 +1201,7 @@ export class GuildsAPI {
|
||||
*/
|
||||
public async createTemplate(
|
||||
templateCode: string,
|
||||
body: RESTPostAPITemplateCreateGuildJSONBody,
|
||||
body: RESTPostAPIGuildTemplatesJSONBody,
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
return this.rest.post(Routes.template(templateCode), { body, signal }) as Promise<RESTPostAPIGuildTemplatesResult>;
|
||||
|
||||
@@ -103,7 +103,7 @@ export class InteractionsAPI {
|
||||
body: APIInteractionResponseCallbackData & { files?: RawFile[] },
|
||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||
) {
|
||||
await this.webhooks.execute(applicationId, interactionToken, body, { signal });
|
||||
return this.webhooks.execute(applicationId, interactionToken, { ...body, wait: true }, { signal });
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,17 +4,17 @@ import { makeURLSearchParams, type RequestData, type RawFile, type REST } from '
|
||||
import {
|
||||
Routes,
|
||||
type RESTGetAPIWebhookWithTokenMessageQuery,
|
||||
type RESTGetAPIChannelMessageResult,
|
||||
type RESTGetAPIWebhookWithTokenMessageResult,
|
||||
type RESTGetAPIWebhookResult,
|
||||
type RESTPatchAPIWebhookJSONBody,
|
||||
type RESTPatchAPIWebhookResult,
|
||||
type RESTPatchAPIWebhookWithTokenMessageJSONBody,
|
||||
type RESTPatchAPIWebhookWithTokenMessageResult,
|
||||
type RESTPostAPIChannelWebhookJSONBody,
|
||||
type RESTPostAPIChannelWebhookResult,
|
||||
type RESTPostAPIWebhookWithTokenGitHubQuery,
|
||||
type RESTPostAPIWebhookWithTokenJSONBody,
|
||||
type RESTPostAPIWebhookWithTokenQuery,
|
||||
type RESTPostAPIWebhookWithTokenResult,
|
||||
type RESTPostAPIWebhookWithTokenSlackQuery,
|
||||
type RESTPostAPIWebhookWithTokenWaitResult,
|
||||
type Snowflake,
|
||||
@@ -53,7 +53,7 @@ export class WebhooksAPI {
|
||||
reason,
|
||||
body,
|
||||
signal,
|
||||
}) as Promise<RESTPostAPIWebhookWithTokenResult>;
|
||||
}) as Promise<RESTPostAPIChannelWebhookResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,7 +225,7 @@ export class WebhooksAPI {
|
||||
query: makeURLSearchParams(query),
|
||||
auth: false,
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIChannelMessageResult>;
|
||||
}) as Promise<RESTGetAPIWebhookWithTokenMessageResult>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user