Skip to content

Commit 73e84ab

Browse files
committed
feat: create class/level role assignment logic
1 parent 8cd917d commit 73e84ab

File tree

9 files changed

+924
-89
lines changed

9 files changed

+924
-89
lines changed

src/bot/commands/config.rs

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ use crate::bot::Error;
22
use crate::state::AppState;
33
use redis::AsyncCommands;
44
use serenity::all::{
5-
Colour, CommandInteraction, Context, CreateCommand, CreateEmbed, CreateEmbedFooter,
6-
CreateInteractionResponse, CreateInteractionResponseMessage, Mentionable, RoleId,
5+
CommandInteraction, Context, CreateCommand, CreateComponent, CreateContainer,
6+
CreateInteractionResponse, CreateInteractionResponseMessage, CreateTextDisplay, Mentionable,
7+
MessageFlags, RoleId,
78
};
89
use std::sync::Arc;
910

@@ -86,7 +87,7 @@ pub async fn handle(
8687
"Invalid configuration".to_string()
8788
}
8889
}
89-
None => "Not configured (use /setverifiedrole)".to_string(),
90+
None => "Not configured (use `/setverifiedrole`)".to_string(),
9091
};
9192

9293
// Count verified users
@@ -107,27 +108,45 @@ pub async fn handle(
107108

108109
let progress_bar = generate_progress_bar(verified_count, total_members, 20);
109110

110-
let embed = CreateEmbed::new()
111-
.title("Server Configuration")
112-
.field("Verified Role", role_info, false)
113-
.field(
114-
"Statistics",
115-
format!(
116-
"Verified Users: {}/{} (total includes bots)\n{}",
117-
verified_count, total_members, progress_bar
118-
),
119-
false,
120-
)
121-
.colour(Colour::BLUE)
122-
.footer(CreateEmbedFooter::new(format!(
123-
"{} users still need to verify",
111+
// Get role mode
112+
let role_mode_key = format!("guild:{}:role_mode", guild_id);
113+
let role_mode: Option<String> = conn.get(&role_mode_key).await?;
114+
let role_mode = role_mode.unwrap_or_else(|| "none".to_string());
115+
116+
let mode_description = match role_mode.as_str() {
117+
"levels" => "* **Levels Mode** (assigning roles based on Undergrad/Graduate status)",
118+
"classes" => {
119+
"* **Classes Mode** (assigning roles based on class year, First-Year through Doctoral)"
120+
}
121+
"custom" => "* **Custom Mode** (assigning roles based on selected levels and classes)",
122+
_ => "* **None** (only the verified role is being assigned)",
123+
};
124+
125+
// Create components v2 message
126+
let container = CreateContainer::new(vec![
127+
CreateComponent::TextDisplay(CreateTextDisplay::new("# Configuration")),
128+
CreateComponent::TextDisplay(CreateTextDisplay::new(format!(
129+
"Current verification settings for this server:\n{}",
130+
mode_description
131+
))),
132+
CreateComponent::TextDisplay(CreateTextDisplay::new(format!(
133+
"* **Verified Role:** {}",
134+
role_info
135+
))),
136+
CreateComponent::TextDisplay(CreateTextDisplay::new(format!(
137+
"Verified Users: {}/{} (total includes bots)\n{}\n\
138+
{} users still need to verify • Use `/setuproles` to change mode",
139+
verified_count,
140+
total_members,
141+
progress_bar,
124142
total_members.saturating_sub(verified_count)
125-
)));
143+
))),
144+
]);
126145

127146
let response = CreateInteractionResponse::Message(
128147
CreateInteractionResponseMessage::new()
129-
.embed(embed)
130-
.ephemeral(true),
148+
.components(vec![CreateComponent::Container(container)])
149+
.flags(MessageFlags::EPHEMERAL | MessageFlags::IS_COMPONENTS_V2),
131150
);
132151
command.create_response(&ctx.http, response).await?;
133152

src/bot/commands/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod config;
2+
pub mod setuproles;
23
pub mod setverifiedrole;
34
pub mod unverify;
45
pub mod userinfo;
@@ -15,6 +16,7 @@ pub async fn register_commands(ctx: &Context) -> Result<(), Error> {
1516
unverify::register(),
1617
userinfo::register(),
1718
setverifiedrole::register(),
19+
setuproles::register(),
1820
config::register(),
1921
];
2022

0 commit comments

Comments
 (0)