diff --git a/aether-core/CHANGELOG.md b/aether-core/CHANGELOG.md index 3d3fd02..680b609 100644 --- a/aether-core/CHANGELOG.md +++ b/aether-core/CHANGELOG.md @@ -8,31 +8,39 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] 0.3.0-rc.1 ### Added + - Added Discord Chat Relay - Added Discord Notifications for important events +- Added Discord to take command ### Changed + - Upgrade dependency `serde_json` - Changed bot joining mechanism to retry forever ### Removed + - Removed azalea patch i.e. [`better-1.20.6`](https://github.com/as1100k-forks/azalea.git) ### Fixed + - Removed Auto Eat [Issue #24](https://github.com/AS1100K/aether/issues/24) ## [0.3.0-beta.1] 07-08-2024 ### Added + - Added `InWorld`, and `ExecutingTask` Component [#22](https://github.com/AS1100K/aether/pull/22) - Added `PearlLoad` Event [#22](https://github.com/AS1100K/aether/pull/22) - Added Auto Eat - Added Auto Totem ### Changed + - Migrated from Tokio to Bevy ECS [#22](https://github.com/AS1100K/aether/pull/22) ### Removed + - Removed Integration with `azalea_discord` [#22](https://github.com/AS1100K/aether/pull/22) _For previous Changelog, you need to do `git blame`_ diff --git a/aether-core/src/chat.rs b/aether-core/src/chat.rs index 1078590..5da4653 100644 --- a/aether-core/src/chat.rs +++ b/aether-core/src/chat.rs @@ -8,7 +8,6 @@ use azalea::entity::LocalEntity; use azalea::prelude::*; use azalea_anti_afk::config::AntiAFKConfig; use azalea_anti_afk::AntiAFK; -use azalea_utility::auto_eat::{StartAutoEat, StopAutoEat}; use azalea_utility::auto_totem::AutoTotem; use bevy_discord::bot::serenity::all::ChannelId; use bevy_discord::bot::DiscordBotRes; diff --git a/aether-core/src/commands/mod.rs b/aether-core/src/commands/mod.rs index c4d0483..5622f08 100644 --- a/aether-core/src/commands/mod.rs +++ b/aether-core/src/commands/mod.rs @@ -1,7 +1,4 @@ -use azalea::{ - app::Plugin, - prelude::*, -}; +use azalea::{app::Plugin, prelude::*}; use pearl::load::{handle_executing_task, handle_load_peral, LoadPearl}; pub mod pearl; diff --git a/aether-core/src/commands/pearl/load.rs b/aether-core/src/commands/pearl/load.rs index 8104216..c8bd2ae 100644 --- a/aether-core/src/commands/pearl/load.rs +++ b/aether-core/src/commands/pearl/load.rs @@ -1,10 +1,10 @@ use std::time::Duration; use azalea::chat::SendChatEvent; +use azalea::ecs::prelude::*; +use azalea::prelude::*; use azalea_anti_afk::config::AntiAFKConfig; use azalea_task_manager::{task_manager_queue::Task, AddTaskEvent}; -use azalea::prelude::*; -use azalea::ecs::prelude::*; use crate::{commands::ExecutingTask, config::Bot}; diff --git a/aether-core/src/discord.rs b/aether-core/src/discord.rs index f299b3b..5a9ca39 100644 --- a/aether-core/src/discord.rs +++ b/aether-core/src/discord.rs @@ -1,14 +1,16 @@ use azalea::app::{Plugin, Update}; -use azalea::chat::{ChatPacketKind, ChatReceivedEvent, SendChatKindEvent}; +use azalea::chat::{ChatPacket, ChatPacketKind, ChatReceivedEvent, SendChatKindEvent}; use azalea::ecs::prelude::*; use azalea::entity::metadata::Player; use azalea::entity::LocalEntity; use azalea::prelude::*; +use azalea::protocol::packets::game::clientbound_system_chat_packet::ClientboundSystemChatPacket; use bevy_discord::bot::events::BMessage; use bevy_discord::bot::serenity::all::ChannelId; use bevy_discord::bot::DiscordBotRes; use bevy_discord::runtime::tokio_runtime; use serde_json::json; +use std::sync::Arc; use tracing::error; use crate::chat::handle_chat; @@ -32,7 +34,11 @@ impl Plugin for AetherDiscordPlugin { fn build(&self, app: &mut azalea::app::App) { app.add_systems( Update, - (handle_chat_relay, handle_discord_bridge) + ( + handle_chat_relay, + handle_discord_bridge, + handle_disocrd_channel_id, + ) .chain() .after(handle_chat), ); @@ -74,6 +80,7 @@ fn handle_chat_relay( } } +#[allow(clippy::complexity)] fn handle_discord_bridge( mut events: EventReader, query: Query<(&DiscordChatRelay, Entity), (With, With)>, @@ -95,3 +102,40 @@ fn handle_discord_bridge( } } } + +#[allow(clippy::complexity)] +fn handle_disocrd_channel_id( + mut events: EventReader, + query: Query<(&DiscordChannelId, Entity), (With, With)>, + mut chat_received_event: EventWriter, +) { + for BMessage { + ctx: _, + new_message, + } in events.read() + { + for (DiscordChannelId { channel_id }, entity) in query.iter() { + if !new_message.author.bot && &new_message.channel_id == channel_id { + match new_message + .content + .split_whitespace() + .collect::>() + .as_slice() + { + ["!pearl", "load", username] => { + chat_received_event.send(ChatReceivedEvent { + entity, + packet: ChatPacket::System(Arc::new(ClientboundSystemChatPacket { + overlay: true, + content: format!("{} whispers: !pearl load", username).into(), + })), + }); + } + _ => { + error!("Invalid Discord Command") + } + } + } + } + } +}