Added !players command

msg_refactor
Joey Hines 2022-03-06 14:18:54 -07:00
parent 086bd1051e
commit 98bc997ff3
No known key found for this signature in database
GPG Key ID: 80F567B5C968F91B
2 changed files with 26 additions and 1 deletions

View File

@ -30,6 +30,7 @@ The game proceeds as a normal Werewolf game.
## Players
* `!vote <player>` - 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

View File

@ -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::<GlobalData>().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("!"))