Skip to content

Commit 6a4b4e8

Browse files
Cpt-Dingusajax146
andauthored
Duck timeout on miss is now a config (#1141)
* Ducks don't timeout anymore * unused import * Make duck timeout a config option --------- Co-authored-by: ajax146 <31014239+ajax146@users.noreply.github.com>
1 parent 34fc8a1 commit 6a4b4e8

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

techsupport_bot/commands/duck.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ async def setup(bot: bot.TechSupportBot) -> None:
6464
description="The amount of time to wait between bef/bang messages",
6565
default=5,
6666
)
67+
config.add(
68+
key="mute_for_cooldown",
69+
datatype="bool",
70+
title="Uses the timeout feature for cooldown",
71+
description="If enabled, users who miss will be timed out for the cooldown seconds",
72+
default=True,
73+
)
6774
config.add(
6875
key="success_rate",
6976
datatype="int",
@@ -376,17 +383,23 @@ def message_check(
376383
f"seconds. Time would have been {duration_exact} seconds"
377384
)
378385
)
379-
# Only attempt timeout if we know we can do it
386+
380387
if (
381-
channel.guild.me.top_role > message.author.top_role
382-
and channel.guild.me.guild_permissions.moderate_members
388+
config.extensions.duck.mute_for_cooldown.value
389+
and config.extensions.duck.cooldown.value > 0
383390
):
384-
asyncio.create_task(
385-
message.author.timeout(
386-
timedelta(seconds=config.extensions.duck.cooldown.value),
387-
reason="Missed a duck",
391+
# Only attempt timeout if we know we can do it
392+
if (
393+
channel.guild.me.top_role > message.author.top_role
394+
and channel.guild.me.guild_permissions.moderate_members
395+
):
396+
asyncio.create_task(
397+
message.author.timeout(
398+
timedelta(seconds=config.extensions.duck.cooldown.value),
399+
reason="Missed a duck",
400+
)
388401
)
389-
)
402+
390403
asyncio.create_task(
391404
message.channel.send(
392405
content=message.author.mention,

0 commit comments

Comments
 (0)