fix: webhook typings

This commit is contained in:
Skillz4Killz
2021-04-12 18:12:59 +00:00
committed by GitHub
parent 8523a5ceea
commit 7e38960e9a
3 changed files with 9 additions and 3 deletions
@@ -1,5 +1,7 @@
import { rest } from "../../rest/rest.ts";
import { Webhook } from "../../types/webhooks/webhook.ts";
import { endpoints } from "../../util/constants.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
/** Edit a webhook. Returns the updated webhook object on success. */
export async function editWebhookWithToken(
@@ -13,5 +15,5 @@ export async function editWebhookWithToken(
options,
);
return result as WebhookPayload;
return snakeKeysToCamelCase(result) as Webhook;
}
+3 -1
View File
@@ -1,9 +1,11 @@
import { rest } from "../../rest/rest.ts";
import { Webhook } from "../../types/webhooks/webhook.ts";
import { endpoints } from "../../util/constants.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
/** Returns the new webhook object for the given id. */
export async function getWebhook(webhookId: string) {
const result = await rest.runMethod("get", endpoints.WEBHOOK_ID(webhookId));
return result as WebhookPayload;
return snakeKeysToCamelCase(result) as Webhook;
}
@@ -1,5 +1,7 @@
import { rest } from "../../rest/rest.ts";
import { Webhook } from "../../types/webhooks/webhook.ts";
import { endpoints } from "../../util/constants.ts";
import { snakeKeysToCamelCase } from "../../util/utils.ts";
/** Returns the new webhook object for the given id, this call does not require authentication and returns no user in the webhook object. */
export async function getWebhookWithToken(webhookId: string, token: string) {
@@ -8,5 +10,5 @@ export async function getWebhookWithToken(webhookId: string, token: string) {
endpoints.WEBHOOK(webhookId, token),
);
return result as WebhookPayload;
return snakeKeysToCamelCase(result) as Webhook;
}