Add restricted channels bypass (for devs or other role)#162
Closed
otiskujawa wants to merge 3 commits intoGeoxor:mainfrom
Closed
Add restricted channels bypass (for devs or other role)#162otiskujawa wants to merge 3 commits intoGeoxor:mainfrom
otiskujawa wants to merge 3 commits intoGeoxor:mainfrom
Conversation
Contributor
|
I think it would be better if we store all Role ID's inside a class constant, so the If doesn't get too long, and it makes it easier to add more roles later export default class RestrictedChannel extends AbstractPipelineElement {
private readonly RESTRICTED_CHANNELS = [GEOXOR_GENERAL_CHANNEL_ID];
+ private readonly WHITELISTED_ROLES = [MOD_ROLE_ID, ADMIN_ROLE_ID, GEOXOR_DEV_ROLE_ID];
execute(payload: MessageCreatePayload): Awaitable<boolean> {
const message = payload.get("message");
// Do not allow Commands in RestrictedChannels
// Not Geoxor's guild or in a restricted channel -> Continue
if (!message.member || !this.RESTRICTED_CHANNELS.includes(message.channel.id)) {
return true;
}
// Check if user is a mod, admin or has admin perms if not, return
if (
- message.member.roles.cache.some((role) => role.id === MOD_ROLE_ID || role.id === ADMIN_ROLE_ID || role.id === RESTRICT_BYPASS_ROLE_ID) ||
+ message.member.roles.cache.some((role) => this.WHITELISTED_ROLES.includes(role.id)) ||
message.member.permissions.has("Administrator")
) {
return true;
}
return false;
}
} |
Owner
|
do i merge this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
i forgot to add import in #161