From 63ec23bac24ab62633bdb8fd19b93ecd3fddba7c Mon Sep 17 00:00:00 2001 From: Nadir Chowdhury Date: Thu, 25 Feb 2021 02:26:51 +0000 Subject: Code optimisations and refactoring via Sourcery --- discord/client.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'discord/client.py') diff --git a/discord/client.py b/discord/client.py index 85035535..8ea1cf30 100644 --- a/discord/client.py +++ b/discord/client.py @@ -754,9 +754,7 @@ class Client: @allowed_mentions.setter def allowed_mentions(self, value): - if value is None: - self._connection.allowed_mentions = value - elif isinstance(value, AllowedMentions): + if value is None or isinstance(value, AllowedMentions): self._connection.allowed_mentions = value else: raise TypeError('allowed_mentions must be AllowedMentions not {0.__class__!r}'.format(value)) @@ -1227,15 +1225,13 @@ class Client: if icon is not None: icon = utils._bytes_to_base64_data(icon) - if region is None: - region = VoiceRegion.us_west.value - else: - region = region.value + region = region or VoiceRegion.us_west + region_value = region.value if code: - data = await self.http.create_from_template(code, name, region, icon) + data = await self.http.create_from_template(code, name, region_value, icon) else: - data = await self.http.create_guild(name, region, icon) + data = await self.http.create_guild(name, region_value, icon) return Guild(data=data, state=self._connection) # Invite management -- cgit v1.2.3