Skip to content

Commit

Permalink
add IHateThe3SecondsTimeout exception
Browse files Browse the repository at this point in the history
  • Loading branch information
odrling committed Apr 1, 2024
1 parent f81c087 commit 044032a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions discord/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ def __init__(self, retry_after: float):
super().__init__(f'Too many requests. Retry in {retry_after:.2f} seconds.')


class IHateThe3SecondsTimeout(HTTPException):
"""Exception that is raised when an expired interaction token is used"""

pass


class Forbidden(HTTPException):
"""Exception that's raised for when status code 403 occurs.
Expand Down
6 changes: 3 additions & 3 deletions discord/webhook/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import aiohttp

from .. import utils
from ..errors import HTTPException, Forbidden, NotFound, DiscordServerError
from ..errors import HTTPException, Forbidden, DiscordServerError, IHateThe3SecondsTimeout
from ..message import Message
from ..enums import try_enum, WebhookType, ChannelType
from ..user import BaseUser, User
Expand Down Expand Up @@ -215,8 +215,8 @@ async def request(

if response.status == 403:
raise Forbidden(response, data)
elif response.status == 404:
raise NotFound(response, data)
elif response.status in (401, 404):
raise IHateThe3SecondsTimeout(response, data)
else:
raise HTTPException(response, data)

Expand Down

0 comments on commit 044032a

Please sign in to comment.