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: ()
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.