mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +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,
|
Routes,
|
||||||
type RESTGetAPIApplicationCommandPermissionsResult,
|
type RESTGetAPIApplicationCommandPermissionsResult,
|
||||||
type RESTGetAPIApplicationCommandResult,
|
type RESTGetAPIApplicationCommandResult,
|
||||||
|
type RESTGetAPIApplicationCommandsQuery,
|
||||||
type RESTGetAPIApplicationCommandsResult,
|
type RESTGetAPIApplicationCommandsResult,
|
||||||
|
type RESTGetAPIApplicationGuildCommandResult,
|
||||||
|
type RESTGetAPIApplicationGuildCommandsQuery,
|
||||||
|
type RESTGetAPIApplicationGuildCommandsResult,
|
||||||
type RESTGetAPIGuildApplicationCommandsPermissionsResult,
|
type RESTGetAPIGuildApplicationCommandsPermissionsResult,
|
||||||
type RESTPatchAPIApplicationCommandJSONBody,
|
type RESTPatchAPIApplicationCommandJSONBody,
|
||||||
type RESTPatchAPIApplicationCommandResult,
|
type RESTPatchAPIApplicationCommandResult,
|
||||||
|
type RESTPatchAPIApplicationGuildCommandJSONBody,
|
||||||
|
type RESTPatchAPIApplicationGuildCommandResult,
|
||||||
type RESTPostAPIApplicationCommandsJSONBody,
|
type RESTPostAPIApplicationCommandsJSONBody,
|
||||||
type RESTPostAPIApplicationCommandsResult,
|
type RESTPostAPIApplicationCommandsResult,
|
||||||
|
type RESTPostAPIApplicationGuildCommandsJSONBody,
|
||||||
|
type RESTPostAPIApplicationGuildCommandsResult,
|
||||||
type RESTPutAPIApplicationCommandPermissionsJSONBody,
|
type RESTPutAPIApplicationCommandPermissionsJSONBody,
|
||||||
type RESTPutAPIApplicationCommandPermissionsResult,
|
type RESTPutAPIApplicationCommandPermissionsResult,
|
||||||
type RESTPutAPIApplicationCommandsJSONBody,
|
type RESTPutAPIApplicationCommandsJSONBody,
|
||||||
type RESTGetAPIApplicationCommandsQuery,
|
|
||||||
type RESTPutAPIApplicationCommandsResult,
|
type RESTPutAPIApplicationCommandsResult,
|
||||||
type RESTGetAPIApplicationGuildCommandsQuery,
|
type RESTPutAPIApplicationGuildCommandsJSONBody,
|
||||||
|
type RESTPutAPIApplicationGuildCommandsResult,
|
||||||
type Snowflake,
|
type Snowflake,
|
||||||
} from 'discord-api-types/v10';
|
} from 'discord-api-types/v10';
|
||||||
|
|
||||||
@@ -153,7 +161,7 @@ export class ApplicationCommandsAPI {
|
|||||||
return this.rest.get(Routes.applicationGuildCommands(applicationId, guildId), {
|
return this.rest.get(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||||
query: makeURLSearchParams(query),
|
query: makeURLSearchParams(query),
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTGetAPIApplicationCommandsResult>;
|
}) as Promise<RESTGetAPIApplicationGuildCommandsResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -168,13 +176,13 @@ export class ApplicationCommandsAPI {
|
|||||||
public async createGuildCommand(
|
public async createGuildCommand(
|
||||||
applicationId: Snowflake,
|
applicationId: Snowflake,
|
||||||
guildId: Snowflake,
|
guildId: Snowflake,
|
||||||
body: RESTPostAPIApplicationCommandsJSONBody,
|
body: RESTPostAPIApplicationGuildCommandsJSONBody,
|
||||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||||
) {
|
) {
|
||||||
return this.rest.post(Routes.applicationGuildCommands(applicationId, guildId), {
|
return this.rest.post(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||||
body,
|
body,
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTPostAPIApplicationCommandsResult>;
|
}) as Promise<RESTPostAPIApplicationGuildCommandsResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -194,7 +202,7 @@ export class ApplicationCommandsAPI {
|
|||||||
) {
|
) {
|
||||||
return this.rest.get(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
return this.rest.get(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTGetAPIApplicationCommandResult>;
|
}) as Promise<RESTGetAPIApplicationGuildCommandResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -211,13 +219,13 @@ export class ApplicationCommandsAPI {
|
|||||||
applicationId: Snowflake,
|
applicationId: Snowflake,
|
||||||
guildId: Snowflake,
|
guildId: Snowflake,
|
||||||
commandId: Snowflake,
|
commandId: Snowflake,
|
||||||
body: RESTPatchAPIApplicationCommandJSONBody,
|
body: RESTPatchAPIApplicationGuildCommandJSONBody,
|
||||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||||
) {
|
) {
|
||||||
return this.rest.patch(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
return this.rest.patch(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
|
||||||
body,
|
body,
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTPatchAPIApplicationCommandResult>;
|
}) as Promise<RESTPatchAPIApplicationGuildCommandResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -250,13 +258,13 @@ export class ApplicationCommandsAPI {
|
|||||||
public async bulkOverwriteGuildCommands(
|
public async bulkOverwriteGuildCommands(
|
||||||
applicationId: Snowflake,
|
applicationId: Snowflake,
|
||||||
guildId: Snowflake,
|
guildId: Snowflake,
|
||||||
body: RESTPutAPIApplicationCommandsJSONBody,
|
body: RESTPutAPIApplicationGuildCommandsJSONBody,
|
||||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||||
) {
|
) {
|
||||||
return this.rest.put(Routes.applicationGuildCommands(applicationId, guildId), {
|
return this.rest.put(Routes.applicationGuildCommands(applicationId, guildId), {
|
||||||
body,
|
body,
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTPutAPIApplicationCommandsResult>;
|
}) as Promise<RESTPutAPIApplicationGuildCommandsResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -47,8 +47,10 @@ import type {
|
|||||||
RESTGetAPIGuildWelcomeScreenResult,
|
RESTGetAPIGuildWelcomeScreenResult,
|
||||||
RESTGetAPIGuildWidgetImageResult,
|
RESTGetAPIGuildWidgetImageResult,
|
||||||
RESTGetAPIGuildWidgetJSONResult,
|
RESTGetAPIGuildWidgetJSONResult,
|
||||||
|
RESTGetAPIGuildWidgetSettingsResult,
|
||||||
RESTGetAPITemplateResult,
|
RESTGetAPITemplateResult,
|
||||||
RESTPatchAPIAutoModerationRuleJSONBody,
|
RESTPatchAPIAutoModerationRuleJSONBody,
|
||||||
|
RESTPatchAPIAutoModerationRuleResult,
|
||||||
RESTPatchAPIGuildChannelPositionsJSONBody,
|
RESTPatchAPIGuildChannelPositionsJSONBody,
|
||||||
RESTPatchAPIGuildEmojiJSONBody,
|
RESTPatchAPIGuildEmojiJSONBody,
|
||||||
RESTPatchAPIGuildEmojiResult,
|
RESTPatchAPIGuildEmojiResult,
|
||||||
@@ -78,6 +80,7 @@ import type {
|
|||||||
RESTPostAPIGuildEmojiJSONBody,
|
RESTPostAPIGuildEmojiJSONBody,
|
||||||
RESTPostAPIGuildEmojiResult,
|
RESTPostAPIGuildEmojiResult,
|
||||||
RESTPostAPIGuildPruneJSONBody,
|
RESTPostAPIGuildPruneJSONBody,
|
||||||
|
RESTPostAPIGuildPruneResult,
|
||||||
RESTPostAPIGuildRoleJSONBody,
|
RESTPostAPIGuildRoleJSONBody,
|
||||||
RESTPostAPIGuildRoleResult,
|
RESTPostAPIGuildRoleResult,
|
||||||
RESTPostAPIGuildScheduledEventJSONBody,
|
RESTPostAPIGuildScheduledEventJSONBody,
|
||||||
@@ -85,8 +88,8 @@ import type {
|
|||||||
RESTPostAPIGuildsJSONBody,
|
RESTPostAPIGuildsJSONBody,
|
||||||
RESTPostAPIGuildsMFAResult,
|
RESTPostAPIGuildsMFAResult,
|
||||||
RESTPostAPIGuildsResult,
|
RESTPostAPIGuildsResult,
|
||||||
|
RESTPostAPIGuildTemplatesJSONBody,
|
||||||
RESTPostAPIGuildTemplatesResult,
|
RESTPostAPIGuildTemplatesResult,
|
||||||
RESTPostAPITemplateCreateGuildJSONBody,
|
|
||||||
RESTPutAPIGuildBanJSONBody,
|
RESTPutAPIGuildBanJSONBody,
|
||||||
RESTPutAPIGuildTemplateSyncResult,
|
RESTPutAPIGuildTemplateSyncResult,
|
||||||
Snowflake,
|
Snowflake,
|
||||||
@@ -446,7 +449,7 @@ export class GuildsAPI {
|
|||||||
body,
|
body,
|
||||||
reason,
|
reason,
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTGetAPIGuildPruneCountResult>;
|
}) as Promise<RESTPostAPIGuildPruneResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -506,7 +509,9 @@ export class GuildsAPI {
|
|||||||
* @param options - The options for fetching the widget settings
|
* @param options - The options for fetching the widget settings
|
||||||
*/
|
*/
|
||||||
public async getWidgetSettings(guildId: Snowflake, { signal }: Pick<RequestData, 'signal'> = {}) {
|
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,
|
reason,
|
||||||
body,
|
body,
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTPatchAPIAutoModerationRuleJSONBody>;
|
}) as Promise<RESTPatchAPIAutoModerationRuleResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1196,7 +1201,7 @@ export class GuildsAPI {
|
|||||||
*/
|
*/
|
||||||
public async createTemplate(
|
public async createTemplate(
|
||||||
templateCode: string,
|
templateCode: string,
|
||||||
body: RESTPostAPITemplateCreateGuildJSONBody,
|
body: RESTPostAPIGuildTemplatesJSONBody,
|
||||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
{ signal }: Pick<RequestData, 'signal'> = {},
|
||||||
) {
|
) {
|
||||||
return this.rest.post(Routes.template(templateCode), { body, signal }) as Promise<RESTPostAPIGuildTemplatesResult>;
|
return this.rest.post(Routes.template(templateCode), { body, signal }) as Promise<RESTPostAPIGuildTemplatesResult>;
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export class InteractionsAPI {
|
|||||||
body: APIInteractionResponseCallbackData & { files?: RawFile[] },
|
body: APIInteractionResponseCallbackData & { files?: RawFile[] },
|
||||||
{ signal }: Pick<RequestData, 'signal'> = {},
|
{ 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 {
|
import {
|
||||||
Routes,
|
Routes,
|
||||||
type RESTGetAPIWebhookWithTokenMessageQuery,
|
type RESTGetAPIWebhookWithTokenMessageQuery,
|
||||||
type RESTGetAPIChannelMessageResult,
|
type RESTGetAPIWebhookWithTokenMessageResult,
|
||||||
type RESTGetAPIWebhookResult,
|
type RESTGetAPIWebhookResult,
|
||||||
type RESTPatchAPIWebhookJSONBody,
|
type RESTPatchAPIWebhookJSONBody,
|
||||||
type RESTPatchAPIWebhookResult,
|
type RESTPatchAPIWebhookResult,
|
||||||
type RESTPatchAPIWebhookWithTokenMessageJSONBody,
|
type RESTPatchAPIWebhookWithTokenMessageJSONBody,
|
||||||
type RESTPatchAPIWebhookWithTokenMessageResult,
|
type RESTPatchAPIWebhookWithTokenMessageResult,
|
||||||
type RESTPostAPIChannelWebhookJSONBody,
|
type RESTPostAPIChannelWebhookJSONBody,
|
||||||
|
type RESTPostAPIChannelWebhookResult,
|
||||||
type RESTPostAPIWebhookWithTokenGitHubQuery,
|
type RESTPostAPIWebhookWithTokenGitHubQuery,
|
||||||
type RESTPostAPIWebhookWithTokenJSONBody,
|
type RESTPostAPIWebhookWithTokenJSONBody,
|
||||||
type RESTPostAPIWebhookWithTokenQuery,
|
type RESTPostAPIWebhookWithTokenQuery,
|
||||||
type RESTPostAPIWebhookWithTokenResult,
|
|
||||||
type RESTPostAPIWebhookWithTokenSlackQuery,
|
type RESTPostAPIWebhookWithTokenSlackQuery,
|
||||||
type RESTPostAPIWebhookWithTokenWaitResult,
|
type RESTPostAPIWebhookWithTokenWaitResult,
|
||||||
type Snowflake,
|
type Snowflake,
|
||||||
@@ -53,7 +53,7 @@ export class WebhooksAPI {
|
|||||||
reason,
|
reason,
|
||||||
body,
|
body,
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTPostAPIWebhookWithTokenResult>;
|
}) as Promise<RESTPostAPIChannelWebhookResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -225,7 +225,7 @@ export class WebhooksAPI {
|
|||||||
query: makeURLSearchParams(query),
|
query: makeURLSearchParams(query),
|
||||||
auth: false,
|
auth: false,
|
||||||
signal,
|
signal,
|
||||||
}) as Promise<RESTGetAPIChannelMessageResult>;
|
}) as Promise<RESTGetAPIWebhookWithTokenMessageResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user