From c8937e60c303ecdbb0fb2ac71fdeaea9584961e2 Mon Sep 17 00:00:00 2001 From: Conatum Date: Sat, 7 Oct 2023 23:47:04 +0300 Subject: [PATCH] fix(shop): Handle unusual error status. --- src/modules/shop/shops/colours.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/shop/shops/colours.py b/src/modules/shop/shops/colours.py index a2add0ed..35f5c040 100644 --- a/src/modules/shop/shops/colours.py +++ b/src/modules/shop/shops/colours.py @@ -446,7 +446,7 @@ class ColourShopping(ShopCog): ), ephemeral=True ) - await logger.warning( + logger.warning( "Unexpected Discord exception occurred while creating a colour role.", exc_info=True ) @@ -469,8 +469,13 @@ class ColourShopping(ShopCog): # Due to the imprecise nature of Discord role ordering, this may fail. try: role = await role.edit(position=position) - except discord.Forbidden: - position = 0 + except discord.HTTPException as e: + if e.code == 50013 or e.status == 403: + # Forbidden case + # But Discord sends its 'Missing Permissions' with a 400 code for position issues + position = 0 + else: + raise # Now that the role is set up, add it to data item = await self.data.ShopItem.create(