Added comments to discord.ts#canEditGuild

This commit is contained in:
Mathias Wagner 2023-11-11 19:32:40 +01:00
parent 7bbe4803ec
commit 9cd9f23265
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

View File

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