aboutsummaryrefslogtreecommitdiff
path: root/discord/state.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2015-12-29 11:59:18 -0500
committerRapptz <[email protected]>2015-12-29 11:59:18 -0500
commitc11bd9b8f4fa5b712249a6fcc97436edbfc5e022 (patch)
tree7ce37aa40745ec4eaf5cf71c9b9a59b0977fceb3 /discord/state.py
parentRaise ClientException if an unexpected websocket close happens (diff)
downloaddiscord.py-c11bd9b8f4fa5b712249a6fcc97436edbfc5e022.tar.xz
discord.py-c11bd9b8f4fa5b712249a6fcc97436edbfc5e022.zip
ConnectionState is now constructed in Client.__init__.
This should reduce the amount of checks for None if someone doesn't want a websocket connection. The connection state is instead cleared rather than reconstructed.
Diffstat (limited to 'discord/state.py')
-rw-r--r--discord/state.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/discord/state.py b/discord/state.py
index 99609959..87d381aa 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -40,13 +40,15 @@ import datetime
class ConnectionState:
def __init__(self, dispatch, max_messages):
+ self.max_messages = max_messages
+ self.dispatch = dispatch
+ self.clear()
+
+ def clear(self):
self.user = None
- self.email = None
self.servers = []
self.private_channels = []
- self.max_messages = max_messages
self.messages = deque(maxlen=self.max_messages)
- self.dispatch = dispatch
def _get_message(self, msg_id):
return utils.find(lambda m: m.id == msg_id, self.messages)