Hello Bevy developers!
The latest version of bevy-discord, version 0.7 is now live! This is a significant update that brings support for the much-anticipated Bevy 0.17. This release also introduces several breaking changes designed to align the crate with Bevy's new APIs and improve overall consistency.
This blog will walk you through all the necessary steps to get your project updated. Let's dive in!
Breaking Changes
This release focuses on renaming and restructuring to match the upstream changes in Bevy 0.17.
1. Update Bevy and bevy-discord Dependencies
First, you'll need to update the versions in your Cargo.toml file to use Bevy 0.17 and bevy-discord 0.7.
# Before (in your Cargo.toml)
[dependencies]
bevy = "0.16"
bevy-discord = "0.6"
# After
[dependencies]
bevy = "0.17"
bevy-discord = "0.7"
2. Aligning with Bevy 0.17: Events are now Messages
This is a key change, and it's driven directly by an important update in Bevy 0.17.
In an effort to improve conceptual clarity, Bevy has renamed "buffered events" (the kind sent with EventWriter and read with EventReader) to Messages. The term Event is now used for a different purpose within the engine.
To stay consistent with this new terminology, bevy-discord has followed suit. The entire bevy_discord::events module has been renamed to bevy_discord::messages.
You'll need to update your use statements accordingly:
// Before
use bevy_discord::events::*;
// After
use bevy_discord::messages::*;
3. Structs Renamed to ...Message
Following the move from Events to Messages, all the relevant structs have been renamed to reflect their new purpose and now carry a Message suffix.
Bot Messages (Formerly Bot Events)
The old B<EVENT_NAME> pattern has been replaced with a more descriptive name.
-
Old Pattern:
bevy_discord::events::bot::B<EVENT_NAME> -
New Pattern:
bevy_discord::messages::bot::<EVENT_NAME>Message
There are some exceptions exists like BReadyEvent is now BotReadyMessage and BMessage is now DiscordMessage.
Here's a practical example of a system handling the Reaction message:
// Before
use bevy_discord::events::bot::BReactionAdd;
fn handle_reaction(mut events: EventReader<BReactionAdd>) {
for reaction in events.read() {
// Logic here ...
}
}
// After
use bevy_discord::messages::bot::ReactionAddMessage;
fn handle_reaction(mut messages: MessageReader<ReactionAddMessage>) {
for reaction in messages.read() {
// Logic here ...
}
}
Rich Presence Messages (Formerly Rich Presence Events)
Similarly, the Rich Presence event types have also been streamlined.
-
Old Pattern:
bevy_discord::events::rich_presence::RichPresence<EVENT_NAME> -
New Pattern:
bevy_discord::messages::rich_presence::<EVENT_NAME>Message
4. System Set Renamed: DiscordSet to DiscordSystems
To better align with Bevy's current naming conventions for system sets, DiscordSet has been renamed to DiscordSystems.
New Features & Improvements
This release isn't just about breaking changes! It also includes some nice quality-of-life improvements.
-
DebugandCloneDerivations: Many core types, including plugins, configs, messages, and resources, now deriveDebugandClone. This makes debugging your application and managing state much easier. - Rust 2024 Edition: The crate has been upgraded to the Rust 2024 edition, keeping it modern and performant.
- Improved Docs: The documentation on docs.rs is now clearer.
That's it! The migration to bevy-discord 0.7 primarily involves updating names and paths to align with the excellent changes in Bevy 0.17.
Happy Coding!
Top comments (0)