mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23: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:
@@ -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), {
|
||||
|
||||
Reference in New Issue
Block a user