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:
Jiralite
2024-12-05 09:09:43 +00:00
committed by GitHub
parent eceaa85ad4
commit abf4b6103c
4 changed files with 65 additions and 58 deletions

View File

@@ -18,6 +18,14 @@ import {
type Snowflake,
} from 'discord-api-types/v10';
export type CreateWebhookMessageOptions = RESTPostAPIWebhookWithTokenJSONBody &
RESTPostAPIWebhookWithTokenQuery & { files?: RawFile[] };
export type EditWebhookMessageOptions = RESTPatchAPIWebhookWithTokenMessageJSONBody & {
files?: RawFile[];
thread_id?: string;
};
export class WebhooksAPI {
public constructor(private readonly rest: REST) {}
@@ -92,7 +100,7 @@ export class WebhooksAPI {
public async execute(
id: Snowflake,
token: string,
body: RESTPostAPIWebhookWithTokenJSONBody & RESTPostAPIWebhookWithTokenQuery & { files?: RawFile[]; wait: true },
body: CreateWebhookMessageOptions & { wait: true },
options?: Pick<RequestData, 'signal'>,
): Promise<RESTPostAPIWebhookWithTokenWaitResult>;
@@ -108,7 +116,7 @@ export class WebhooksAPI {
public async execute(
id: Snowflake,
token: string,
body: RESTPostAPIWebhookWithTokenJSONBody & RESTPostAPIWebhookWithTokenQuery & { files?: RawFile[]; wait?: false },
body: CreateWebhookMessageOptions & { wait?: false },
options?: Pick<RequestData, 'signal'>,
): Promise<void>;
@@ -124,12 +132,7 @@ export class WebhooksAPI {
public async execute(
id: Snowflake,
token: string,
{
wait,
thread_id,
files,
...body
}: RESTPostAPIWebhookWithTokenJSONBody & RESTPostAPIWebhookWithTokenQuery & { files?: RawFile[] },
{ wait, thread_id, files, ...body }: CreateWebhookMessageOptions,
{ signal }: Pick<RequestData, 'signal'> = {},
) {
return this.rest.post(Routes.webhook(id, token), {
@@ -230,11 +233,7 @@ export class WebhooksAPI {
id: Snowflake,
token: string,
messageId: Snowflake,
{
thread_id,
files,
...body
}: RESTPatchAPIWebhookWithTokenMessageJSONBody & { files?: RawFile[]; thread_id?: string },
{ thread_id, files, ...body }: EditWebhookMessageOptions,
{ signal }: Pick<RequestData, 'signal'> = {},
) {
return this.rest.patch(Routes.webhookMessage(id, token, messageId), {