Skip to content

Commit cf07d27

Browse files
authored
Merge pull request #122 from Rustmail/121-help-command
feat(commands): add help command to display all bot's commands
2 parents 509d3e8 + 0b0628b commit cf07d27

3 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/commands/help.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use serenity::all::{Context, Message};
2+
use crate::config::Config;
3+
use crate::errors::ModmailResult;
4+
use crate::utils::message::message_builder::MessageBuilder;
5+
6+
pub async fn help(ctx: &Context, msg: &Message, config: &Config) -> ModmailResult<()> {
7+
let help_message = "# Available commands:\n\n\
8+
**!add_staff <staff_id>** - Add a staff to an hidden ticket\n\
9+
**!remove_staff <staff_id>** - Remove a staff from a ticket\n\
10+
**!alert** - Alert staff in the current thread when a new user answer arrives \n\
11+
**!help** - Show this help message\n\
12+
**!reply <message>** - Reply to a ticket\n\
13+
**!annonreply <message>** - Reply anonymously to a ticket\n\
14+
**!close [reason]** - Close the current thread with an optional reason\n\
15+
**!delete [reason]** - Delete the current thread with an optional reason\n\
16+
**!hide** - Make the current thread hidden to non-staff members\n\
17+
**!new_thread <user_id>** - Create a new ticket with a specific user\n\
18+
**!alert [cancel]** - Set or cancel an alert for staff in the current thread\n\
19+
**!force_close** - Force close the current thread if it's orphaned\n\
20+
**!id** - Show the user ID associated with the current thread";
21+
22+
MessageBuilder::system_message(ctx, config)
23+
.content(help_message)
24+
.to_channel(msg.channel_id)
25+
.send()
26+
.await?;
27+
28+
Ok(())
29+
}

src/commands/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ pub mod recover;
1212
pub mod remove_staff;
1313
pub mod reply;
1414
pub mod test_errors;
15+
pub mod help;

src/handlers/guild_messages_handler.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use serenity::{
3737
use std::collections::HashSet;
3838
use std::sync::{LazyLock, Mutex};
3939
use std::{collections::HashMap, future::Future, pin::Pin, sync::Arc};
40+
use crate::commands::help::help;
4041

4142
static SUPPRESSED_DELETES: LazyLock<Mutex<HashSet<u64>>> =
4243
LazyLock::new(|| Mutex::new(HashSet::new()));
@@ -74,6 +75,7 @@ impl GuildMessagesHandler {
7475
wrap_command!(h.commands, ["add_staff", "as"], add_staff);
7576
wrap_command!(h.commands, ["remove_staff", "rs"], remove_staff);
7677
wrap_command!(h.commands, "id", id);
78+
wrap_command!(h.commands, "help", help);
7779
h
7880
}
7981
}

0 commit comments

Comments
 (0)