pub struct DiscordBotConfig { /* private fields */ }Available on (crate features
bot or rich_presence) and crate feature bot only.Expand description
Configuration settings for the Discord bot.
This struct allows you to configure various aspects of the bot including:
- Bot token
- Gateway intents
- Online status
- Activity status
Implementations§
Source§impl DiscordBotConfig
impl DiscordBotConfig
Sourcepub fn token(self, token: String) -> Self
pub fn token(self, token: String) -> Self
Sets the bot token.
Examples found in repository?
More examples
examples/reactions.rs (line 13)
11fn main() {
12 let config = DiscordBotConfig::default()
13 .token("YOUR_BOT_TOKEN_HERE".to_string())
14 .gateway_intents(
15 GatewayIntents::GUILD_MESSAGES
16 | GatewayIntents::MESSAGE_CONTENT
17 | GatewayIntents::GUILDS
18 | GatewayIntents::GUILD_MESSAGE_REACTIONS,
19 );
20
21 App::new()
22 .add_plugins(MinimalPlugins)
23 .add_plugins(DiscordBotPlugin::new(config))
24 .add_systems(Update, (handle_discord_messages, handle_discord_reactions))
25 .run();
26}examples/basic_bot.rs (line 16)
13fn main() {
14 // Configure the bot with necessary intents
15 let config = DiscordBotConfig::default()
16 .token("YOUR_BOT_TOKEN_HERE".to_string())
17 .gateway_intents(
18 GatewayIntents::GUILD_MESSAGES
19 | GatewayIntents::MESSAGE_CONTENT
20 | GatewayIntents::GUILDS,
21 );
22
23 App::new()
24 .add_plugins(MinimalPlugins)
25 .add_plugins(bevy::log::LogPlugin {
26 ..Default::default()
27 })
28 .add_plugins(DiscordBotPlugin::new(config))
29 .add_systems(Update, handle_discord_message)
30 .run();
31}Sourcepub fn gateway_intents(self, gateway_intents: GatewayIntents) -> Self
pub fn gateway_intents(self, gateway_intents: GatewayIntents) -> Self
Sets the bot GatewayIntents.
Examples found in repository?
More examples
examples/reactions.rs (lines 14-19)
11fn main() {
12 let config = DiscordBotConfig::default()
13 .token("YOUR_BOT_TOKEN_HERE".to_string())
14 .gateway_intents(
15 GatewayIntents::GUILD_MESSAGES
16 | GatewayIntents::MESSAGE_CONTENT
17 | GatewayIntents::GUILDS
18 | GatewayIntents::GUILD_MESSAGE_REACTIONS,
19 );
20
21 App::new()
22 .add_plugins(MinimalPlugins)
23 .add_plugins(DiscordBotPlugin::new(config))
24 .add_systems(Update, (handle_discord_messages, handle_discord_reactions))
25 .run();
26}examples/basic_bot.rs (lines 17-21)
13fn main() {
14 // Configure the bot with necessary intents
15 let config = DiscordBotConfig::default()
16 .token("YOUR_BOT_TOKEN_HERE".to_string())
17 .gateway_intents(
18 GatewayIntents::GUILD_MESSAGES
19 | GatewayIntents::MESSAGE_CONTENT
20 | GatewayIntents::GUILDS,
21 );
22
23 App::new()
24 .add_plugins(MinimalPlugins)
25 .add_plugins(bevy::log::LogPlugin {
26 ..Default::default()
27 })
28 .add_plugins(DiscordBotPlugin::new(config))
29 .add_systems(Update, handle_discord_message)
30 .run();
31}Sourcepub fn status(self, status: OnlineStatus) -> Self
pub fn status(self, status: OnlineStatus) -> Self
Sets the initial status.
Sourcepub fn activity(self, activity: ActivityData) -> Self
pub fn activity(self, activity: ActivityData) -> Self
Sets the initial activity.
Trait Implementations§
Source§impl Clone for DiscordBotConfig
impl Clone for DiscordBotConfig
Source§fn clone(&self) -> DiscordBotConfig
fn clone(&self) -> DiscordBotConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DiscordBotConfig
impl Debug for DiscordBotConfig
Source§impl Default for DiscordBotConfig
impl Default for DiscordBotConfig
Source§fn default() -> DiscordBotConfig
fn default() -> DiscordBotConfig
Returns the “default value” for a type. Read more
impl Resource for DiscordBotConfig
Auto Trait Implementations§
impl Freeze for DiscordBotConfig
impl RefUnwindSafe for DiscordBotConfig
impl Send for DiscordBotConfig
impl Sync for DiscordBotConfig
impl Unpin for DiscordBotConfig
impl UnwindSafe for DiscordBotConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
Source§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<T> TypeData for T
impl<T> TypeData for T
Source§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.