Allow Guild.create_role to accept an int as the colour parameter.

This commit is contained in:
Alex Nørgaard 2020-12-25 07:22:59 +00:00 committed by GitHub
parent c5a76588cd
commit 624a9c8687
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1736,7 +1736,7 @@ class Guild(Hashable):
The role name. Defaults to 'new role'. The role name. Defaults to 'new role'.
permissions: :class:`Permissions` permissions: :class:`Permissions`
The permissions to have. Defaults to no permissions. The permissions to have. Defaults to no permissions.
colour: :class:`Colour` colour: Union[:class:`Colour`, :class:`int`]
The colour for the role. Defaults to :meth:`Colour.default`. The colour for the role. Defaults to :meth:`Colour.default`.
This is aliased to ``color`` as well. This is aliased to ``color`` as well.
hoist: :class:`bool` hoist: :class:`bool`
@ -1775,6 +1775,8 @@ class Guild(Hashable):
except KeyError: except KeyError:
colour = fields.get('color', Colour.default()) colour = fields.get('color', Colour.default())
finally: finally:
if isinstance(colour, int):
colour = Colour(value=colour)
fields['color'] = colour.value fields['color'] = colour.value
valid_keys = ('name', 'permissions', 'color', 'hoist', 'mentionable') valid_keys = ('name', 'permissions', 'color', 'hoist', 'mentionable')