From 9f9a344eef31c6c898f117495a608777da2a18d3 Mon Sep 17 00:00:00 2001 From: ITOH Date: Sat, 22 May 2021 17:57:32 +0200 Subject: [PATCH 1/6] fix: getInvite return type --- src/helpers/invites/get_invite.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/invites/get_invite.ts b/src/helpers/invites/get_invite.ts index d6a58e4ec..dbe9c7062 100644 --- a/src/helpers/invites/get_invite.ts +++ b/src/helpers/invites/get_invite.ts @@ -1,10 +1,10 @@ import { rest } from "../../rest/rest.ts"; import { GetInvite } from "../../types/invites/get_invite.ts"; -import type { Invite } from "../../types/invites/invite.ts"; +import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { endpoints } from "../../util/constants.ts"; import { snakelize } 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, options?: GetInvite) { - return await rest.runMethod("get", endpoints.INVITE(inviteCode), snakelize(options ?? {})); + return await rest.runMethod("get", endpoints.INVITE(inviteCode), snakelize(options ?? {})); } From 97e37da29a5b3adfcd0affd8e07c045588c9d591 Mon Sep 17 00:00:00 2001 From: ITOH Date: Sat, 22 May 2021 17:57:56 +0200 Subject: [PATCH 2/6] fix: getInvites return type --- src/helpers/invites/get_invites.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/invites/get_invites.ts b/src/helpers/invites/get_invites.ts index a74e2bbec..59098bfbf 100644 --- a/src/helpers/invites/get_invites.ts +++ b/src/helpers/invites/get_invites.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import type { Invite } from "../../types/invites/invite.ts"; +import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotGuildPermissions } from "../../util/permissions.ts"; @@ -8,7 +8,7 @@ import { requireBotGuildPermissions } from "../../util/permissions.ts"; export async function getInvites(guildId: bigint) { await requireBotGuildPermissions(guildId, ["MANAGE_GUILD"]); - const result = await rest.runMethod("get", endpoints.GUILD_INVITES(guildId)); + const result = await rest.runMethod("get", endpoints.GUILD_INVITES(guildId)); return new Collection(result.map((invite) => [invite.code, invite])); } From 2850fdd13f2f4b4ebbc4b587c4696464be72ea5c Mon Sep 17 00:00:00 2001 From: ITOH Date: Sat, 22 May 2021 17:58:17 +0200 Subject: [PATCH 3/6] fix: getChannelInivtes return type --- src/helpers/invites/get_channel_invites.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/invites/get_channel_invites.ts b/src/helpers/invites/get_channel_invites.ts index db8b3834c..3877b6c7f 100644 --- a/src/helpers/invites/get_channel_invites.ts +++ b/src/helpers/invites/get_channel_invites.ts @@ -1,5 +1,5 @@ import { rest } from "../../rest/rest.ts"; -import type { Invite } from "../../types/invites/invite.ts"; +import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { Collection } from "../../util/collection.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; @@ -8,7 +8,7 @@ import { requireBotChannelPermissions } from "../../util/permissions.ts"; export async function getChannelInvites(channelId: bigint) { await requireBotChannelPermissions(channelId, ["MANAGE_CHANNELS"]); - const result = await rest.runMethod("get", endpoints.CHANNEL_INVITES(channelId)); + const result = await rest.runMethod("get", endpoints.CHANNEL_INVITES(channelId)); return new Collection(result.map((invite) => [invite.code, invite])); } From 5c6dd00a1e4221521b084c1563fd6c356213246e Mon Sep 17 00:00:00 2001 From: ITOH Date: Sat, 22 May 2021 18:01:04 +0200 Subject: [PATCH 4/6] fix: deleteInvite return type --- src/helpers/invites/delete_invite.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/invites/delete_invite.ts b/src/helpers/invites/delete_invite.ts index b9b18c8d7..fe033ddf6 100644 --- a/src/helpers/invites/delete_invite.ts +++ b/src/helpers/invites/delete_invite.ts @@ -1,6 +1,6 @@ import { cacheHandlers } from "../../cache.ts"; import { rest } from "../../rest/rest.ts"; -import type { Invite } from "../../types/invites/invite.ts"; +import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { endpoints } from "../../util/constants.ts"; import { botHasChannelPermissions, requireBotGuildPermissions } from "../../util/permissions.ts"; @@ -15,5 +15,5 @@ export async function deleteInvite(channelId: bigint, inviteCode: string) { } } - return await rest.runMethod("delete", endpoints.INVITE(inviteCode)); + return await rest.runMethod("delete", endpoints.INVITE(inviteCode)); } From b8f145f2d5be80d7244b46e2a2dc8e57700df3f0 Mon Sep 17 00:00:00 2001 From: ITOH Date: Sat, 22 May 2021 18:03:28 +0200 Subject: [PATCH 5/6] change: make createInivte options optional --- src/helpers/invites/create_invite.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/invites/create_invite.ts b/src/helpers/invites/create_invite.ts index 7711b05d2..36cb94232 100644 --- a/src/helpers/invites/create_invite.ts +++ b/src/helpers/invites/create_invite.ts @@ -6,7 +6,7 @@ import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; /** Creates a new invite for this channel. Requires CREATE_INSTANT_INVITE */ -export async function createInvite(channelId: bigint, options: CreateChannelInvite) { +export async function createInvite(channelId: bigint, options: CreateChannelInvite = {}) { await requireBotChannelPermissions(channelId, ["CREATE_INSTANT_INVITE"]); if (options.maxAge && (options.maxAge < 0 || options.maxAge > 604800)) { From 3f80e921cadee773e08a5d4f57e562700dcaa72d Mon Sep 17 00:00:00 2001 From: ITOH Date: Sat, 22 May 2021 18:05:21 +0200 Subject: [PATCH 6/6] fix: createInvite return type --- src/helpers/invites/create_invite.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/invites/create_invite.ts b/src/helpers/invites/create_invite.ts index 36cb94232..c3354a3fe 100644 --- a/src/helpers/invites/create_invite.ts +++ b/src/helpers/invites/create_invite.ts @@ -1,6 +1,6 @@ import { rest } from "../../rest/rest.ts"; import type { CreateChannelInvite } from "../../types/invites/create_channel_invite.ts"; -import type { Invite } from "../../types/invites/invite.ts"; +import type { InviteMetadata } from "../../types/invites/invite_metadata.ts"; import { Errors } from "../../types/discordeno/errors.ts"; import { endpoints } from "../../util/constants.ts"; import { requireBotChannelPermissions } from "../../util/permissions.ts"; @@ -16,5 +16,5 @@ export async function createInvite(channelId: bigint, options: CreateChannelInvi throw new Error(Errors.INVITE_MAX_USES_INVALID); } - return await rest.runMethod("post", endpoints.CHANNEL_INVITES(channelId), options); + return await rest.runMethod("post", endpoints.CHANNEL_INVITES(channelId), options); }