Skip to content
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

Add select menu-based role management #20

Open
wants to merge 3 commits into
base: development
Choose a base branch
from

Conversation

Fox-Islam
Copy link
Collaborator

@Fox-Islam Fox-Islam commented Mar 11, 2021

Based off this discussion in #server-suggestions which concerns adding channels hidden behind roles and a method through which a person may self-assign those roles

This feature will allow any moderator to create posts (possibly in the welcome channel) which can be used to auto-assign roles based on which options a user selects

Example usage:

Making a post like this:

!role message
📖: 57438598437 - For people who want to view the reading channel
✍🏾: 5439857439 - For people who want to view the writing channel
👂: 5483795438 - For people who want to view the listening channel

Would result in the bot creating a message with a select menu using the provided role ids, emojis and descriptions
Any time a user selects an option they are assigned to the corresponding role by the bot
Any deselected roles in the list will unnassign them from those roles

Interface

The usage rules currently:

  • The message must start with "!role message"
  • The reaction must be part of the standard set (no custom server emojis)
  • The sequence to form a role/reaction pair is {Emoji}{colon}{Role id}
  • Any line that contains the sequence is picked up and parsed
    • The line may include an optional description after that sequence which will be used in the select menu
    • Additional lines may be included that don't contain the sequence (these are not parsed)

Notable additions in this commit

Dev dependencies added to package.json:

  • discord-buttons
    • provides helpful abstractions for creating select menus

New events added to index.js:

  • "clickMenu"
    • Fires whenever a user closes the select menu with changes
      • Used to trigger role assignation

@Fox-Islam Fox-Islam added the conflicts This branch has conflicts with the base branch and must be updated before it can be merged label Jun 28, 2021
Not a huge issue, just annoying having it show up and clogging up
the terminal
Also fixed a bug where if the bot doesn't have access to a channel
it would bubble up an error, made it avoid that case instead
Based off this discussion in #server-suggestions:
https://discord.com/channels/782201995011817493/793224619012128779/819308969460891648
Which concerns adding channels hidden behind roles and a method
through which to assign those roles

This feature will allow any moderator to create a post (possibly
in the welcome channel) which can be used to auto-assign roles
based on which reactions a user clicks

Example usage:
Making a post like this:
```
!role message
📖: @ReadingRole - For people who want to view the reading channel
✍🏾: @WritingRole - For people who want to view the writing channel
👂: @ListeningRole - For people who want to view the listening channel
```
Would result in the bot auto-adding those 📖, ✍🏾 and 👂 reactions to
the message.
Any time a user clicks one of the reactions they are assigned to
the corresponding role by the bot.
They may also remove their reaction to be unnassigned from that role

The usage rules currently:
- The message must start with "!role message"
- The reaction must be part of the standard set (no custom server
emojis)
- The sequence to form a role/reaction pair is:
{Emoji}{colon}{Role mention}
- Any line that contains the sequence is picked up and parsed
  - The line may include additional details after that sequence
  - Additional lines may be included that don't contain the
sequence (these are ignored)
  - The message can be edited after creation to have none of these
details and will still function as a role assignation message

Tables added to the database:
- RoleMessage
  - messageId
  - channelId
  - roleReactions (Array of objects:)
    - reactionName (emoji character code)
    - roleId (corresponding role for emoji)

Dev dependencies added to package.json:
- @babel/plugin-proposal-unicode-property-regex
  - Required to use Unicode property regexes
    - Allows us to use \p{Emoji} as a pattern to match any emoji

New events added to index.js:
- messageDelete
  - Fires whenever a message is deleted
    - Used to trigger the deletion of a role message from the database
@Fox-Islam Fox-Islam force-pushed the feature/emoji-role-management branch from 8df80cb to f167d33 Compare July 14, 2021 14:38
@Fox-Islam Fox-Islam removed the conflicts This branch has conflicts with the base branch and must be updated before it can be merged label Jul 14, 2021
@Fox-Islam Fox-Islam changed the title Add emoji-based role management Add select menu-based role management Jul 14, 2021
@Fox-Islam Fox-Islam force-pushed the feature/emoji-role-management branch from 0416069 to 9373c8c Compare July 15, 2021 13:02
src/scripts/users/role-manager.js Outdated Show resolved Hide resolved
src/scripts/users/role-manager.js Outdated Show resolved Hide resolved
src/scripts/users/role-manager.js Outdated Show resolved Hide resolved
src/scripts/users/role-manager.js Show resolved Hide resolved
src/scripts/users/role-manager.js Show resolved Hide resolved
src/scripts/users/role-manager.js Show resolved Hide resolved
src/scripts/users/role-manager.js Show resolved Hide resolved
src/scripts/users/role-manager.js Outdated Show resolved Hide resolved
src/scripts/utilities.js Outdated Show resolved Hide resolved
src/scripts/utilities.js Outdated Show resolved Hide resolved
Based off this discussion in #server-suggestions:
https://discord.com/channels/782201995011817493/793224619012128779/819308969460891648
Which concerns adding channels hidden behind roles and a method
through which to assign those roles

This feature will allow any moderator to create posts (possibly
in the welcome channel) which can be used to auto-assign roles
based on which options a user selects

Example usage:
Making a post like this:
```
!role message
📖: 57438598437 - For people who want to view the reading channel
✍🏾: 5439857439 - For people who want to view the writing channel
👂: 5483795438 - For people who want to view the listening channel
```
Would result in the bot creating a message with a select menu using
the provided role ids, emojis and descriptions
Any time a user selects an option they are assigned to the corresponding
role by the bot
Any deselected roles in the list will unnassign them from those roles

The usage rules currently:
- The message must start with "!role message"
- The reaction must be part of the standard set (no custom server
emojis)
- The sequence to form a role/reaction pair is:
{Emoji}{colon}{Role id}
- Any line that contains the sequence is picked up and parsed
  - The line may include an optional description after that sequence
which will be used in the select menu
  - Additional lines may be included that don't contain the
sequence (these are not parsed)

New events added to index.js:
- clickMenu
  - Fires whenever a user closes the select menu with changes
    - Used to trigger role assignation
@Fox-Islam Fox-Islam force-pushed the feature/emoji-role-management branch from 9373c8c to 8b0ba03 Compare July 15, 2021 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants