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 option to automate date based roles #6

Open
v-pan opened this issue Sep 24, 2024 · 0 comments
Open

Add option to automate date based roles #6

v-pan opened this issue Sep 24, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@v-pan
Copy link

v-pan commented Sep 24, 2024

Current behaviour

Currently Whodis takes a few roles and assigns them to a user on verification

func addRoles(s *discordgo.Session, gid, uid string, rid []string) error {
roles, err := s.GuildRoles(gid)
if err != nil {
return err
}
roleID := utils.GetRoleIDFromName(roles, viper.GetString("discord.member.role"))
if roleID == "" {
return errors.New("no role called: " + viper.GetString("discord.member.role"))
}
if err := s.GuildMemberRoleAdd(gid, uid, roleID); err != nil {
return err
}
for _, additionalRoleID := range rid {
if err := s.GuildMemberRoleAdd(gid, uid, additionalRoleID); err != nil {
return err
}
}
return nil
}

This works for roles which do not change name over time, but requires manual management for assigning roles that may change by calling /setup again (eg. an @22/23 role).

Proposed Changes

Add an option to have Whodis manage a time-related role. This involves two things:

  1. Whodis will check the existence of, and create roles based on the current date.
    • Permissions wise, this should already be covered by the Manage roles permission
    • A role check needs to occur on user verification, as the required role will change after /setup was called.
  2. A method of configuring the role and how it should be updated needs to be provided.
    • By default this should not be enabled.

There's two ways we could add this:

Option 1

Allow a time format string in role names, in the style of the time command.

This would be easier to implement and flexible, but means that when /setup is called that we need to allow invalid roles as argument(s).

  • This doesn't have to affect autocomplete, as discord allows bots to provide their own list of completions.
  • To keep validating roles, it could instead be given a dedicated argument for dynamic roles.

Not all format options need to (or should, eg. seconds level accuracy) be provided.

Option 2

Fix the role as annual, and provide limited options to customise it.

It should check for the current academic year, probably by checking against a config provided cutoff date.

The role itself should be configured through extra arguments in /setup, or with a dedicated command for configuring dynamic roles.

With subcommands, setting up a dynamic role might look something like:

  1. /setup welcome-message [announce-channel] [logging-channel] <given-role-1> <given-role-2>
    • The old setup, but moved to a subcommand
  2. /setup date-role [date-format] <role-prefix> <role-suffix>
    • New subcommand. This will create and manage the role itself.

As before, we can provide auto-completions for the date formats, and don't have concerns with overloading existing arguments or commands.

@v-pan v-pan added the enhancement New feature or request label Sep 24, 2024
@v-pan v-pan changed the title Add option to automate year based roles Add option to automate date based roles Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant