Skip to content

Commit 87106d5

Browse files
Raise error if deffered and already responded to
Added check to defer() Added AlreadyResponded error
1 parent 1fb34ce commit 87106d5

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

discord_slash/context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ async def defer(self, hidden: bool = False):
8686
8787
:param hidden: Whether the deffered response should be ephemeral . Default ``False``.
8888
"""
89+
if self._deffered or self._sent:
90+
raise error.AlreadyResponded("You have already responded to this command!")
8991
base = {"type": 5}
9092
if hidden:
9193
base["data"] = {"flags": 64}

discord_slash/error.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ class IncorrectType(SlashCommandError):
5454
"""
5555
Type passed was incorrect
5656
"""
57+
58+
class AlreadyResponded(SlashCommandError):
59+
"""
60+
The interaction was already responded to
61+
"""

0 commit comments

Comments
 (0)