Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api): various fixes for overlooked stuff #9588

Merged
merged 7 commits into from
May 22, 2023
Merged
28 changes: 18 additions & 10 deletions packages/core/src/api/applicationCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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>;
}

/**
Expand All @@ -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>;
}

/**
Expand All @@ -194,7 +202,7 @@ export class ApplicationCommandsAPI {
) {
return this.rest.get(Routes.applicationGuildCommand(applicationId, guildId, commandId), {
signal,
}) as Promise<RESTGetAPIApplicationCommandResult>;
}) as Promise<RESTGetAPIApplicationGuildCommandResult>;
}

/**
Expand All @@ -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>;
}

/**
Expand Down Expand Up @@ -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>;
}

/**
Expand Down
15 changes: 10 additions & 5 deletions packages/core/src/api/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ import type {
RESTGetAPIGuildWelcomeScreenResult,
RESTGetAPIGuildWidgetImageResult,
RESTGetAPIGuildWidgetJSONResult,
RESTGetAPIGuildWidgetSettingsResult,
RESTGetAPITemplateResult,
RESTPatchAPIAutoModerationRuleJSONBody,
RESTPatchAPIAutoModerationRuleResult,
RESTPatchAPIGuildChannelPositionsJSONBody,
RESTPatchAPIGuildEmojiJSONBody,
RESTPatchAPIGuildEmojiResult,
Expand Down Expand Up @@ -78,15 +80,16 @@ import type {
RESTPostAPIGuildEmojiJSONBody,
RESTPostAPIGuildEmojiResult,
RESTPostAPIGuildPruneJSONBody,
RESTPostAPIGuildPruneResult,
RESTPostAPIGuildRoleJSONBody,
RESTPostAPIGuildRoleResult,
RESTPostAPIGuildScheduledEventJSONBody,
RESTPostAPIGuildScheduledEventResult,
RESTPostAPIGuildsJSONBody,
RESTPostAPIGuildsMFAResult,
RESTPostAPIGuildsResult,
RESTPostAPIGuildTemplatesJSONBody,
RESTPostAPIGuildTemplatesResult,
RESTPostAPITemplateCreateGuildJSONBody,
RESTPutAPIGuildBanJSONBody,
RESTPutAPIGuildTemplateSyncResult,
Snowflake,
Expand Down Expand Up @@ -446,7 +449,7 @@ export class GuildsAPI {
body,
reason,
signal,
}) as Promise<RESTGetAPIGuildPruneCountResult>;
}) as Promise<RESTPostAPIGuildPruneResult>;
}

/**
Expand Down Expand Up @@ -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>;
}

/**
Expand Down Expand Up @@ -1051,7 +1056,7 @@ export class GuildsAPI {
reason,
body,
signal,
}) as Promise<RESTPatchAPIAutoModerationRuleJSONBody>;
}) as Promise<RESTPatchAPIAutoModerationRuleResult>;
}

/**
Expand Down Expand Up @@ -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>;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/api/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Jiralite marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/api/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -53,7 +53,7 @@ export class WebhooksAPI {
reason,
body,
signal,
}) as Promise<RESTPostAPIWebhookWithTokenResult>;
}) as Promise<RESTPostAPIChannelWebhookResult>;
}

/**
Expand Down Expand Up @@ -225,7 +225,7 @@ export class WebhooksAPI {
query: makeURLSearchParams(query),
auth: false,
signal,
}) as Promise<RESTGetAPIChannelMessageResult>;
}) as Promise<RESTGetAPIWebhookWithTokenMessageResult>;
}

/**
Expand Down