question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Self-assigned roles

See original GitHub issue

This recommendation comes from discussion in the C# server and is something I designed in a custom bot of my own. This issue is being opened for discussion, particularly for generalization, since the current system was built strictly with my guild in mind. As such, the description below will cover how it’s set up with my bot.

This system allows for specified roles to be opted-into by the user. This can be used purely for cosmetics or for opting-in to notifications or the ability to read or write to particular channels- essentially whatever can be done by assigning a role to a user.

On the user’s end, they need only worry about three commands: !iam, !iamnot, and !roles. The !iam and !iamnot commands accept a list of roles (with params) as an argument. Both commands operate in exactly the same manner up until the last operation:

  1. Iterate through each of the requested roles and cast them to an AssignableRole. Should casting fail, the role is assumed to not be assignable.
  2. Check the AssignmentMethod property - an enum which allows you to temporarily disable certain roles.
  3. If assigning, check for prerequisites on the AssignableRole - should those exist and they are satisfied, assign the role. If removing, skip the prerequisite check and just remove the role.

Prerequisite types available for roles are role (stored as the role’s ulong) and Period from NodaTime. This allows me to configure a prerequisite for another role (for instance, in my server, you can opt-in to the NSFW role, but you can only do so if you already have the 18+ role, the latter of which is granted by a mod), or a duration (for instance, requiring users to be present for 24 hours before allowing them to get a certain role).

Admin side is nothing interesting. Just the standard accoutrement of commands mapped to the particular property you wish to modify on an existing AssignableRole, or creating or destroying such. Overall, it works pretty well for my purposes.

Here’s a view of the output of the !roles command, page 5, from my server. Note the category (just above the listing) image

Adding a role: image

Artist is not assignable: image

How categories are used. These are the roles I have on my account: image (all the free demographic information)


Some topics for discussion:

  1. Role Categories Role Categories on my guild are granted when the user first joins the server (as defined by an AutoIssue flag). They can also be assigned when a user opts-into a role under that category. However, no code yet exists to remove an empty category as I don’t use that option.
  2. Prerequisite Handling Currently, I have two types of prerequisites, each as their own property on the AssignableRole object. Should this remain as-is or should it be moved to a List<IPrerequisite> of some sort to allow users to define their own (perhaps hooking into the proposed plugin feature which doesn’t have an issue yet?)
  3. AssignmentMethod enum Currently this is only used to disable the role, though it can possibly be extended.
  4. Description I started building this in but I’ve not yet finished it. Each assignable role has a Description (string) property which is planned to be displayed next to the role name in the listing.

Code documents of relevance for this bot: IAssignableRole, AssignableRole

RoleCommands, RoleList Command

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
calledudecommented, Apr 11, 2019

I’m swooping this up if nobody has any objections 😃

1reaction
JakenVeinacommented, Sep 25, 2018

So, stripping out the implementation, all this really is is a way for users to assign cosmetic-only roles to themselves, yes?

This sounds stupid simple, given our current architecture. Simply add a new DesignatedRoleType of SelfAssignable or Tag or something similar, and then we just need the commands to allow users to assign and unassign them.

Definitely add AuthorizationClaim values for these commands as well. Although you might want to allow any and everyone to use them, I think in the main C# server, we’ll probably limit it to at least Regular and above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Role Commands (Self-assignable roles)
Ignore role: Ignore any person who has this role. Group: Put the role in a role group (will be explained more further down)....
Read more >
Self-Assigned Roles By Selecting A Custom Reaction/Emoji?
Self-Assigned Roles By Selecting A Custom Reaction/Emoji? ... Is there any free bot that supports this yet? Not really seen or found an...
Read more >
How To Make Reaction Roles On Discord - TechNewsToday
Reaction roles are a fun feature in Discord servers. ... But that's never going to be as convenient as self-assigned reaction roles.
Read more >
Self-Assignable Roles
Self-assignable roles are a powerful feature that allows anyone on your team to assign themselves a role of their choice.
Read more >
How To Self-Assign Roles In Discord | Step-By-Step Guide
Want to learn how to self assign roles in discord? Check out this article and find best solutions for your problem. Let's solve...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found