diff --git a/disco/bot/bot.py b/disco/bot/bot.py index d5751cd..292332e 100644 --- a/disco/bot/bot.py +++ b/disco/bot/bot.py @@ -237,13 +237,17 @@ class Bot(object): if self.config.commands_require_mention: mention_direct = msg.is_mentioned(self.client.state.me) mention_everyone = msg.mention_everyone - mention_roles = list(filter(lambda r: msg.is_mentioned(r), - msg.guild.get_member(self.client.state.me).roles)) + + mention_roles = [] + if msg.guild: + mention_roles = list(filter(lambda r: msg.is_mentioned(r), + msg.guild.get_member(self.client.state.me).roles)) if not any(( self.config.commands_mention_rules['user'] and mention_direct, self.config.commands_mention_rules['everyone'] and mention_everyone, self.config.commands_mention_rules['role'] and any(mention_roles), + msg.channel.is_dm )): raise StopIteration diff --git a/disco/gateway/events.py b/disco/gateway/events.py index 67921b0..f0726b3 100644 --- a/disco/gateway/events.py +++ b/disco/gateway/events.py @@ -107,6 +107,7 @@ class Ready(GatewayEvent): session_id = Field(str) user = Field(User) guilds = Field(listof(Guild)) + private_channels = Field(listof(Channel)) class Resumed(GatewayEvent): diff --git a/disco/state.py b/disco/state.py index 5780e96..a08c983 100644 --- a/disco/state.py +++ b/disco/state.py @@ -141,6 +141,10 @@ class State(object): self.me = event.user self.guilds_waiting_sync = len(event.guilds) + for dm in event.private_channels: + self.dms[dm.id] = dm + self.channels[dm.id] = dm + def on_message_create(self, event): if self.config.track_messages: self.messages[event.message.channel_id].append( diff --git a/disco/types/user.py b/disco/types/user.py index 3e3fc9b..cad2cb8 100644 --- a/disco/types/user.py +++ b/disco/types/user.py @@ -6,8 +6,9 @@ from disco.types.base import SlottedModel, Field, snowflake, text, binary, with_ class User(SlottedModel, with_equality('id'), with_hash('id')): id = Field(snowflake) username = Field(text) - discriminator = Field(str) avatar = Field(binary) + discriminator = Field(str) + bot = Field(bool) verified = Field(bool) email = Field(str)