Add prefix customization command
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)),
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user