Skip to content

Commit daf04b0

Browse files
committed
New thread related config, resolves #3072
1 parent 68ede9d commit daf04b0

File tree

8 files changed

+119
-31
lines changed

8 files changed

+119
-31
lines changed

CHANGELOG.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
77
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.
88

9-
# v3.10.0-dev5
9+
# v3.10.0-dev6
1010

1111
v3.10 adds group conversations while resolving other bugs and QOL changes. It is potentially breaking to some plugins that adds functionality to threads.
1212

@@ -20,6 +20,7 @@ v3.10 adds group conversations while resolving other bugs and QOL changes. It is
2020
- Ability to have group conversations. ([GH #143](https://github.com/kyb3r/modmail/issues/143))
2121
- Snippets are invoked case insensitively. ([GH #3077](https://github.com/kyb3r/modmail/issues/3077), [PR #3080](https://github.com/kyb3r/modmail/pull/3080))
2222
- Default tags now use top hoisted role. ([GH #3014](https://github.com/kyb3r/modmail/issues/3014))
23+
- New thread-related config - `thread_show_roles`, `thread_show_account_age`, `thread_show_join_age`, `thread_cancelled`, `thread_creation_contact_title`, `thread_creation_self_contact_response`, `thread_creation_contact_response`. ([GH #3072](https://github.com/kyb3r/modmail/issues/3072))
2324

2425
### Fixed
2526

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<br>
77

88
<a href="#">
9-
<img src="https://img.shields.io/badge/Latest%20Version-v3.10.0-dev5-7289da?style=for-the-badge&logo=data:image/gif;base64,R0lGODlhGAAYAPcAAAAAADQ+Yj5MdThCaEFOekNQfWt5e1lqfEdVhVpriVx1iVtsnFZpll1xlF1znFx5mGNtjGR7hWNzjGd5iWJunGNslmN0lGl1lGN5lWt7lWR0nGp1nWR5nGt8nHJ9l3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0iVoqsI0ipXr1bhywfVXxYdiA3Sourz2dqc8lbNQJz4bDWqix73E7ZjhgrKOjYmvfWLbZcZqCdTPjjHGLdtibi2U5Q6NWiEqqq64ifvVe3at1nX2tTuWQ/QyIMfxHOGi+rkyeMklPMDuvWaBqlbj469IPUU2ykPCOw+53t4AAEBADs=">
9+
<img src="https://img.shields.io/badge/Latest%20Version-v3.10.0-dev6-7289da?style=for-the-badge&logo=data:image/gif;base64,R0lGODlhGAAYAPcAAAAAADQ+Yj5MdThCaEFOekNQfWt5e1lqfEdVhVpriVx1iVtsnFZpll1xlF1znFx5mGNtjGR7hWNzjGd5iWJunGNslmN0lGl1lGN5lWt7lWR0nGp1nWR5nGt8nHJ9l3J9jFxto1xtqlZqqF5zpF15pV10rVx5q1Z2ql1us150s114sV50uVd1smJupGNurGN0pGp1pGR6o2t7o2F0rml0rGR5rGt8q3J9pGNus2Fvu2Bzs2p2smR5s2t7tGF0u2N6vGp7u2l1uXJ+uGJ1wWV7w2l+xWl+yl5zwHWDiWyCmHODnHiGmHSLkW2CpGuEqnSCpHqMo3ODrHWKrXyMq3iHp3yTqGyEtWqFunKDs3uLtHSGvXSMvHuMu3eItnyTs3yTu3iUuW+RsV+ApmuCxG2Dy22LxnSMxHuMxHGGzXSLzXqLzXWFxXyTw3uSy3WSx26E0W+N2m+L1XKG03SL1XmL1HOL2HmL23WF2XiS1m+QyHOK4XmL4XaH4nGM5ImXm4WOlJSjnoOOq4OOpYSUrImXqJOcqYONt4OUtIybtIOUu4ycvImYt5OcuIyiqZekqYyiupOjvJurvJimtp+yvqKruae2ua23trLCucPHvIOMxoOUxIuaw4eYyJKbyISW1YiW0o2kyJWlxJqpxZWkzJury5aoxp6xxZ2zyZio1Jyy2Yuk0aOsyKOyxKOzzKy8zKq2yLO7xqOr1KSz1Ku706W026y73Ki21bK716u75LS95KSu4Zyx6bPDzLjGx63B2LPD1LTE3LvL3brI17/S2bbKzrTE47rF47zM5L3M67bH577R5L7R67zK8rjM8MLM3MPK1sTT3crU3MjW2dLZ2srUy8PN5MTO68nP68jL48TS5MnT5cbR68jS7M3b7Mva5dTb6MTO8srO8szF8MXR8snS8c3a8cnY+NXb9tDL7dnm6dzk8tro99Pq9uTp6+r17fr77eTr/efr+Oz09OXz/Ov0/e37/uj39fX19fX89fz+9vP1/fX9/f7//vr2/ODl4sK75yH5BAEAAAAALAAAAAAYABgAAAj/AAEAmFOnoMGDCAvGmRNHYMKHEOdIhEgRIcGKGDMeTJVO00WNBj194/frFik5IOvgqdaP371N26xpefORYq57/HI+s7Vtmy0eKCmmapcz575FPXt+SfHmociiRae1SroNWIoVTQ2uxAk15yJg1awl7ZSCaUE82uRxhTpt1TNXq0Ip2pSobIqCc0iVoqsI0ipXr1bhywfVXxYdiA3Sourz2dqc8lbNQJz4bDWqix73E7ZjhgrKOjYmvfWLbZcZqCdTPjjHGLdtibi2U5Q6NWiEqqq64ifvVe3at1nX2tTuWQ/QyIMfxHOGi+rkyeMklPMDuvWaBqlbj469IPUU2ykPCOw+53t4AAEBADs=">
1010
</a>
1111

1212
<br>

bot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "v3.10.0-dev5"
1+
__version__ = "v3.10.0-dev6"
22

33

44
import asyncio

cogs/modmail.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ async def adduser(self, ctx, *users_arg: Union[discord.Member, discord.Role, str
720720

721721
if not silent:
722722
description = self.bot.formatter.format(
723-
self.bot.config["private_added_to_group_description"], moderator=ctx.author
723+
self.bot.config["private_added_to_group_response"], moderator=ctx.author
724724
)
725725
em = discord.Embed(
726726
title=self.bot.config["private_added_to_group_title"],
@@ -734,7 +734,7 @@ async def adduser(self, ctx, *users_arg: Union[discord.Member, discord.Role, str
734734
await u.send(embed=em)
735735

736736
description = self.bot.formatter.format(
737-
self.bot.config["public_added_to_group_description"],
737+
self.bot.config["public_added_to_group_response"],
738738
moderator=ctx.author,
739739
users=", ".join(u.name for u in users),
740740
)
@@ -799,7 +799,7 @@ async def removeuser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
799799

800800
if not silent:
801801
description = self.bot.formatter.format(
802-
self.bot.config["private_removed_from_group_description"], moderator=ctx.author
802+
self.bot.config["private_removed_from_group_response"], moderator=ctx.author
803803
)
804804
em = discord.Embed(
805805
title=self.bot.config["private_removed_from_group_title"],
@@ -813,7 +813,7 @@ async def removeuser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
813813
await u.send(embed=em)
814814

815815
description = self.bot.formatter.format(
816-
self.bot.config["public_removed_from_group_description"],
816+
self.bot.config["public_removed_from_group_response"],
817817
moderator=ctx.author,
818818
users=", ".join(u.name for u in users),
819819
)
@@ -1385,12 +1385,14 @@ async def contact(
13851385

13861386
if not silent and not self.bot.config.get("thread_contact_silently"):
13871387
if creator.id == user.id:
1388-
description = "You have opened a Modmail thread."
1388+
description = self.bot.config["thread_creation_self_contact_response"]
13891389
else:
1390-
description = f"{creator.name} has opened a Modmail thread."
1390+
description = self.bot.formatter.format(
1391+
self.bot.config["thread_creation_contact_response"], creator=creator
1392+
)
13911393

13921394
em = discord.Embed(
1393-
title="New Thread",
1395+
title=self.bot.config["thread_creation_contact_title"],
13941396
description=description,
13951397
color=self.bot.main_color,
13961398
)

core/config.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,20 @@ class ConfigManager:
5252
"close_emoji": "\N{LOCK}",
5353
"use_user_id_channel_name": False,
5454
"recipient_thread_close": False,
55+
"thread_show_roles": True,
56+
"thread_show_account_age": True,
57+
"thread_show_join_age": True,
58+
"thread_cancelled": "Cancelled",
5559
"thread_auto_close_silently": False,
5660
"thread_auto_close": isodate.Duration(),
5761
"thread_auto_close_response": "This thread has been closed automatically due to inactivity after {timeout}.",
5862
"thread_creation_response": "The staff team will get back to you as soon as possible.",
5963
"thread_creation_footer": "Your message has been sent",
6064
"thread_contact_silently": False,
6165
"thread_self_closable_creation_footer": "Click the lock to close the thread",
66+
"thread_creation_contact_title": "New Thread",
67+
"thread_creation_self_contact_response": "You have opened a Modmail thread.",
68+
"thread_creation_contact_response": "{creator.name} has opened a Modmail thread.",
6269
"thread_creation_title": "Thread Created",
6370
"thread_close_footer": "Replying will create a new thread",
6471
"thread_close_title": "Thread Closed",
@@ -85,16 +92,16 @@ class ConfigManager:
8592
"anonymous_snippets": False,
8693
# group conversations
8794
"private_added_to_group_title": "New Thread (Group)",
88-
"private_added_to_group_description": "{moderator.name} has added you to a Modmail thread.",
95+
"private_added_to_group_response": "{moderator.name} has added you to a Modmail thread.",
8996
"private_added_to_group_description_anon": "A moderator has added you to a Modmail thread.",
9097
"public_added_to_group_title": "New User",
91-
"public_added_to_group_description": "{moderator.name} has added {users} to the Modmail thread.",
98+
"public_added_to_group_response": "{moderator.name} has added {users} to the Modmail thread.",
9299
"public_added_to_group_description_anon": "A moderator has added {users} to the Modmail thread.",
93100
"private_removed_from_group_title": "Removed From Thread (Group)",
94-
"private_removed_from_group_description": "{moderator.name} has removed you from the Modmail thread.",
101+
"private_removed_from_group_response": "{moderator.name} has removed you from the Modmail thread.",
95102
"private_removed_from_group_description_anon": "A moderator has removed you from the Modmail thread.",
96103
"public_removed_from_group_title": "User Removed",
97-
"public_removed_from_group_description": "{moderator.name} has removed {users} from the Modmail thread.",
104+
"public_removed_from_group_response": "{moderator.name} has removed {users} from the Modmail thread.",
98105
"public_removed_from_group_description_anon": "A moderator has removed {users} from the Modmail thread.",
99106
# moderation
100107
"recipient_color": str(discord.Color.gold()),

core/config_help.json

+75-4
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,36 @@
266266
"See also: `close_emoji`."
267267
]
268268
},
269+
"thread_show_roles": {
270+
"default": "Yes",
271+
"description": "Shows roles on first message sent in thread channels to mods",
272+
"examples":[
273+
"`{prefix}config set thread_show_roles no`"
274+
],
275+
"notes": [
276+
"See also: `thread_show_account_age`, `thread_show_join_age`."
277+
]
278+
},
279+
"thread_show_account_age": {
280+
"default": "Yes",
281+
"description": "Shows account age on first message sent in thread channels to mods",
282+
"examples":[
283+
"`{prefix}config set thread_show_account_age no`"
284+
],
285+
"notes": [
286+
"See also: `thread_show_roles`, `thread_show_join_age`."
287+
]
288+
},
289+
"thread_show_join_age": {
290+
"default": "Yes",
291+
"description": "Shows join age on first message sent in thread channels to mods",
292+
"examples":[
293+
"`{prefix}config set thread_show_join_age no`"
294+
],
295+
"notes": [
296+
"See also: `thread_show_account_age`, `thread_show_roles`."
297+
]
298+
},
269299
"thread_auto_close_silently": {
270300
"default": "No",
271301
"description": "Setting this configuration will close silently when the thread auto-closes.",
@@ -302,6 +332,14 @@
302332
"To disable thread cooldown, do `{prefix}config del thread_cooldown`."
303333
]
304334
},
335+
"thread_cancelled": {
336+
"default": "\"Cancelled\"",
337+
"description": "This is the message to display when a thread times out and creation is cancelled.",
338+
"examples": [
339+
"`{prefix}config set thread_cancelled Gone.`"
340+
],
341+
"notes": []
342+
},
305343
"thread_auto_close_response": {
306344
"default": "\"This thread has been closed automatically due to inactivity after {{timeout}}.\"",
307345
"description": "This is the message to display when the thread when the thread auto-closes.",
@@ -359,6 +397,39 @@
359397
"See also: `thread_creation_title`, `thread_creation_response`, `thread_creation_footer`."
360398
]
361399
},
400+
"thread_creation_contact_title": {
401+
"default": "\"New Thread\"",
402+
"description": "This is the message embed title sent to recipients when contacted.",
403+
"examples": [
404+
"`{prefix}config set thread_creation_contact_title New Message!`"
405+
],
406+
"notes": [
407+
"See also: `thread_creation_self_contact_response`, `thread_creation_contact_response`."
408+
]
409+
},
410+
"thread_creation_self_contact_response": {
411+
"default": "\"You have opened a Modmail thread.\"",
412+
"description": "This is the message embed description sent to recipients when self-contacted.",
413+
"examples": [
414+
"`{prefix}config set thread_creation_contact_title You contacted yourself.`"
415+
],
416+
"notes": [
417+
"`thread_creation_contact_response` is used when contacted by another user.",
418+
"See also: `thread_creation_contact_title`, `thread_creation_contact_response`."
419+
]
420+
},
421+
"thread_creation_contact_response": {
422+
"default": "\"{creator.name} has opened a Modmail thread.\"",
423+
"description": "This is the message embed description sent to recipients when contacted by a mod.",
424+
"examples": [
425+
"`{prefix}config set thread_creation_contact_response New thread opened.`"
426+
],
427+
"notes": [
428+
"You may use the `{{creator}}` variable for access to the [Member](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member) that created the thread.",
429+
"`thread_creation_self_contact_response` is used when contacted by self.",
430+
"See also: `thread_creation_contact_title`, `thread_creation_self_contact_response`."
431+
]
432+
},
362433
"thread_creation_title": {
363434
"default": "\"Thread Created\"",
364435
"description": "This is the message embed title sent to the recipient upon the creation of a new thread.",
@@ -722,7 +793,7 @@
722793
"See also: `private_added_to_group_description`, `public_added_to_group_title`"
723794
]
724795
},
725-
"private_added_to_group_description": {
796+
"private_added_to_group_response": {
726797
"default": "\"{{moderator.name}} has added you to a Modmail thread.\"",
727798
"description": "This is the message embed content sent to the recipient that is just added to a thread.",
728799
"examples": [
@@ -758,7 +829,7 @@
758829
"See also: `private_added_to_group_title`, `private_added_to_group_title`"
759830
]
760831
},
761-
"public_added_to_group_description": {
832+
"public_added_to_group_response": {
762833
"default": "\"{{moderator.name}} has added {{users}} to the Modmail thread.\"",
763834
"description": "This is the message embed content sent to all other recipients when someone is added to the thread.",
764835
"examples": [
@@ -794,7 +865,7 @@
794865
"See also: `private_removed_from_group_description`, `public_removed_from_group_title`"
795866
]
796867
},
797-
"private_removed_from_group_description": {
868+
"private_removed_from_group_response": {
798869
"default": "\"{{moderator.name}} has removed you from the Modmail thread.\"",
799870
"description": "This is the message embed content sent to the recipient that is just removed from a thread.",
800871
"examples": [
@@ -830,7 +901,7 @@
830901
"See also: `private_removed_from_group_title`, `private_removed_from_group_title`"
831902
]
832903
},
833-
"public_removed_from_group_description": {
904+
"public_removed_from_group_response": {
834905
"default": "\"{{moderator.name}} has removed {{users}} from the Modmail thread.\"",
835906
"description": "This is the message embed content sent to all other recipients when someone is removed from the thread.",
836907
"examples": [

core/thread.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ def _format_info_embed(self, user, log_url, log_count, color):
286286
# key = log_url.split('/')[-1]
287287

288288
role_names = ""
289-
if member is not None:
289+
if member is not None and self.bot.config["thread_show_roles"]:
290290
sep_server = self.bot.using_multiple_server_setup
291291
separator = ", " if sep_server else " "
292292

@@ -309,13 +309,11 @@ def _format_info_embed(self, user, log_url, log_count, color):
309309
role_names = separator.join(roles)
310310

311311
created = str((time - user.created_at).days)
312-
embed = discord.Embed(
313-
color=color, description=f"{user.mention} was created {days(created)}", timestamp=time
314-
)
312+
user_info = []
313+
if self.bot.config["thread_show_account_age"]:
314+
user_info.append(f"was created {days(created)}")
315315

316-
# if not role_names:
317-
# embed.add_field(name='Mention', value=user.mention)
318-
# embed.add_field(name='Registered', value=created + days(created))
316+
embed = discord.Embed(color=color, description=user.mention, timestamp=time)
319317

320318
if user.dm_channel:
321319
footer = f"User ID: {user.id} • DM ID: {user.dm_channel.id}"
@@ -328,7 +326,8 @@ def _format_info_embed(self, user, log_url, log_count, color):
328326
if member is not None:
329327
joined = str((time - member.joined_at).days)
330328
# embed.add_field(name='Joined', value=joined + days(joined))
331-
embed.description += f", joined {days(joined)}"
329+
if self.bot.config["thread_show_join_age"]:
330+
user_info.append(f"joined {days(joined)}")
332331

333332
if member.nick:
334333
embed.add_field(name="Nickname", value=member.nick, inline=True)
@@ -338,10 +337,12 @@ def _format_info_embed(self, user, log_url, log_count, color):
338337
else:
339338
embed.set_footer(text=f"{footer} • (not in main server)")
340339

340+
embed.description += ", ".join(user_info)
341+
341342
if log_count is not None:
342-
# embed.add_field(name="Past logs", value=f"{log_count}")
343+
connector = "with" if user_info else "has"
343344
thread = "thread" if log_count == 1 else "threads"
344-
embed.description += f" with **{log_count or 'no'}** past {thread}."
345+
embed.description += f" {connector} **{log_count or 'no'}** past {thread}."
345346
else:
346347
embed.description += "."
347348

@@ -1336,15 +1337,21 @@ async def create(
13361337
self.bot.loop.create_task(
13371338
destination.send(
13381339
embed=discord.Embed(
1339-
title="Cancelled", description="Timed out", color=self.bot.error_color
1340+
title=self.bot.config["thread_cancelled"],
1341+
description="Timed out",
1342+
color=self.bot.error_color,
13401343
)
13411344
)
13421345
)
13431346
else:
13441347
if str(r.emoji) == deny_emoji:
13451348
thread.cancelled = True
13461349
self.bot.loop.create_task(
1347-
destination.send(embed=discord.Embed(title="Cancelled", color=self.bot.error_color))
1350+
destination.send(
1351+
embed=discord.Embed(
1352+
title=self.bot.config["thread_cancelled"], color=self.bot.error_color
1353+
)
1354+
)
13481355
)
13491356

13501357
async def remove_reactions():

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extend-exclude = '''
2121

2222
[tool.poetry]
2323
name = 'Modmail'
24-
version = '3.10.0-dev5'
24+
version = '3.10.0-dev6'
2525
description = "Modmail is similar to Reddit's Modmail, both in functionality and purpose. It serves as a shared inbox for server staff to communicate with their users in a seamless way."
2626
license = 'AGPL-3.0-only'
2727
authors = [

0 commit comments

Comments
 (0)