Updated prefix and added help command
parent
4ff36d3fe8
commit
23f5a86013
22
README.md
22
README.md
|
@ -2,7 +2,7 @@
|
||||||
Discord bot for managing an anonymous [Werewolf Game](https://en.wikipedia.org/wiki/Mafia_(party_game)).
|
Discord bot for managing an anonymous [Werewolf Game](https://en.wikipedia.org/wiki/Mafia_(party_game)).
|
||||||
|
|
||||||
## How It Works
|
## 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
|
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
|
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
|
## Commands
|
||||||
|
|
||||||
## Host
|
## Host
|
||||||
* `!start <list of player ids>` - starts the game
|
* `$start <list of player ids>` - starts the game
|
||||||
* `!end` - Ends the current game
|
* `$end` - Ends the current game
|
||||||
* `!say <msg>` - Allows the host to speak into the game chat
|
* `$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
|
* `$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
|
* `$next_phase <duration> <msg>` - Send the next phase message. Also cycles the phase
|
||||||
* `!terminate <player>` - Kills a player and removes them from the game
|
* `$terminate <player>` - Kills a player and removes them from the game
|
||||||
* `!add_time <duration>` - Adds more time to the current game
|
* `$add_time <duration>` - Adds more time to the current game
|
||||||
|
|
||||||
## Players
|
## Players
|
||||||
* `!vote <player>` - Casts a vote for a player to be terminated. Only can be used during the day phase
|
* `$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
|
* `$status` - Get the current game status. Includes time left in the phase and current vote tallies
|
||||||
* `!players` - Lists all the players in the game
|
* `$players` - Lists all the players in the game
|
||||||
|
|
||||||
## Example Config
|
## Example Config
|
||||||
```toml
|
```toml
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
use serenity::framework::standard::macros::{command, group};
|
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::framework::StandardFramework;
|
||||||
use serenity::model::id::ChannelId;
|
use serenity::model::id::ChannelId;
|
||||||
use serenity::model::prelude::{Message, UserId};
|
use serenity::model::prelude::{Message, UserId};
|
||||||
use serenity::prelude::Context;
|
use serenity::prelude::Context;
|
||||||
use serenity::utils::MessageBuilder;
|
use serenity::utils::MessageBuilder;
|
||||||
|
use serenity::framework::standard::macros::help;
|
||||||
|
|
||||||
use crate::data::{GlobalData, MessageSource, Phase};
|
use crate::data::{GlobalData, MessageSource, Phase};
|
||||||
use crate::helper;
|
use crate::helper;
|
||||||
|
@ -12,6 +13,7 @@ use crate::helper::{
|
||||||
build_system_message, clear_game_state, get_phase_end_timestamp, print_game_status,
|
build_system_message, clear_game_state, get_phase_end_timestamp, print_game_status,
|
||||||
save_game_state, send_msg_to_player_channels,
|
save_game_state, send_msg_to_player_channels,
|
||||||
};
|
};
|
||||||
|
use std::collections::HashSet;
|
||||||
|
|
||||||
#[group]
|
#[group]
|
||||||
#[commands(start, say, end, broadcast, next_phase, terminate, add_time)]
|
#[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(())
|
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 {
|
pub fn command_framework() -> StandardFramework {
|
||||||
StandardFramework::new()
|
StandardFramework::new()
|
||||||
.configure(|c| c.prefix("!"))
|
.configure(|c| c.prefix('$'))
|
||||||
.group(&HOST_GROUP)
|
.group(&HOST_GROUP)
|
||||||
.group(&PLAYER_GROUP)
|
.group(&PLAYER_GROUP)
|
||||||
|
.help(&HELP)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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("You will also use this terminal for choosing one of your fellow subjects for termination.")
|
||||||
.push_line("Happy testing :)")
|
.push_line("Happy testing :)")
|
||||||
.push_line("")
|
.push_line("")
|
||||||
|
.push_line("Do $help to see all commands.")
|
||||||
|
.push_line("")
|
||||||
.push("SUBJECT CODENAME: ")
|
.push("SUBJECT CODENAME: ")
|
||||||
.push_line(&codename)
|
.push_line(&codename)
|
||||||
.push(print_game_status(&global_data.game_state))
|
.push(print_game_status(&global_data.game_state))
|
||||||
|
|
|
@ -22,7 +22,7 @@ impl EventHandler for Handler {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if msg.content.starts_with('!') {
|
if msg.content.starts_with('$') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue