|
| 1 | +use crate::config::Config; |
| 2 | +use crate::errors::ModmailResult; |
| 3 | +use crate::i18n::get_translated_message; |
| 4 | +use crate::utils::command::defer_response::defer_response; |
| 5 | +use crate::utils::message::message_builder::MessageBuilder; |
| 6 | +use serenity::all::{CommandInteraction, Context, CreateCommand, ResolvedOption}; |
| 7 | + |
| 8 | +pub async fn register(config: &Config) -> CreateCommand { |
| 9 | + let cmd_desc = get_translated_message( |
| 10 | + config, |
| 11 | + "slash_command.help_command_description", |
| 12 | + None, |
| 13 | + None, |
| 14 | + None, |
| 15 | + None, |
| 16 | + ) |
| 17 | + .await; |
| 18 | + |
| 19 | + CreateCommand::new("help").description(cmd_desc) |
| 20 | +} |
| 21 | + |
| 22 | +pub async fn run( |
| 23 | + ctx: &Context, |
| 24 | + command: &CommandInteraction, |
| 25 | + _options: &[ResolvedOption<'_>], |
| 26 | + config: &Config, |
| 27 | +) -> ModmailResult<()> { |
| 28 | + let help_message = "# Available commands:\n\n\ |
| 29 | + **!add_staff <staff_id>** - Add a staff to an hidden ticket\n\ |
| 30 | + **!remove_staff <staff_id>** - Remove a staff from a ticket\n\ |
| 31 | + **!alert** - Alert staff in the current thread when a new user answer arrives \n\ |
| 32 | + **!help** - Show this help message\n\ |
| 33 | + **!reply <message>** - Reply to a ticket\n\ |
| 34 | + **!annonreply <message>** - Reply anonymously to a ticket\n\ |
| 35 | + **!close [reason]** - Close the current thread with an optional reason\n\ |
| 36 | + **!delete [reason]** - Delete the current thread with an optional reason\n\ |
| 37 | + **!hide** - Make the current thread hidden to non-staff members\n\ |
| 38 | + **!new_thread <user_id>** - Create a new ticket with a specific user\n\ |
| 39 | + **!alert [cancel]** - Set or cancel an alert for staff in the current thread\n\ |
| 40 | + **!force_close** - Force close the current thread if it's orphaned\n\ |
| 41 | + **!id** - Show the user ID associated with the current thread"; |
| 42 | + |
| 43 | + defer_response(&ctx, &command).await?; |
| 44 | + |
| 45 | + let response = MessageBuilder::system_message(ctx, config) |
| 46 | + .content(help_message) |
| 47 | + .to_channel(command.channel_id) |
| 48 | + .build_interaction_message_followup() |
| 49 | + .await; |
| 50 | + |
| 51 | + let _ = command.create_followup(&ctx.http, response).await; |
| 52 | + |
| 53 | + Ok(()) |
| 54 | +} |
0 commit comments