Skip to content

Commit 73f2ca6

Browse files
committed
Created confirm_thread_creation_timeout config
1 parent 389dfb6 commit 73f2ca6

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

core/config.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class ConfigManager:
122122
"react_to_contact_emoji": "\N{WHITE HEAVY CHECK MARK}",
123123
# confirm thread creation
124124
"confirm_thread_creation": False,
125+
"confirm_thread_creation_timeout": 20,
125126
"confirm_thread_creation_title": "Confirm thread creation",
126127
"confirm_thread_response": "React to confirm thread creation which will directly contact the moderators",
127128
"confirm_thread_creation_accept": "\N{WHITE HEAVY CHECK MARK}",
@@ -186,6 +187,10 @@ class ConfigManager:
186187

187188
time_deltas = {"account_age", "guild_age", "thread_auto_close", "thread_cooldown"}
188189

190+
ints = {
191+
"confirm_thread_creation_timeout",
192+
}
193+
189194
booleans = {
190195
"use_user_id_channel_name",
191196
"use_timestamp_channel_name",
@@ -319,6 +324,13 @@ def get(self, key: str, *, convert: bool = True) -> typing.Any:
319324
logger.error("Invalid %s provided.", key)
320325
value = int(self.remove(key).lstrip("#"), base=16)
321326

327+
elif key in self.ints:
328+
try:
329+
return int(value)
330+
except ValueError:
331+
logger.error("Invalid %s provided.", key)
332+
value = int(self.remove(key))
333+
322334
elif key in self.time_deltas:
323335
if not isinstance(value, isodate.Duration):
324336
try:

core/config_help.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,17 @@
10001000
"`{prefix}config set confirm_thread_creation yes`"
10011001
],
10021002
"notes": [
1003-
"See also: `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny`"
1003+
"See also: `confirm_thread_creation_timeout`, `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny`"
1004+
]
1005+
},
1006+
"confirm_thread_creation_timeout": {
1007+
"default": "20",
1008+
"description": "How long the user has to confirm thread creation before the request times out",
1009+
"examples":[
1010+
"`{prefix}config set confirm_thread_creation_timeout 30`"
1011+
],
1012+
"notes": [
1013+
"See also: `confirm_thread_creation`, `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny`"
10041014
]
10051015
},
10061016
"confirm_thread_creation_title": {
@@ -1010,7 +1020,7 @@
10101020
"`{prefix}config set confirm_thread_creation_title Are you sure you want to create a new thread?`"
10111021
],
10121022
"notes": [
1013-
"See also: `confirm_thread_creation`, `confirm_thread_response`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny`"
1023+
"See also: `confirm_thread_creation`, `confirm_thread_creation_timeout`, `confirm_thread_response`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny`"
10141024
]
10151025
},
10161026
"confirm_thread_response": {
@@ -1020,18 +1030,18 @@
10201030
"`{prefix}config set confirm_thread_response React to confirm`"
10211031
],
10221032
"notes": [
1023-
"See also: `confirm_thread_creation`, `confirm_thread_creation_title`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny`"
1033+
"See also: `confirm_thread_creation`, `confirm_thread_creation_timeout`, `confirm_thread_creation_title`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny`"
10241034
]
10251035
},
10261036
"confirm_thread_creation_accept": {
10271037
"default": "\u2705",
10281038
"description": "Emoji to accept a thread creation",
1029-
"examples":[
1039+
"examples": [
10301040
"`{prefix}config set confirm_thread_creation_accept \u2611`"
10311041
],
10321042
"notes": [
10331043
"This has no effect unless `confirm_thread_creation` is set",
1034-
"See also: `confirm_thread_creation`, `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_deny`"
1044+
"See also: `confirm_thread_creation`, `confirm_thread_creation_timeout`, `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_deny`"
10351045
]
10361046
},
10371047
"confirm_thread_creation_deny": {
@@ -1042,7 +1052,7 @@
10421052
],
10431053
"notes": [
10441054
"This has no effect unless `confirm_thread_creation` is set",
1045-
"See also: `confirm_thread_creation`, `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_accept`"
1055+
"See also: `confirm_thread_creation`, `confirm_thread_creation_timeout`, `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_accept`"
10461056
]
10471057
},
10481058
"use_regex_autotrigger": {

core/thread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1437,7 +1437,7 @@ async def create(
14371437
and r.message.id == confirm.id
14381438
and r.message.channel.id == confirm.channel.id
14391439
and str(r.emoji) in (accept_emoji, deny_emoji),
1440-
timeout=20,
1440+
timeout=self.bot.config["confirm_thread_creation_timeout"],
14411441
)
14421442
except asyncio.TimeoutError:
14431443
thread.cancelled = True

0 commit comments

Comments
 (0)