Skip to content

Commit

Permalink
Merge pull request #32 from PretendoNetwork/head-mod-accept-applications
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbarrow authored Jul 27, 2024
2 parents b7b07c3 + aefd893 commit 90d6c30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/buttons/mod-application-accept.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@ async function modApplicationAcceptHandler(interaction) {
});

const adminRoleId = await database.getGuildSetting(interaction.guildId, 'admin_role_id');

if (!adminRoleId) {
throw new Error('No admin role ID set!');
}

const hasdAdminRole = interaction.member.roles.cache.get(adminRoleId);
const headModRoleId = await database.getGuildSetting(interaction.guildId, 'head_mod_role_id');
if (!headModRoleId) {
throw new Error('No head mod role ID set!');
}

const hasAdminRole = interaction.member.roles.cache.get(adminRoleId);
const hasHeadModRole = interaction.member.roles.cache.get(headModRoleId);

if (!hasdAdminRole) {
throw new Error('Only administrators have permission to accept/deny applications');
if (!(hasAdminRole || hasHeadModRole)) {
throw new Error('Only administrators and head mods have permission to accept/deny applications');
}

const { message } = interaction;
Expand Down
13 changes: 9 additions & 4 deletions src/modals/mod-application-deny.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ async function denyModApplicationHandler(interaction) {
});

const adminRoleId = await database.getGuildSetting(interaction.guildId, 'admin_role_id');

if (!adminRoleId) {
throw new Error('No admin role ID set!');
}

const hasdAdminRole = interaction.member.roles.cache.get(adminRoleId);
const headModRoleId = await database.getGuildSetting(interaction.guildId, 'head_mod_role_id');
if (!headModRoleId) {
throw new Error('No head mod role ID set!');
}

const hasAdminRole = interaction.member.roles.cache.get(adminRoleId);
const hasHeadModRole = interaction.member.roles.cache.get(headModRoleId);

if (!hasdAdminRole) {
throw new Error('Only administrators have permission to accept/deny applications');
if (!(hasAdminRole || hasHeadModRole)) {
throw new Error('Only administrators and head mods have permission to accept/deny applications');
}

const { message } = interaction;
Expand Down

0 comments on commit 90d6c30

Please sign in to comment.