Skip to content

Commit 5a26c28

Browse files
committed
Config help on protected keys
1 parent 92fad07 commit 5a26c28

File tree

4 files changed

+87
-10
lines changed

4 files changed

+87
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ however, insignificant breaking changes does not guarantee a major version bump,
1212

1313
- `disable_recipient_thread_close` is removed, a new configuration variable `recipient_thread_close` replaces it which defaults to False.
1414
- Truthy and falsy values for binary configuration variables are now interpreted respectfully.
15+
- `LOG_URL_PREFIX` cannot be set to "NONE" to specify no additional path in the future, "/" is the new method.
1516

1617
### Added
1718

cogs/modmail.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,9 @@ def format_log_embeds(self, logs, avatar_url):
572572
for entry in logs:
573573
created_at = parser.parse(entry["created_at"])
574574

575-
prefix = self.bot.config['log_url_prefix'].strip('/')
576-
if prefix == 'NONE':
577-
prefix = ''
575+
prefix = self.bot.config["log_url_prefix"].strip("/")
576+
if prefix == "NONE":
577+
prefix = ""
578578
log_url = f"{self.bot.config['log_url'].strip('/')}{'/' + prefix if prefix else ''}/{entry['key']}"
579579

580580
username = entry["recipient"]["name"] + "#"

cogs/utility.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,9 @@ async def config_get(self, ctx, key: str.lower = None):
844844
color=Color.red(),
845845
description=f"`{key}` is an invalid key.",
846846
)
847-
valid_keys = [f"`{k}`" for k in keys]
848-
embed.add_field(name="Valid keys", value=", ".join(valid_keys))
847+
embed.set_footer(
848+
text=f'Type "{self.bot.prefix}config options" for a list of config variables.'
849+
)
849850

850851
else:
851852
embed = Embed(
@@ -870,7 +871,9 @@ async def config_help(self, ctx, key: str.lower):
870871
"""
871872
Show information on a specified configuration.
872873
"""
873-
if key not in self.bot.config.public_keys:
874+
if not (
875+
key in self.bot.config.public_keys or key in self.bot.config.protected_keys
876+
):
874877
embed = Embed(
875878
title="Error",
876879
color=Color.red(),
@@ -904,10 +907,11 @@ def fmt(val):
904907
embed.add_field(
905908
name="Information:", value=fmt(info["description"]), inline=False
906909
)
907-
example_text = ""
908-
for example in info["examples"]:
909-
example_text += f"- {fmt(example)}\n"
910-
embed.add_field(name="Example(s):", value=example_text, inline=False)
910+
if info["examples"]:
911+
example_text = ""
912+
for example in info["examples"]:
913+
example_text += f"- {fmt(example)}\n"
914+
embed.add_field(name="Example(s):", value=example_text, inline=False)
911915

912916
note_text = ""
913917
for note in info["notes"]:

core/config_help.json

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,5 +373,77 @@
373373
"See also: `anon_avatar_url`, `anon_username`, `mod_tag`."
374374
],
375375
"image": "https://i.imgur.com/SKOC42Z.png"
376+
},
377+
"modmail_guild_id": {
378+
"default": "Fallback on `GUILD_ID`",
379+
"description": "The ID of the discord server where the threads channels should be created (receiving server).",
380+
"examples": [
381+
],
382+
"notes": [
383+
"This configuration can only to be set through `.env` file or environment (config) variables."
384+
]
385+
},
386+
"guild_id": {
387+
"default": "None, required",
388+
"description": "The ID of the discord server where recipient users reside (users server).",
389+
"examples": [
390+
],
391+
"notes": [
392+
"This configuration can only to be set through `.env` file or environment (config) variables."
393+
]
394+
},
395+
"log_url": {
396+
"default": "https://example.com/",
397+
"description": "The base log viewer URL link, leave this as-is to not configure a log viewer.",
398+
"examples": [
399+
],
400+
"notes": [
401+
"This configuration can only to be set through `.env` file or environment (config) variables."
402+
]
403+
},
404+
"log_url_prefix": {
405+
"default": "`/logs`",
406+
"description": "The path to your log viewer extending from your `LOG_URL`, set this to `/` to specify no extra path to the log viewer.",
407+
"examples": [
408+
],
409+
"notes": [
410+
"This configuration can only to be set through `.env` file or environment (config) variables."
411+
]
412+
},
413+
"mongo_uri": {
414+
"default": "None, required",
415+
"description": "A MongoDB SRV connection string.",
416+
"examples": [
417+
],
418+
"notes": [
419+
"This configuration can only to be set through `.env` file or environment (config) variables."
420+
]
421+
},
422+
"owners": {
423+
"default": "None, required",
424+
"description": "A list of definite bot owners, use `{prefix}perms add level OWNER @user` to set flexible bot owners.",
425+
"examples": [
426+
],
427+
"notes": [
428+
"This configuration can only to be set through `.env` file, ~~`config.json` file~~ (removed), or environment (config) variables."
429+
]
430+
},
431+
"token": {
432+
"default": "None, required",
433+
"description": "Your bot token as found in the Discord Developer Portal.",
434+
"examples": [
435+
],
436+
"notes": [
437+
"This configuration can only to be set through `.env` file, ~~`config.json` file~~ (removed), or environment (config) variables."
438+
]
439+
},
440+
"log_level": {
441+
"default": "INFO",
442+
"description": "The logging level for logging to stdout.",
443+
"examples": [
444+
],
445+
"notes": [
446+
"This configuration can only to be set through `.env` file, ~~`config.json` file~~ (removed), or environment (config) variables."
447+
]
376448
}
377449
}

0 commit comments

Comments
 (0)