# The bot depends on this patch to handle rate limits with the uploading of emoji # There isn't a cleaner way to do this as of right now... diff --git a/discord/guild.py b/discord/guild.py index 6982356..d6cd907 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -1209,6 +1209,8 @@ class Guild(Hashable): if roles: roles = [role.id for role in roles] data = await self._state.http.create_custom_emoji(self.id, name, img, roles=roles, reason=reason) + if isinstance(data, int): + return data return self._state.store_emoji(self, data) async def create_role(self, *, reason=None, **fields): diff --git a/discord/http.py b/discord/http.py index b103a7e..0c21f4c 100644 --- a/discord/http.py +++ b/discord/http.py @@ -183,6 +183,9 @@ class HTTPClient: if r.status == 429: fmt = 'We are being rate limited. Retrying in %.2f seconds. Handled under the bucket "%s"' + if bucket.endswith(":/guilds/{guild_id}/emojis"): + return data["retry_after"] + # sleep a bit retry_after = data['retry_after'] / 1000.0 log.warning(fmt, retry_after, bucket)