Change internal role storage in Guild to a dict instead of a list.

This adds the following APIs:

* Guild.get_role

This removes the following APIs:

* Guild.role_hierarchy

To compensate for the removed APIs, Guild.roles is now a sorted list
based on hierarchy. The first element will always be the @everyone
role.

This speeds up access at the cost of some memory, theoretically.
This commit is contained in:
Rapptz
2018-09-24 21:05:41 -04:00
parent 12cb074316
commit 3d03dbc451
9 changed files with 61 additions and 46 deletions

View File

@ -368,11 +368,17 @@ They will be enumerated here.
- Use :attr:`Member.activity` instead.
- ``Guild.role_hierarchy`` / ``Server.role_hierarchy``
- Use :attr:`Guild.roles` instead. Note that while sorted, it is in the opposite order
of what the old ``Guild.role_hierarchy`` used to be.
**Changed**
- :attr:`Member.avatar_url` and :attr:`User.avatar_url` now return the default avatar if a custom one is not set.
- :attr:`Message.embeds` is now a list of :class:`Embed` instead of ``dict`` objects.
- :attr:`Message.attachments` is now a list of :class:`Attachment` instead of ``dict`` object.
- :attr:`Guild.roles` is now sorted through hierarchy. The first element is always the ``@everyone`` role.
**Added**
@ -398,6 +404,7 @@ They will be enumerated here.
- :attr:`Message.activity` and :attr:`Message.application` for Rich Presence related information.
- :meth:`TextChannel.is_nsfw` to check if a text channel is NSFW.
- :meth:`Colour.from_rgb` to construct a :class:`Colour` from RGB tuple.
- :meth:`Guild.get_role` to get a role by its ID.
.. _migrating_1_0_sending_messages: