feat: add command to ping random members#103
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new $random prefix command to ping a random subset of members with either the First Year or Second Year role, wiring it into the bot’s command registry and introducing a rand dependency.
Changes:
- Added
$randomcommand implementation to fetch guild members, filter by year roles, and ping 5 selected members. - Registered the new command in
src/commands/mod.rs. - Added role ID constants for First/Second Year and added
randas a dependency.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/ids.rs | Adds role ID constants for First/Second Year filtering. |
| src/commands/random.rs | Implements $random member selection and ping message. |
| src/commands/mod.rs | Registers the new random command in the command list. |
| Cargo.toml | Adds direct rand dependency. |
| Cargo.lock | Records rand addition and multiple dependency updates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
c60e22b to
673a000
Compare
|
673a000 to
6f5a6bd
Compare
6f5a6bd to
df10f43
Compare
| let first_year_role = RoleId::new(FIRST_YEAR_ROLE_ID); | ||
| let second_year_role = RoleId::new(SECOND_YEAR_ROLE_ID); |
There was a problem hiding this comment.
why are only first and second years included as eligible members? Ideally one should be able to specify which all years they want to target with it falling back to all 3 as a default
| let data = ctx.data(); | ||
| let recent_random_picks = data.recent_random_picks.lock().unwrap(); | ||
| recent_random_picks.clone() |
| let data = ctx.data(); | ||
| let mut recent_random_picks = data.recent_random_picks.lock().unwrap(); | ||
| recent_random_picks.extend(selected.iter().map(|m| m.user.id)); // Adding selected members to recently picked set |
| @@ -49,6 +52,7 @@ type Context<'a> = PoiseContext<'a, Data, Error>; | |||
| #[derive(Clone)] | |||
| struct Data { | |||
| reaction_roles: HashMap<ReactionType, RoleId>, | |||
| recent_random_picks: Arc<Mutex<HashSet<UserId>>>, | |||
| log_reload_handle: ReloadHandle, | |||
|
|
||
| let recent_picks = { | ||
| // Accessing recently picked members to avoid repetition | ||
| let data = ctx.data(); |
There was a problem hiding this comment.
is ctx.data() persisted across bot restarts? If not, it can't be relied upon as the bot service may restart due to various factors.
|
|
||
| let mut selected: Vec<_> = available_members.into_iter().choose_multiple(&mut rng, 5); | ||
|
|
||
| if selected.len() < 5 { |
There was a problem hiding this comment.
number should be configurable via the slash syntax rather than hardcoded to 5
This PR adds a
$randomcommand which randomly selects and pings 5 members who are either First Years or Second YearsChanges
$randomcommand.shufflemethod