@@ -49,6 +49,11 @@ async def edit(self, _resp, bot_id, token, message_id="@original"):
49
49
req_url = f"https://discord.com/api/v8/webhooks/{ bot_id } /{ token } /messages/{ message_id } "
50
50
async with aiohttp .ClientSession () as session :
51
51
async with session .patch (req_url , json = _resp ) as resp :
52
+ if resp .status == 429 :
53
+ _json = await resp .json ()
54
+ self .logger .warning (f"We are being rate limited, retrying after { _json ['retry_after' ]} seconds." )
55
+ await asyncio .sleep (_json ["retry_after" ])
56
+ return await self .edit (_resp , bot_id , token , message_id )
52
57
if not 200 <= resp .status < 300 :
53
58
raise RequestFailure (resp .status , await resp .text ())
54
59
return True
@@ -66,6 +71,11 @@ async def delete(self, bot_id, token, message_id="@original"):
66
71
req_url = f"https://discord.com/api/v8/webhooks/{ bot_id } /{ token } /messages/{ message_id } "
67
72
async with aiohttp .ClientSession () as session :
68
73
async with session .delete (req_url ) as resp :
74
+ if resp .status == 429 :
75
+ _json = await resp .json ()
76
+ self .logger .warning (f"We are being rate limited, retrying after { _json ['retry_after' ]} seconds." )
77
+ await asyncio .sleep (_json ["retry_after" ])
78
+ return await self .delete (bot_id , token , message_id )
69
79
if not 200 <= resp .status < 300 :
70
80
raise RequestFailure (resp .status , await resp .text ())
71
81
return True
0 commit comments