Struct FrameworkOptions

Source
pub struct FrameworkOptions<U, E> {
Show 16 fields pub commands: Vec<Command<U, E>>, pub on_error: fn(FrameworkError<'_, U, E>) -> BoxFuture<'_, ()>, pub pre_command: fn(Context<'_, U, E>) -> BoxFuture<'_, ()>, pub post_command: fn(Context<'_, U, E>) -> BoxFuture<'_, ()>, pub command_check: Option<fn(Context<'_, U, E>) -> BoxFuture<'_, Result<bool, E>>>, pub skip_checks_for_owners: bool, pub allowed_mentions: Option<CreateAllowedMentions>, pub reply_callback: Option<fn(Context<'_, U, E>, CreateReply) -> CreateReply>, pub manual_cooldowns: bool, pub require_cache_for_guild_check: bool, pub event_handler: for<'a> fn(&'a Context, &'a FullEvent, FrameworkContext<'a, U, E>, &'a U) -> BoxFuture<'a, Result<(), E>>, pub listener: (), pub prefix_options: PrefixFrameworkOptions<U, E>, pub owners: HashSet<UserId>, pub initialize_owners: bool, pub initialized_team_roles: Option<Vec<TeamMemberRole>>, /* private fields */
}
Expand description

Framework configuration

Fields§

§commands: Vec<Command<U, E>>

List of commands in the framework

§on_error: fn(FrameworkError<'_, U, E>) -> BoxFuture<'_, ()>

Provide a callback to be invoked when any user code yields an error.

§pre_command: fn(Context<'_, U, E>) -> BoxFuture<'_, ()>

Called before every command

§post_command: fn(Context<'_, U, E>) -> BoxFuture<'_, ()>

Called after every command if it was successful (returned Ok)

§command_check: Option<fn(Context<'_, U, E>) -> BoxFuture<'_, Result<bool, E>>>

Provide a callback to be invoked before every command. The command will only be executed if the callback returns true.

If individual commands add their own check, both callbacks are run and must return true.

§skip_checks_for_owners: bool

If set to true, skips command checks if command was issued by FrameworkOptions::owners

§allowed_mentions: Option<CreateAllowedMentions>

Default set of allowed mentions to use for all responses

By default, user pings are allowed and role pings and everyone pings are filtered

§reply_callback: Option<fn(Context<'_, U, E>, CreateReply) -> CreateReply>

Invoked before every message sent using crate::Context::say or crate::Context::send

Allows you to modify every outgoing message in a central place

§manual_cooldowns: bool

If true, disables automatic cooldown handling before every command invocation.

Useful for implementing custom cooldown behavior. See crate::Command::cooldowns and the methods on crate::Cooldowns for how to do that.

§require_cache_for_guild_check: bool

If true, changes behavior of guild_only command check to abort execution if the guild is not in cache.

If cache feature is disabled, this has no effect!

§event_handler: for<'a> fn(&'a Context, &'a FullEvent, FrameworkContext<'a, U, E>, &'a U) -> BoxFuture<'a, Result<(), E>>

Called on every Discord event. Can be used to react to non-command events, like messages deletions or guild updates.

§listener: ()
👎Deprecated: renamed to event_handler

Renamed to Self::event_handler!

§prefix_options: PrefixFrameworkOptions<U, E>

Prefix command specific options.

§owners: HashSet<UserId>

User IDs which are allowed to use owners_only commands

§initialize_owners: bool

If true, Self::owners is automatically initialized with the results of serenity::Http::get_current_application_info().

True by default.

§initialized_team_roles: Option<Vec<TeamMemberRole>>

If set and Self::initialize_owners is true, the selected teams will be initialized using the results of serenity::Http::get_current_application_info().

When set to None, only users with the Developer and Admin roles are initialized.

None by default.

Implementations§

Source§

impl<U, E> FrameworkOptions<U, E>

Source

pub fn command( &mut self, command: Command<U, E>, meta_builder: impl FnOnce(&mut Command<U, E>) -> &mut Command<U, E> + 'static, )

👎Deprecated: supply commands in FrameworkOptions directly with commands: vec![...]

Add a new command to the framework

Trait Implementations§

Source§

impl<U, E> Debug for FrameworkOptions<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 FrameworkOptions<U, E>
where U: Send + Sync, E: Display + Debug + Send,

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

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

§

impl<U, E> !RefUnwindSafe for FrameworkOptions<U, E>

§

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

§

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

§

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

§

impl<U, E> !UnwindSafe for FrameworkOptions<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> 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,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T