-
Notifications
You must be signed in to change notification settings - Fork 25
Skill role refactor #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Skill role refactor #148
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8c32cdb
Refactor skill role stuff
michael-kenzel b98f6a6
delete commented code
michael-kenzel b92ea23
move skill_level and skill_levels
michael-kenzel fae936b
introduce SkillLevel enum to replace array mess
michael-kenzel 6c6b66d
switch from enum to const object
michael-kenzel 846f3c4
Add some infrastructure for formerly banned user actions
jeremy-rifkin d014833
Merge branch 'main' into michael-kenzel-skill-role-refactor
jeremy-rifkin 7e0d5aa
Use lowercase names for skill levels, setup a migration to a new inde…
jeremy-rifkin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import * as Discord from "discord.js"; | ||
| import { unwrap } from "../../../utils/misc.js"; | ||
| import { M } from "../../../utils/debugging-and-logging.js"; | ||
| import { BotComponent } from "../../../bot-component.js"; | ||
| import { CommandSetBuilder } from "../../../command-abstractions/command-set-builder.js"; | ||
| import SkillRoles, { SkillLevel } from "./skill-roles.js"; | ||
|
|
||
| export default class TheEstablishment extends BotComponent { | ||
| private skill_roles!: SkillRoles; | ||
|
|
||
| override async setup(commands: CommandSetBuilder) { | ||
| this.skill_roles = unwrap(this.wheatley.components.get("SkillRoles")) as SkillRoles; | ||
| this.wheatley.is_established_member = this.is_established_member.bind(this); | ||
|
jeremy-rifkin marked this conversation as resolved.
|
||
| } | ||
|
|
||
| private async is_established_member( | ||
| options: Discord.GuildMember | Discord.User | Discord.UserResolvable | Discord.FetchMemberOptions, | ||
| ) { | ||
| const member = await this.wheatley.try_fetch_guild_member(options); | ||
| if (!member) { | ||
| return false; | ||
| } | ||
| return ( | ||
| this.skill_roles.find_highest_skill_level(member) > SkillLevel.beginner || | ||
| member.premiumSince != null || | ||
| member.permissions.has(Discord.PermissionFlagsBits.MuteMembers) || | ||
| member.permissions.has(Discord.PermissionFlagsBits.ModerateMembers) | ||
| ); | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a schema so changing it like this isn't great. I'll give a think about how to do it better.