diff options
| author | acdenisSK <[email protected]> | 2017-07-07 16:21:34 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-07-07 16:21:34 +0200 |
| commit | cdedf36330aa6da9e59d296164090f54b651b874 (patch) | |
| tree | be2d18f9882debcdf549200462d27930382efc0f /src/client/dispatch.rs | |
| parent | Add an `is_new` to the arguments of the `guild_create` handler (diff) | |
| download | serenity-cdedf36330aa6da9e59d296164090f54b651b874.tar.xz serenity-cdedf36330aa6da9e59d296164090f54b651b874.zip | |
Apply the new api change for dms in bots
Diffstat (limited to 'src/client/dispatch.rs')
| -rw-r--r-- | src/client/dispatch.rs | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs index 7ff37d5..c1df0d2 100644 --- a/src/client/dispatch.rs +++ b/src/client/dispatch.rs @@ -6,7 +6,7 @@ use super::Context; use typemap::ShareMap; use ::gateway::Shard; use ::model::event::Event; -use ::model::{Message, Reaction, GuildId}; +use ::model::{Message, Reaction, GuildId, Channel}; use chrono::{Utc, Timelike}; #[cfg(feature="framework")] @@ -202,16 +202,32 @@ fn handle_event<H: EventHandler + Send + Sync + 'static>(event: Event, let context = context(conn, data); + // This different channel_create dispacthing is only due to the fact that + // each time the bot receives a dm, this event is also fired. + // So in short, only exists to reduce unnecessary clutter. let h = event_handler.clone(); - thread::spawn(move || h.on_channel_create(context, event.channel)); + match event.channel { + Channel::Private(channel) => { + thread::spawn(move || h.on_private_channel_create(context, channel)); + }, + Channel::Group(_) => {}, + Channel::Guild(channel) => { + thread::spawn(move || h.on_channel_create(context, channel)); + }, + } }, Event::ChannelDelete(event) => { update!(update_with_channel_delete, event); let context = context(conn, data); - let h = event_handler.clone(); - thread::spawn(move || h.on_channel_delete(context, event.channel)); + match event.channel { + Channel::Private(_) | Channel::Group(_) => {} + Channel::Guild(channel) => { + let h = event_handler.clone(); + thread::spawn(move || h.on_channel_delete(context, channel)); + }, + } }, Event::ChannelPinsUpdate(event) => { let context = context(conn, data); |