Files
discordeno/src/helpers/webhooks/edit_webhook.ts
ayntee 5f1b82a4e8 refactor: remove RequestManager and use runMethod() (#732)
* fix(rest/process_request): use DiscordHTTPResponseCodes

* refactor: remove RequestManager

* refactor: remove RequestManager and use runMethod()
2021-04-02 23:18:51 +04:00

24 lines
667 B
TypeScript

import { rest } from "../../rest/rest.ts";
import { endpoints } from "../../util/constants.ts";
import { requireBotChannelPermissions } from "../../util/permissions.ts";
/** Edit a webhook. Requires the `MANAGE_WEBHOOKS` permission. Returns the updated webhook object on success. */
export async function editWebhook(
channelId: string,
webhookId: string,
options: WebhookEditOptions,
) {
await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]);
const result = await rest.runMethod(
"patch",
endpoints.WEBHOOK_ID(webhookId),
{
...options,
channel_id: options.channelId,
},
);
return result as WebhookPayload;
}