Skip to content

Commit

Permalink
Add bot admin permission
Browse files Browse the repository at this point in the history
  • Loading branch information
chessebuilderman committed Aug 11, 2024
1 parent 7bab596 commit f8e3099
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/common/managers/custom_interactions_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export enum CustomInteractionAccessLevel {
Admins = 5,
TeamLeaders = 6,
CompanyManagement = 7,
BotAdmin = 8
}

//------------------------------------------------------------//
Expand Down
7 changes: 7 additions & 0 deletions src/common/permissions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ if (guild_team_leaders_role_id.length < 1) throw new Error('Environment variable
const guild_company_management_role_id = `${process.env.BOT_COMPANY_MANAGEMENT_ROLE_ID ?? ''}`;
if (guild_company_management_role_id.length < 1) throw new Error('Environment variable: BOT_COMPANY_MANAGEMENT_ROLE_ID; was not set correctly!');

const guild_bot_admin_role_id = `${process.env.BOT_BOT_ADMIN_ROLE_ID ?? ''}`;
if (guild_company_management_role_id.length < 1) throw new Error('Environment variable: BOT_BOT_ADMIN_ROLE_ID; was not set correctly!');

//------------------------------------------------------------//

/**
Expand Down Expand Up @@ -70,5 +73,9 @@ export async function fetchHighestAccessLevelForUser(
access_levels_for_user.push(CustomInteractionAccessLevel.CompanyManagement);
}

if (bot_guild_member_roles_cache.has(guild_bot_admin_role_id)) {
access_levels_for_user.push(CustomInteractionAccessLevel.BotAdmin);
}

return Math.max(...access_levels_for_user); // the highest access level for the user
}

0 comments on commit f8e3099

Please sign in to comment.