Files
discordeno/helpers/webhooks/getWebhookWithToken.ts
Skillz4Killz 3a5bdce32d feat: helpers support strings in args (#2478)
* fix: helpers support strings in args

* fix: fmt
2022-09-15 20:59:02 -05:00

25 lines
938 B
TypeScript

import type { Bot } from "../../bot.ts";
import { Webhook } from "../../transformers/webhook.ts";
import { DiscordWebhook } from "../../types/discord.ts";
import { BigString } from "../../types/shared.ts";
/**
* Gets a webhook using the webhook token, thereby bypassing the need for authentication + permissions.
*
* @param bot - The bot instance to use to make the request.
* @param webhookId - The ID of the webhook to get.
* @param token - The webhook token, used to get the webhook.
* @returns An instance of {@link Webhook}.
*
* @see {@link https://discord.com/developers/docs/resources/webhook#get-webhook-with-token}
*/
export async function getWebhookWithToken(bot: Bot, webhookId: BigString, token: string): Promise<Webhook> {
const result = await bot.rest.runMethod<DiscordWebhook>(
bot.rest,
"GET",
bot.constants.routes.WEBHOOK(webhookId, token),
);
return bot.transformers.webhook(bot, result);
}