aboutsummaryrefslogtreecommitdiff
path: root/src/framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/framework')
-rw-r--r--src/framework/mod.rs30
-rw-r--r--src/framework/standard/mod.rs2
2 files changed, 23 insertions, 9 deletions
diff --git a/src/framework/mod.rs b/src/framework/mod.rs
index 0641ab6..a5f458d 100644
--- a/src/framework/mod.rs
+++ b/src/framework/mod.rs
@@ -67,17 +67,33 @@ use model::Message;
use model::UserId;
/// This trait allows for serenity to either use its builtin framework, or yours.
-///
-/// When implementing, be sure to use `tokio_handle.spawn_fn(|| ...; Ok())` when dispatching
-/// commands.
-///
-/// Note that you may see some other methods in here as well, but they're meant to be internal only
-/// for the builtin framework.
pub trait Framework {
fn dispatch(&mut self, Context, Message);
+ #[doc(hidden)]
#[cfg(feature = "standard_framework")]
fn update_current_user(&mut self, UserId, bool) {}
+}
+
+impl<F: Framework + ?Sized> Framework for Box<F> {
+ fn dispatch(&mut self, ctx: Context, msg: Message) {
+ (**self).dispatch(ctx, msg);
+ }
+
+ #[cfg(feature = "standard_framework")]
+ fn update_current_user(&mut self, id: UserId, is_bot: bool) {
+ (**self).update_current_user(id, is_bot);
+ }
+}
+
+impl<'a, F: Framework + ?Sized> Framework for &'a mut F {
+ fn dispatch(&mut self, ctx: Context, msg: Message) {
+ (**self).dispatch(ctx, msg);
+ }
+
#[cfg(feature = "standard_framework")]
- fn initialized(&self) -> bool { false }
+ fn update_current_user(&mut self, id: UserId, is_bot: bool) {
+ (**self).update_current_user(id, is_bot);
+ }
}
+
diff --git a/src/framework/standard/mod.rs b/src/framework/standard/mod.rs
index 1f4a33e..dc065f0 100644
--- a/src/framework/standard/mod.rs
+++ b/src/framework/standard/mod.rs
@@ -956,6 +956,4 @@ impl Framework for StandardFramework {
fn update_current_user(&mut self, user_id: UserId, is_bot: bool) {
self.user_info = (user_id.0, is_bot);
}
-
- fn initialized(&self) -> bool { self.initialized }
}