Skip to main content

PrefixFrameworkOptions

Struct PrefixFrameworkOptions 

Source
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: bool

Treat 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: bool

If 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: bool

Whether 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: bool

Whether commands in messages emitted by this bot itself should be executed as well.

§ignore_bots: bool

Whether to ignore messages from bots for command invoking. Default true

§ignore_thread_creation: bool

Whether to ignore commands contained within thread creation messages. Default true

§case_insensitive_commands: bool

Whether 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

Trait Implementations§

Source§

impl<U, E> Debug for PrefixFrameworkOptions<U, E>

Source§

fn fmt(&self, __f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<U, E> Default for PrefixFrameworkOptions<U, E>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<U, E> Freeze for PrefixFrameworkOptions<U, E>

§

impl<U, E> RefUnwindSafe for PrefixFrameworkOptions<U, E>

§

impl<U, E> Send for PrefixFrameworkOptions<U, E>

§

impl<U, E> Sync for PrefixFrameworkOptions<U, E>

§

impl<U, E> Unpin for PrefixFrameworkOptions<U, E>

§

impl<U, E> UnsafeUnpin for PrefixFrameworkOptions<U, E>

§

impl<U, E> UnwindSafe for PrefixFrameworkOptions<U, E>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DebuggableStorage for T
where T: Any + Send + Sync + Debug,