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))));