diff --git a/src/helpers/invites/create_invite.ts b/src/helpers/invites/create_invite.ts index 09e13633d..0c7af679f 100644 --- a/src/helpers/invites/create_invite.ts +++ b/src/helpers/invites/create_invite.ts @@ -1,5 +1,6 @@ import { rest } from "../../rest/rest.ts"; import { CreateChannelInvite } from "../../types/invites/create_channel_invite.ts"; +import { Invite } from "../../types/mod.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; @@ -12,11 +13,9 @@ export async function createInvite( // TODO: add proper options validation - const result = await rest.runMethod( + return await rest.runMethod( "post", endpoints.CHANNEL_INVITES(channelId), options, ); - - return result; } diff --git a/src/helpers/invites/delete_invite.ts b/src/helpers/invites/delete_invite.ts index a0e9cead8..0891c89ed 100644 --- a/src/helpers/invites/delete_invite.ts +++ b/src/helpers/invites/delete_invite.ts @@ -1,13 +1,12 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import { DiscordInvite, Invite } from "../../types/invites/invite.ts"; +import { Invite } from "../../types/invites/invite.ts"; import { Errors } from "../../types/misc/errors.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasChannelPermissions, requireBotGuildPermissions, } from "../../util/permissions.ts"; -import { snakeKeysToCamelCase } from "../../util/utils.ts"; /** Deletes an invite for the given code. Requires `MANAGE_CHANNELS` or `MANAGE_GUILD` permission */ export async function deleteInvite(channelId: string, inviteCode: string) { @@ -23,10 +22,8 @@ export async function deleteInvite(channelId: string, inviteCode: string) { await requireBotGuildPermissions(channel!.guildId, ["MANAGE_GUILD"]); } - const result: DiscordInvite = await rest.runMethod( + return await rest.runMethod( "delete", endpoints.INVITE(inviteCode), ); - - return snakeKeysToCamelCase(result); } diff --git a/src/helpers/invites/get_channel_invites.ts b/src/helpers/invites/get_channel_invites.ts index f1a489693..4c9ce95c6 100644 --- a/src/helpers/invites/get_channel_invites.ts +++ b/src/helpers/invites/get_channel_invites.ts @@ -1,20 +1,19 @@ import { rest } from "../../rest/rest.ts"; -import { DiscordInvite, Invite } from "../../types/invites/invite.ts"; +import { Invite } from "../../types/invites/invite.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; -import { snakeKeysToCamelCase } from "../../util/utils.ts"; /** Gets the invites for this channel. Requires MANAGE_CHANNEL */ export async function getChannelInvites(channelId: string) { await requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]); - const result = (await rest.runMethod( + const result = await rest.runMethod( "get", endpoints.CHANNEL_INVITES(channelId), - )) as DiscordInvite[]; + ); return new Collection( - result.map((invite) => [invite.code, snakeKeysToCamelCase(invite)]), + result.map((invite) => [invite.code, invite]), ); } diff --git a/src/helpers/invites/get_invite.ts b/src/helpers/invites/get_invite.ts index 43f2cb35e..de91249fe 100644 --- a/src/helpers/invites/get_invite.ts +++ b/src/helpers/invites/get_invite.ts @@ -1,14 +1,11 @@ import { rest } from "../../rest/rest.ts"; -import { DiscordInvite, Invite } from "../../types/invites/invite.ts"; +import { Invite } from "../../types/invites/invite.ts"; import { endpoints } from "../../util/constants.ts"; -import { snakeKeysToCamelCase } from "../../util/utils.ts"; /** Returns an invite for the given code or throws an error if the invite doesn't exists. */ export async function getInvite(inviteCode: string) { - const result: DiscordInvite = await rest.runMethod( + return await rest.runMethod( "get", endpoints.INVITE(inviteCode), ); - - return snakeKeysToCamelCase(result); } diff --git a/src/helpers/invites/get_invites.ts b/src/helpers/invites/get_invites.ts index 778a243d6..c4a72e7d6 100644 --- a/src/helpers/invites/get_invites.ts +++ b/src/helpers/invites/get_invites.ts @@ -1,20 +1,19 @@ import { rest } from "../../rest/rest.ts"; -import { DiscordInvite, Invite } from "../../types/invites/invite.ts"; +import { Invite } from "../../types/invites/invite.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; -import { snakeKeysToCamelCase } from "../../util/utils.ts"; /** Get all the invites for this guild. Requires MANAGE_GUILD permission */ export async function getInvites(guildId: string) { await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); - const result = (await rest.runMethod( + const result = await rest.runMethod( "get", endpoints.GUILD_INVITES(guildId), - )) as DiscordInvite[]; + ); return new Collection( - result.map((invite) => [invite.code, snakeKeysToCamelCase(invite)]), + result.map((invite) => [invite.code, invite]), ); }