From 9cd9f23265d9c6928b901eddc25405bb851a5f57 Mon Sep 17 00:00:00 2001 From: Mathias Wagner Date: Sat, 11 Nov 2023 19:32:40 +0100 Subject: [PATCH] Added comments to discord.ts#canEditGuild --- controller/discord.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/controller/discord.ts b/controller/discord.ts index 0811e2a..4ed9eb4 100644 --- a/controller/discord.ts +++ b/controller/discord.ts @@ -60,6 +60,13 @@ export const getGuilds = async (refreshDate: Date, refreshToken: string, accessT return await oauth.getUserGuilds(await updateToken(refreshDate, refreshToken, accessToken)); } +/** + * Checks if the user is the owner of the guild or has the manage server permission + * @param refreshDate The date of when to renew the provided access token + * @param refreshToken The token to refresh the access token + * @param accessToken The token to access the discord api + * @param guildId The id of the guild + */ export const canEditGuild = async (refreshDate: Date, refreshToken: string, accessToken: string, guildId: string) => { const guilds = await getGuilds(refreshDate, refreshToken, accessToken); return guilds.some(guild => guild.id === guildId && (guild.owner || (guild.permissions && (guild.permissions & 0x8))));