Skip to content

Commit 3534b23

Browse files
AstreaTSSLordOfPolls
authored andcommitted
feat: allow disabling autodefer through auto_defer methods (#1296)
* feat: allow disabling autodefer through auto_defer methods * fix: oops --------- Co-authored-by: Astrea49 <25420078+Astrea49@users.noreply.github.com>
1 parent ce3f355 commit 3534b23

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

interactions/models/internal/application_commands.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,11 +1252,14 @@ def wrapper(func: SlashCommandT) -> SlashCommandT:
12521252
return wrapper
12531253

12541254

1255-
def auto_defer(ephemeral: bool = False, time_until_defer: float = 0.0) -> Callable[[InterCommandT], InterCommandT]:
1255+
def auto_defer(
1256+
enabled: bool = True, ephemeral: bool = False, time_until_defer: float = 0.0
1257+
) -> Callable[[InterCommandT], InterCommandT]:
12561258
"""
12571259
A decorator to add an auto defer to a application command.
12581260
12591261
Args:
1262+
enabled: Should the command be deferred automatically
12601263
ephemeral: Should the command be deferred as ephemeral
12611264
time_until_defer: How long to wait before deferring automatically
12621265
@@ -1265,7 +1268,7 @@ def auto_defer(ephemeral: bool = False, time_until_defer: float = 0.0) -> Callab
12651268
def wrapper(func: InterCommandT) -> InterCommandT:
12661269
if hasattr(func, "cmd_id"):
12671270
raise ValueError("auto_defer decorators must be positioned under a slash_command decorator")
1268-
func.auto_defer = AutoDefer(enabled=True, ephemeral=ephemeral, time_until_defer=time_until_defer)
1271+
func.auto_defer = AutoDefer(enabled=enabled, ephemeral=ephemeral, time_until_defer=time_until_defer)
12691272
return func
12701273

12711274
return wrapper

interactions/models/internal/extension.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,17 @@ def drop(self) -> None:
167167
self.bot.dispatch(events.ExtensionUnload(self))
168168
self.bot.logger.debug(f"{self.name} has been drop")
169169

170-
def add_ext_auto_defer(self, ephemeral: bool = False, time_until_defer: float = 0.0) -> None:
170+
def add_ext_auto_defer(self, enabled: bool = True, ephemeral: bool = False, time_until_defer: float = 0.0) -> None:
171171
"""
172172
Add a auto defer for all commands in this extension.
173173
174174
Args:
175+
enabled: Should the command be deferred automatically
175176
ephemeral: Should the command be deferred as ephemeral
176177
time_until_defer: How long to wait before deferring automatically
177178
178179
"""
179-
self.auto_defer = models.AutoDefer(enabled=True, ephemeral=ephemeral, time_until_defer=time_until_defer)
180+
self.auto_defer = models.AutoDefer(enabled=enabled, ephemeral=ephemeral, time_until_defer=time_until_defer)
180181

181182
def add_ext_check(self, coroutine: Callable[["BaseContext"], Awaitable[bool]]) -> None:
182183
"""

0 commit comments

Comments
 (0)