pub struct PrefixFrameworkOptions<U, E> {Show 13 fields
pub prefix: Option<String>,
pub additional_prefixes: Vec<Prefix>,
pub dynamic_prefix: Option<fn(PartialContext<'_, U, E>) -> BoxFuture<'_, Result<Option<String>, E>>>,
pub stripped_dynamic_prefix: Option<for<'a> fn(&'a Context, &'a Message, &'a U) -> BoxFuture<'a, Result<Option<(&'a str, &'a str)>, E>>>,
pub mention_as_prefix: bool,
pub edit_tracker: Option<Arc<RwLock<EditTracker>>>,
pub execute_untracked_edits: bool,
pub ignore_edits_if_not_yet_responded: bool,
pub execute_self_messages: bool,
pub ignore_bots: bool,
pub ignore_thread_creation: bool,
pub case_insensitive_commands: bool,
pub non_command_message: Option<for<'a> fn(&'a FrameworkContext<'a, U, E>, &'a Context, &'a Message) -> BoxFuture<'a, Result<(), E>>>,
/* private fields */
}Expand description
Prefix-specific framework configuration
Fields§
§prefix: Option<String>The main bot prefix. Can be set to None if the bot supports only dynamic prefixes.
additional_prefixes: Vec<Prefix>List of additional bot prefixes
dynamic_prefix: Option<fn(PartialContext<'_, U, E>) -> BoxFuture<'_, Result<Option<String>, E>>>Callback invoked on every message to return a prefix.
Override this field for a simple dynamic prefix which changes depending on the guild or user.
For more advanced dynamic prefixes, see Self::stripped_dynamic_prefix
stripped_dynamic_prefix: Option<for<'a> fn(&'a Context, &'a Message, &'a U) -> BoxFuture<'a, Result<Option<(&'a str, &'a str)>, E>>>Callback invoked on every message to strip the prefix off an incoming message.
Override this field for advanced dynamic prefixes which change depending on guild or user.
Return value is a tuple of the prefix and the rest of the message:
let my_cool_prefix = "$";
if msg.content.starts_with(my_cool_prefix) {
return Ok(Some(msg.content.split_at(my_cool_prefix.len())));
}
Ok(None)mention_as_prefix: boolTreat a bot mention (a ping) like a prefix
edit_tracker: Option<Arc<RwLock<EditTracker>>>If Some, the framework will react to message edits by editing the corresponding bot response with the new result.
execute_untracked_edits: boolIf the user makes a typo in their message and a subsequent edit creates a valid invocation,
the bot will execute the command if this attribute is set. Self::edit_tracker does not
need to be set for this.
That does not mean that any subsequent edits will also trigger execution. For that,
see crate::Command::invoke_on_edit.
Note: only has an effect if Self::edit_tracker is set.
ignore_edits_if_not_yet_responded: boolWhether to ignore message edits on messages that have not yet been responded to.
This is the case if the message edit happens before a command has sent a response, or if the command does not send a response at all.
execute_self_messages: boolWhether commands in messages emitted by this bot itself should be executed as well.
ignore_bots: boolWhether to ignore messages from bots for command invoking. Default true
ignore_thread_creation: boolWhether to ignore commands contained within thread creation messages. Default true
case_insensitive_commands: boolWhether command names should be compared case-insensitively.
non_command_message: Option<for<'a> fn(&'a FrameworkContext<'a, U, E>, &'a Context, &'a Message) -> BoxFuture<'a, Result<(), E>>>Callback for all non-command messages. Useful if you want to run code on any message that is not a command