Skip to content

Commit a8c2e1d

Browse files
committed
feat(commands): merge help command from main branch into convert_to_slash_commands
2 parents b1db5f4 + cf07d27 commit a8c2e1d

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
@@ -5,6 +5,7 @@ pub mod close;
55
pub mod delete;
66
pub mod edit;
77
pub mod force_close;
8+
pub mod help;
89
pub mod id;
910
pub mod move_thread;
1011
pub mod new_thread;

src/handlers/guild_messages_handler.rs

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

3839
static SUPPRESSED_DELETES: LazyLock<Mutex<HashSet<u64>>> =
3940
LazyLock::new(|| Mutex::new(HashSet::new()));
@@ -68,6 +69,7 @@ impl GuildMessagesHandler {
6869
wrap_command!(h.commands, ["add_staff", "as"], add_staff);
6970
wrap_command!(h.commands, ["remove_staff", "rs"], remove_staff);
7071
wrap_command!(h.commands, "id", id);
72+
wrap_command!(h.commands, "help", help);
7173
h
7274
}
7375
}

0 commit comments

Comments
 (0)