Skip to content

Commit

Permalink
fix(permissions): only use admin role permission if role is set/confi…
Browse files Browse the repository at this point in the history
…gured
  • Loading branch information
Mirasaki committed Apr 23, 2024
1 parent b0cab49 commit 4383f9f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/permissions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ClientPermissionLevel } from '@rhidium/core';
import { guildSettingsFromCache } from './database';
import { PermissionFlagsBits } from 'discord.js';

export const permConfig: ClientPermissionLevel[] = [
{
Expand Down Expand Up @@ -31,6 +32,7 @@ export const permConfig: ClientPermissionLevel[] = [
hasLevel: async (_config, member) => {
const guildSettings = await guildSettingsFromCache(member.guild.id);
if (!guildSettings) return false;
if (!guildSettings.adminRoleId) return member.permissions.has(PermissionFlagsBits.Administrator);
return member.roles.cache.some(
(role) => guildSettings.adminRoleId === role.id,
);
Expand Down

0 comments on commit 4383f9f

Please sign in to comment.