diff options
| author | acdenisSK <[email protected]> | 2017-09-30 14:38:20 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-09-30 14:38:20 +0200 |
| commit | 336916865633fd6c69870db2f8d77ba0a7ea4a90 (patch) | |
| tree | 34f485fc5d41adfbd1c8810ae5fcb165f5e419f9 /src/framework | |
| parent | Change the way users' command handlers are stored as (diff) | |
| parent | Fix a few things with the framework trait (diff) | |
| download | serenity-336916865633fd6c69870db2f8d77ba0a7ea4a90.tar.xz serenity-336916865633fd6c69870db2f8d77ba0a7ea4a90.zip | |
Merge branch 'v0.4.1' into v0.5.0
Diffstat (limited to 'src/framework')
| -rw-r--r-- | src/framework/mod.rs | 30 | ||||
| -rw-r--r-- | src/framework/standard/mod.rs | 2 |
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 } } |