Skip to content

Commit

Permalink
use_nickname_channel_name, resolves #3112
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Nov 21, 2021
1 parent e44fb12 commit ec8fb29
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ however, insignificant breaking changes do not guarantee a major version bump, s
- `require_close_reason` config to require a reason to close a thread. ([GH #3107](https://github.com/kyb3r/modmail/issues/3107))
- `plain_snippets` config to force all snippets to be plain. ([GH #3083](https://github.com/kyb3r/modmail/issues/3083))
- `?fpareply` and `?fpreply` to reply to messages with variables plainly.
- `use_nickname_channel_name` config to use nicknames instead of usernames for channel names. ([GH #3112](https://github.com/kyb3r/modmail/issues/3112))

### Improved

Expand Down
9 changes: 7 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.11.0-dev2"
__version__ = "3.11.0-dev3"


import asyncio
Expand Down Expand Up @@ -1663,7 +1663,12 @@ def format_channel_name(self, author, exclude_channel=None, force_null=False):
elif self.config["use_timestamp_channel_name"]:
name = new_name = author.created_at.isoformat(sep="-", timespec="minutes")
else:
name = author.name.lower()
if self.config["use_nickname_channel_name"]:
author_member = self.guild.get_member(author.id)
name = author_member.display_name.lower()
else:
name = author.name.lower()

if force_null:
name = "null"

Expand Down
2 changes: 2 additions & 0 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ConfigManager:
"close_emoji": "\N{LOCK}",
"use_user_id_channel_name": False,
"use_timestamp_channel_name": False,
"use_nickname_channel_name": False,
"recipient_thread_close": False,
"thread_show_roles": True,
"thread_show_account_age": True,
Expand Down Expand Up @@ -184,6 +185,7 @@ class ConfigManager:
booleans = {
"use_user_id_channel_name",
"use_timestamp_channel_name",
"use_nickname_channel_name",
"user_typing",
"mod_typing",
"reply_without_command",
Expand Down
21 changes: 17 additions & 4 deletions core/config_help.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@
],
"notes": [
"This config is suitable for servers in Server Discovery to comply with channel name restrictions.",
"This cannot be applied with `use_timestamp_channel_name`.",
"See also: `use_timestamp_channel_name`."
"This cannot be applied with `use_timestamp_channel_name` or `use_nickname_channel_name`.",
"See also: `use_timestamp_channel_name`, `use_nickname_channel_name`."
]
},
"use_timestamp_channel_name": {
Expand All @@ -119,8 +119,21 @@
],
"notes": [
"This config is suitable for servers in Server Discovery to comply with channel name restrictions.",
"This cannot be applied with `use_user_id_channel_name`.",
"See also: `use_user_id_channel_name`."
"This cannot be applied with `use_user_id_channel_name` or `use_nickname_channel_name`.",
"See also: `use_user_id_channel_name`, `use_nickname_channel_name`."
]
},
"use_nickname_channel_name": {
"default": "No",
"description": "When this is set to `yes`, new thread channels will be named with the recipient's nickname instead of the recipient's name.",
"examples": [
"`{prefix}config set use_nickname_channel_name yes`",
"`{prefix}config set use_nickname_channel_name no`"
],
"notes": [
"This config is suitable for servers in Server Discovery to comply with channel name restrictions.",
"This cannot be applied with `use_timestamp_channel_name` or `use_user_id_channel_name`.",
"See also: `use_timestamp_channel_name`, `use_user_id_channel_name`."
]
},
"mod_typing": {
Expand Down

0 comments on commit ec8fb29

Please sign in to comment.