From 0b23a308efa4d2ebf99410aba8ef66292657e9f2 Mon Sep 17 00:00:00 2001 From: ayntee Date: Mon, 12 Apr 2021 22:24:20 +0400 Subject: [PATCH] Fix some moar --- src/helpers/members/get_member.ts | 9 ++++++--- src/helpers/webhooks/create_webhook.ts | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/helpers/members/get_member.ts b/src/helpers/members/get_member.ts index 406337aa8..240a386a4 100644 --- a/src/helpers/members/get_member.ts +++ b/src/helpers/members/get_member.ts @@ -1,7 +1,10 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; import { structures } from "../../structures/mod.ts"; -import { DiscordGuildMember } from "../../types/guilds/guild_member.ts"; +import { + DiscordGuildMember, + DiscordGuildMemberWithUser, +} from "../../types/guilds/guild_member.ts"; import { endpoints } from "../../util/constants.ts"; /** Returns a guild member object for the specified user. @@ -16,10 +19,10 @@ export async function getMember( const guild = await cacheHandlers.get("guilds", guildId); if (!guild && !options?.force) return; - const data = (await rest.runMethod( + const data: DiscordGuildMemberWithUser = (await rest.runMethod( "get", endpoints.GUILD_MEMBER(guildId, id), - )) as DiscordGuildMember; + )); const discordenoMember = await structures.createDiscordenoMember( data, diff --git a/src/helpers/webhooks/create_webhook.ts b/src/helpers/webhooks/create_webhook.ts index bd771596f..c8173d433 100644 --- a/src/helpers/webhooks/create_webhook.ts +++ b/src/helpers/webhooks/create_webhook.ts @@ -1,8 +1,11 @@ import { rest } from "../../rest/rest.ts"; import { Errors } from "../../types/misc/errors.ts"; +import { CreateWebhook } from "../../types/webhooks/create_webhook.ts"; +import { Webhook } from "../../types/webhooks/webhook.ts"; +import { DiscordWebhook } from "../../types/webhooks/webhook.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; -import { urlToBase64 } from "../../util/utils.ts"; +import { snakeKeysToCamelCase, urlToBase64 } from "../../util/utils.ts"; /** * Create a new webhook. Requires the MANAGE_WEBHOOKS permission. Returns a webhook object on success. Webhook names follow our naming restrictions that can be found in our Usernames and Nicknames documentation, with the following additional stipulations: @@ -11,7 +14,7 @@ import { urlToBase64 } from "../../util/utils.ts"; */ export async function createWebhook( channelId: string, - options: WebhookCreateOptions, + options: CreateWebhook, ) { await requireBotChannelPermissions(channelId, ["MANAGE_WEBHOOKS"]); @@ -25,7 +28,7 @@ export async function createWebhook( throw new Error(Errors.INVALID_WEBHOOK_NAME); } - const result = await rest.runMethod( + const result: DiscordWebhook = await rest.runMethod( "post", endpoints.CHANNEL_WEBHOOKS(channelId), { @@ -34,5 +37,5 @@ export async function createWebhook( }, ); - return result as WebhookPayload; + return snakeKeysToCamelCase(result); }