Add prefix customization command

This commit is contained in:
2025-08-14 18:30:33 -03:00
parent eb6dcb4604
commit 53d61cfbbb
7 changed files with 143 additions and 7 deletions
+4
View File
@@ -31,6 +31,10 @@ impl FromArguments for String {
}
}
/// Consumes the entire remaining string as a single argument. If no string is remaining, it
/// returns an empty string.
///
/// Parsing this argument type never fails.
pub struct GreedyString(pub String);
impl FromArguments for GreedyString {
+7 -1
View File
@@ -20,6 +20,9 @@ pub enum CommandError {
#[error("A database operation failed due to an inconsistent state")]
DatabaseInconsistentState,
#[error("The command was used in DMs, but it can only be used in servers")]
ServerCommandRunInDMs,
}
#[async_trait]
@@ -66,7 +69,10 @@ pub fn get_command_parts<'a>(prefix: &str, message: &'a str) -> Option<CommandPa
.to_ascii_lowercase()
.starts_with(&prefix.to_ascii_lowercase())
{
let message = message_trimmed_start.split_at(prefix.len()).1.trim_ascii_start();
let message = message_trimmed_start
.split_at(prefix.len())
.1
.trim_ascii_start();
match message.split_once(" ") {
Some((name, args)) => Some(CommandParts::new(name, args)),
+4 -1
View File
@@ -32,7 +32,10 @@ impl<T: Send + Sync + 'static> OnMessageHandler<T> for CommandRunner {
if let Some(command) = command {
command
.execute(CommandContext::new(event, rt.clone(), &prefixes[0]), parts.args)
.execute(
CommandContext::new(event, rt.clone(), &prefixes[0]),
parts.args,
)
.await?;
break;