fix: resolve issue with iterating through``NoneType``s
@@ -520,6 +520,8 @@ class Guild(ClientSerializerMixin, IDMixin):
reason=reason,
payload=payload,
)
+ if self.roles is None:
+ self.roles = []
role = Role(**res, _client=self._client)
self.roles.append(role)
return role
@@ -543,6 +545,8 @@ class Guild(ClientSerializerMixin, IDMixin):
member_id=int(member_id),
)
member = Member(**res, _client=self._client)
+ if self.members is None:
+ self.members = []
for index, _member in enumerate(self.members):
if int(_member.id) == int(member_id):
self.members[index] = member
@@ -672,6 +676,8 @@ class Guild(ClientSerializerMixin, IDMixin):
reason=reason,
)
_role = Role(**res, _client=self._client)
+ if self.roles is None:
+ self.roles = []
for index, item in enumerate(self.roles):
if int(item.id) == int(role.id):
self.roles[index] = _role
@@ -835,6 +841,8 @@ class Guild(ClientSerializerMixin, IDMixin):
payload=payload,
)
+ if self.channels is None:
+ self.channels = []
channel = Channel(**res, _client=self._client)
self.channels.append(channel)
return channel
@@ -981,6 +989,9 @@ class Guild(ClientSerializerMixin, IDMixin):
_channel = Channel(**res, _client=self._client)
+ if self.channels is None:
+ self.channels = []
+
for index, item in enumerate(self.channels):
if int(item.id) == int(ch.id):
self.channels[index] = _channel
@@ -1054,7 +1065,8 @@ class Guild(ClientSerializerMixin, IDMixin):
)
_member = Member(**res, _client=self._client)
-
+ if self.members is None:
+ self.members = []
for index, member in enumerate(self.members):
if int(member.id) == _member_id:
self.members[index] = _member
@@ -1871,6 +1883,10 @@ class Guild(ClientSerializerMixin, IDMixin):
res = await self._client.get_guild_emoji(guild_id=int(self.id), emoji_id=emoji_id)
_emoji = Emoji(**res, _client=self._client)
+
+ if self.emojis is None:
+ self.emojis = []
+
for index, emoji in enumerate(self.emojis):
if int(emoji.id) == emoji_id:
self.emojis[index] = _emoji
@@ -1928,6 +1944,10 @@ class Guild(ClientSerializerMixin, IDMixin):
res = await self._client.create_guild_emoji(
guild_id=int(self.id), payload=payload, reason=reason
)
+
+ if self.emojis is None:
+ self.emojis = []
+
_emoji = Emoji(**res)
self.emojis.append(_emoji)
return _emoji
@@ -1985,6 +2005,8 @@ class Guild(ClientSerializerMixin, IDMixin):
guild_id=int(self.id), limit=limit, after=_after
)
_members = [Member(**member, _client=self._client) for member in res]
+ if self.members is None:
+ self.members = []
for member in _members:
if member not in self.members:
self.members.append(member)
