aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/channel.py2
-rw-r--r--discord/colour.py4
-rw-r--r--discord/invite.py4
-rw-r--r--discord/member.py6
-rw-r--r--discord/message.py2
-rw-r--r--discord/mixins.py4
-rw-r--r--discord/permissions.py3
-rw-r--r--discord/role.py7
-rw-r--r--discord/state.py1
-rw-r--r--discord/user.py12
10 files changed, 33 insertions, 12 deletions
diff --git a/discord/channel.py b/discord/channel.py
index b342d9e7..814e940f 100644
--- a/discord/channel.py
+++ b/discord/channel.py
@@ -225,6 +225,8 @@ class PrivateChannel(Hashable):
``True`` if the channel is a private channel (i.e. PM). ``True`` in this case.
"""
+ __slots__ = ['user', 'id', 'is_private']
+
def __init__(self, user, id, **kwargs):
self.user = user
self.id = id
diff --git a/discord/colour.py b/discord/colour.py
index 67137cb4..ae6bab87 100644
--- a/discord/colour.py
+++ b/discord/colour.py
@@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
-class Colour(object):
+class Colour:
"""Represents a Discord role colour. This class is similar
to an (red, green, blue) tuple.
@@ -50,6 +50,8 @@ class Colour(object):
The raw integer colour value.
"""
+ __slots__ = [ 'value' ]
+
def __init__(self, value):
self.value = value
diff --git a/discord/invite.py b/discord/invite.py
index ad6b2673..d28d80c4 100644
--- a/discord/invite.py
+++ b/discord/invite.py
@@ -75,6 +75,10 @@ class Invite(Hashable):
The channel the invite is for.
"""
+
+ __slots__ = [ 'max_age', 'code', 'server', 'revoked', 'created_at', 'uses',
+ 'temporary', 'max_uses', 'xkcd', 'inviter', 'channel' ]
+
def __init__(self, **kwargs):
self.max_age = kwargs.get('max_age')
self.code = kwargs.get('code')
diff --git a/discord/member.py b/discord/member.py
index 5c151e9f..684aab2d 100644
--- a/discord/member.py
+++ b/discord/member.py
@@ -64,8 +64,12 @@ class Member(User):
The server that the member belongs to.
"""
+ __slots__ = [ 'deaf', 'mute', 'self_mute', 'self_deaf', 'is_afk',
+ 'voice_channel', 'roles', 'joined_at', 'status', 'game_id',
+ 'server' ]
+
def __init__(self, deaf, joined_at, user, roles, mute, **kwargs):
- super(Member, self).__init__(**user)
+ super().__init__(**user)
self.deaf = deaf
self.mute = mute
self.joined_at = parse_time(joined_at)
diff --git a/discord/message.py b/discord/message.py
index b94d50c2..8981de2c 100644
--- a/discord/message.py
+++ b/discord/message.py
@@ -30,7 +30,7 @@ from .member import Member
from .object import Object
import re
-class Message(object):
+class Message:
"""Represents a message from Discord.
There should be no need to create one of these manually.
diff --git a/discord/mixins.py b/discord/mixins.py
index cdbd67d7..f6f641d5 100644
--- a/discord/mixins.py
+++ b/discord/mixins.py
@@ -25,6 +25,8 @@ DEALINGS IN THE SOFTWARE.
"""
class EqualityComparable:
+ __slots__ = []
+
def __eq__(self, other):
return isinstance(other, self.__class__) and other.id == self.id
@@ -34,5 +36,7 @@ class EqualityComparable:
return True
class Hashable(EqualityComparable):
+ __slots__ = []
+
def __hash__(self):
return hash(self.id)
diff --git a/discord/permissions.py b/discord/permissions.py
index ee0ad555..d9426693 100644
--- a/discord/permissions.py
+++ b/discord/permissions.py
@@ -24,7 +24,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
-class Permissions(object):
+class Permissions:
"""Wraps up the Discord permission value.
Supported operations:
@@ -50,6 +50,7 @@ class Permissions(object):
were regular bools. This allows you to edit permissions.
"""
+ __slots__ = [ 'value' ]
def __init__(self, permissions=0, **kwargs):
self.value = permissions
diff --git a/discord/role.py b/discord/role.py
index a78a4af7..7b4c1d5e 100644
--- a/discord/role.py
+++ b/discord/role.py
@@ -53,8 +53,8 @@ class Role(Hashable):
The name of the role.
permissions : :class:`Permissions`
Represents the role's permissions.
- color : :class:`Colour`
- Represents the role colour.
+ colour : :class:`Colour`
+ Represents the role colour. An alias exists under ``color``.
hoist : bool
Indicates if the role will be displayed separately from other members.
position : int
@@ -64,6 +64,9 @@ class Role(Hashable):
integrations such as Twitch.
"""
+ __slots__ = ['id', 'name', 'permissions', 'color', 'colour', 'position',
+ 'managed', '_is_everyone', 'hoist' ]
+
def __init__(self, **kwargs):
self._is_everyone = kwargs.get('everyone', False)
self.update(**kwargs)
diff --git a/discord/state.py b/discord/state.py
index a4ba1526..07c71039 100644
--- a/discord/state.py
+++ b/discord/state.py
@@ -81,7 +81,6 @@ class ConnectionState:
self.messages.append(message)
def parse_message_delete(self, data):
- channel = self.get_channel(data.get('channel_id'))
message_id = data.get('id')
found = self._get_message(message_id)
if found is not None:
diff --git a/discord/user.py b/discord/user.py
index d2f149c3..85e43ba4 100644
--- a/discord/user.py
+++ b/discord/user.py
@@ -53,11 +53,13 @@ class User:
The avatar hash the user has. Could be None.
"""
- def __init__(self, username, id, discriminator, avatar, **kwargs):
- self.name = username
- self.id = id
- self.discriminator = discriminator
- self.avatar = avatar
+ __slots__ = ['name', 'id', 'discriminator', 'avatar']
+
+ def __init__(self, **kwargs):
+ self.name = kwargs.get('username')
+ self.id = kwargs.get('id')
+ self.discriminator = kwargs.get('discriminator')
+ self.avatar = kwargs.get('avatar')
def __str__(self):
return self.name