Skip to content

Commit

Permalink
feat(WebhooksAPI): allow with token requests without bot auth (#9715)
Browse files Browse the repository at this point in the history
* Also move `get`'s `token` parameter to options.
  • Loading branch information
D4isDAVID authored Jul 16, 2023
1 parent 20268ac commit bc83cab
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions packages/core/src/api/webhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-with-token}
* @param id - The id of the webhook
* @param token - The token of the webhook
* @param options - The options for fetching the webhook
*/
public async get(id: Snowflake, token?: string, { signal }: Pick<RequestData, 'signal'> = {}) {
return this.rest.get(Routes.webhook(id, token), { signal }) as Promise<RESTGetAPIWebhookResult>;
public async get(
id: Snowflake,
{ token, signal }: Pick<RequestData, 'signal'> & { token?: string | undefined } = {},
) {
return this.rest.get(Routes.webhook(id, token), {
signal,
auth: !token,
}) as Promise<RESTGetAPIWebhookResult>;
}

/**
Expand All @@ -52,6 +57,7 @@ export class WebhooksAPI {
reason,
body,
signal,
auth: !token,
}) as Promise<RESTPatchAPIWebhookResult>;
}

Expand All @@ -67,7 +73,11 @@ export class WebhooksAPI {
id: Snowflake,
{ 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,
});
}

/**
Expand Down

0 comments on commit bc83cab

Please sign in to comment.