From 7e38960e9abd3381d5aeb835f4e2559172556269 Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Mon, 12 Apr 2021 18:12:59 +0000 Subject: [PATCH] fix: webhook typings --- src/helpers/webhooks/edit_webhook_with_token.ts | 4 +++- src/helpers/webhooks/get_webhook.ts | 4 +++- src/helpers/webhooks/get_webhook_with_token.ts | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/helpers/webhooks/edit_webhook_with_token.ts b/src/helpers/webhooks/edit_webhook_with_token.ts index 2088b740a..6a1e7e877 100644 --- a/src/helpers/webhooks/edit_webhook_with_token.ts +++ b/src/helpers/webhooks/edit_webhook_with_token.ts @@ -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; } diff --git a/src/helpers/webhooks/get_webhook.ts b/src/helpers/webhooks/get_webhook.ts index 694afdd68..8f57f844f 100644 --- a/src/helpers/webhooks/get_webhook.ts +++ b/src/helpers/webhooks/get_webhook.ts @@ -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; } diff --git a/src/helpers/webhooks/get_webhook_with_token.ts b/src/helpers/webhooks/get_webhook_with_token.ts index c59ad4978..5018628ee 100644 --- a/src/helpers/webhooks/get_webhook_with_token.ts +++ b/src/helpers/webhooks/get_webhook_with_token.ts @@ -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; }