aboutsummaryrefslogtreecommitdiff
path: root/src/ext/framework/mod.rs
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2017-01-15 17:01:46 -0800
committerAustin Hellyer <[email protected]>2017-01-15 17:01:46 -0800
commit41b67c60bf3a6d87d6d80595bdaa00a8d9d0590a (patch)
tree9e3f8c80c367159d39bebfe40f75ee96c4597693 /src/ext/framework/mod.rs
parentDon't reconnect on WS error within some time (diff)
downloadserenity-41b67c60bf3a6d87d6d80595bdaa00a8d9d0590a.tar.xz
serenity-41b67c60bf3a6d87d6d80595bdaa00a8d9d0590a.zip
First round of deleting useless methods
Diffstat (limited to 'src/ext/framework/mod.rs')
-rw-r--r--src/ext/framework/mod.rs36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/ext/framework/mod.rs b/src/ext/framework/mod.rs
index 1e3927e..ccb81f1 100644
--- a/src/ext/framework/mod.rs
+++ b/src/ext/framework/mod.rs
@@ -78,6 +78,8 @@ use ::utils;
#[cfg(feature="cache")]
use ::client::CACHE;
+#[cfg(feature="cache")]
+use ::ext::cache::ChannelRef;
/// A macro to generate "named parameters". This is useful to avoid manually
/// using the "arguments" parameter and manually parsing types.
@@ -354,7 +356,7 @@ impl Framework {
return;
}
- if self.configuration.ignore_webhooks && message.is_webhook() {
+ if self.configuration.ignore_webhooks && message.webhook_id.is_some() {
return;
}
@@ -404,7 +406,15 @@ impl Framework {
#[cfg(feature="cache")]
{
- if let Some(guild_id) = message.guild_id() {
+
+ let guild_id = {
+ match CACHE.read().unwrap().get_channel(message.channel_id) {
+ Some(ChannelRef::Guild(channel)) => Some(channel.guild_id),
+ _ => None,
+ }
+ };
+
+ if let Some(guild_id) = guild_id {
if self.configuration.blocked_guilds.contains(&guild_id) {
if let Some(ref message) = self.configuration.blocked_guild_message {
let _ = context.say(message);
@@ -412,9 +422,7 @@ impl Framework {
return;
}
- }
- if let Some(guild_id) = message.guild_id() {
if let Some(guild) = guild_id.find() {
if self.configuration.blocked_users.contains(&guild.owner_id) {
if let Some(ref message) = self.configuration.blocked_guild_message {
@@ -499,9 +507,25 @@ impl Framework {
if !is_owner && !command.required_permissions.is_empty() {
let mut permissions_fulfilled = false;
- if let Some(member) = message.get_member() {
- let cache = CACHE.read().unwrap();
+ let cache = CACHE.read().unwrap();
+
+ // Really **really** dirty code in the meantime
+ // before the framework rewrite.
+ let member = {
+ let mut member_found = None;
+
+ if let Some(ChannelRef::Guild(channel)) = cache.get_channel(message.channel_id) {
+ if let Some(guild) = channel.guild_id.find() {
+ if let Some(member) = guild.members.get(&message.author.id) {
+ member_found = Some(member.clone());
+ }
+ }
+ }
+
+ member_found
+ };
+ if let Some(member) = member {
if let Ok(guild_id) = member.find_guild() {
if let Some(guild) = cache.get_guild(guild_id) {
let perms = guild.permissions_for(message.channel_id, message.author.id);