From 98bc997ff38f53c3aa3686534429bdb23f7914fe Mon Sep 17 00:00:00 2001 From: Joey Hines Date: Sun, 6 Mar 2022 14:18:54 -0700 Subject: [PATCH] Added !players command --- README.md | 1 + src/commands.rs | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ec11c09..2f2ed84 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The game proceeds as a normal Werewolf game. ## Players * `!vote ` - Casts a vote for a player to be terminated. Only can be used during the day phase * `!status` - Get the current game status. Includes time left in the phase and current vote tallies +* `!players` - Lists all the players in the game ## Example Config ```toml diff --git a/src/commands.rs b/src/commands.rs index 36a0b1b..2971de3 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -288,7 +288,7 @@ async fn add_time(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult } #[group] -#[commands(vote, status)] +#[commands(vote, status, players)] struct Player; #[command] @@ -386,6 +386,30 @@ async fn status(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { Ok(()) } + +#[command] +#[only_in(guilds)] +async fn players(ctx: &Context, msg: &Message, _args: Args) -> CommandResult { + let data = ctx.data.read().await; + let global_data = data.get::().unwrap(); + + let global_data = global_data.lock().await; + + let mut msg_builder = MessageBuilder::new(); + + msg_builder.push_line("Test Subjects:"); + + for player in &global_data.game_state.player_data { + msg_builder + .push("* ") + .push_line(&player.codename); + } + + msg.reply(&ctx.http, msg_builder.build()).await.unwrap(); + + Ok(()) +} + pub fn command_framework() -> StandardFramework { StandardFramework::new() .configure(|c| c.prefix("!"))