diff --git a/discord/errors.py b/discord/errors.py index 6035ace7c20f..6605fd77368d 100644 --- a/discord/errors.py +++ b/discord/errors.py @@ -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. diff --git a/discord/webhook/async_.py b/discord/webhook/async_.py index 9ce18bbe49d8..bda9423e4708 100644 --- a/discord/webhook/async_.py +++ b/discord/webhook/async_.py @@ -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 @@ -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)