Browse Source

Fix DM loading / commands in DMs

pull/6/head
Andrei 9 years ago
parent
commit
231f595227
  1. 8
      disco/bot/bot.py
  2. 1
      disco/gateway/events.py
  3. 4
      disco/state.py
  4. 3
      disco/types/user.py

8
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

1
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):

4
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(

3
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)

Loading…
Cancel
Save