Updated prefix and added help command

msg_refactor
Joey Hines 2022-03-07 19:56:12 -07:00
parent 4ff36d3fe8
commit 23f5a86013
No known key found for this signature in database
GPG Key ID: 80F567B5C968F91B
4 changed files with 38 additions and 14 deletions

View File

@ -2,7 +2,7 @@
Discord bot for managing an anonymous [Werewolf Game](https://en.wikipedia.org/wiki/Mafia_(party_game)).
## How It Works
A host gets a list of players to play, and then begins the game with the `!start` command.
A host gets a list of players to play, and then begins the game with the `$start` command.
Each player is assigned a channel where they will view the game through. The player can read and send messages
in this channel normally. When a message is sent, it is forwarded to all other player channels. The message's author
@ -19,18 +19,18 @@ The game proceeds as a normal Werewolf game.
## Commands
## Host
* `!start <list of player ids>` - starts the game
* `!end` - Ends the current game
* `!say <msg>` - Allows the host to speak into the game chat
* `!broadcast <msg>` - Broadcasts a system message, this message is then pinned in each player channel
* `!next_phase <duration> <msg>` - Send the next phase message. Also cycles the phase
* `!terminate <player>` - Kills a player and removes them from the game
* `!add_time <duration>` - Adds more time to the current game
* `$start <list of player ids>` - starts the game
* `$end` - Ends the current game
* `$say <msg>` - Allows the host to speak into the game chat
* `$broadcast <msg>` - Broadcasts a system message, this message is then pinned in each player channel
* `$next_phase <duration> <msg>` - Send the next phase message. Also cycles the phase
* `$terminate <player>` - Kills a player and removes them from the game
* `$add_time <duration>` - Adds more time to the current 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
* `$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

@ -1,10 +1,11 @@
use serenity::framework::standard::macros::{command, group};
use serenity::framework::standard::{Args, CommandResult};
use serenity::framework::standard::{Args, CommandResult, HelpOptions, CommandGroup, help_commands};
use serenity::framework::StandardFramework;
use serenity::model::id::ChannelId;
use serenity::model::prelude::{Message, UserId};
use serenity::prelude::Context;
use serenity::utils::MessageBuilder;
use serenity::framework::standard::macros::help;
use crate::data::{GlobalData, MessageSource, Phase};
use crate::helper;
@ -12,6 +13,7 @@ use crate::helper::{
build_system_message, clear_game_state, get_phase_end_timestamp, print_game_status,
save_game_state, send_msg_to_player_channels,
};
use std::collections::HashSet;
#[group]
#[commands(start, say, end, broadcast, next_phase, terminate, add_time)]
@ -412,9 +414,29 @@ async fn players(ctx: &Context, msg: &Message, _args: Args) -> CommandResult {
Ok(())
}
#[help]
#[individual_command_tip = "If you want more information about a specific command, just pass the command as argument."]
#[command_not_found_text = "Could not find: `{}`."]
#[max_levenshtein_distance(3)]
#[indention_prefix = "+"]
#[lacking_role = "Nothing"]
#[wrong_channel = "Strike"]
async fn help(
context: &Context,
msg: &Message,
args: Args,
help_options: &'static HelpOptions,
groups: &[&'static CommandGroup],
owners: HashSet<UserId>,
) -> CommandResult {
let _ = help_commands::with_embeds(context, msg, args, help_options, groups, owners).await;
Ok(())
}
pub fn command_framework() -> StandardFramework {
StandardFramework::new()
.configure(|c| c.prefix("!"))
.configure(|c| c.prefix('$'))
.group(&HOST_GROUP)
.group(&PLAYER_GROUP)
.help(&HELP)
}

View File

@ -172,6 +172,8 @@ pub async fn add_user_to_game(
.push_line("You will also use this terminal for choosing one of your fellow subjects for termination.")
.push_line("Happy testing :)")
.push_line("")
.push_line("Do $help to see all commands.")
.push_line("")
.push("SUBJECT CODENAME: ")
.push_line(&codename)
.push(print_game_status(&global_data.game_state))

View File

@ -22,7 +22,7 @@ impl EventHandler for Handler {
return;
}
if msg.content.starts_with('!') {
if msg.content.starts_with('$') {
return;
}