mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 18:43:31 +01:00
feat(WebhooksAPI): allow with token requests without bot auth (#9715)
* Also move `get`'s `token` parameter to options.
This commit is contained in:
@@ -27,11 +27,16 @@ export class WebhooksAPI {
|
|||||||
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook}
|
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook}
|
||||||
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook-with-token}
|
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook-with-token}
|
||||||
* @param id - The id of the webhook
|
* @param id - The id of the webhook
|
||||||
* @param token - The token of the webhook
|
|
||||||
* @param options - The options for fetching the webhook
|
* @param options - The options for fetching the webhook
|
||||||
*/
|
*/
|
||||||
public async get(id: Snowflake, token?: string, { signal }: Pick<RequestData, 'signal'> = {}) {
|
public async get(
|
||||||
return this.rest.get(Routes.webhook(id, token), { signal }) as Promise<RESTGetAPIWebhookResult>;
|
id: Snowflake,
|
||||||
|
{ token, signal }: Pick<RequestData, 'signal'> & { token?: string | undefined } = {},
|
||||||
|
) {
|
||||||
|
return this.rest.get(Routes.webhook(id, token), {
|
||||||
|
signal,
|
||||||
|
auth: !token,
|
||||||
|
}) as Promise<RESTGetAPIWebhookResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,6 +57,7 @@ export class WebhooksAPI {
|
|||||||
reason,
|
reason,
|
||||||
body,
|
body,
|
||||||
signal,
|
signal,
|
||||||
|
auth: !token,
|
||||||
}) as Promise<RESTPatchAPIWebhookResult>;
|
}) as Promise<RESTPatchAPIWebhookResult>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,7 +73,11 @@ export class WebhooksAPI {
|
|||||||
id: Snowflake,
|
id: Snowflake,
|
||||||
{ token, reason, signal }: Pick<RequestData, 'reason' | 'signal'> & { token?: string | undefined } = {},
|
{ token, reason, signal }: Pick<RequestData, 'reason' | 'signal'> & { token?: string | undefined } = {},
|
||||||
) {
|
) {
|
||||||
await this.rest.delete(Routes.webhook(id, token), { reason, signal });
|
await this.rest.delete(Routes.webhook(id, token), {
|
||||||
|
reason,
|
||||||
|
signal,
|
||||||
|
auth: !token,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user