Skip to content

Commit 34befb5

Browse files
committed
update channel id and show timestamp config, resolves #2885
1 parent 306df8a commit 34befb5

File tree

7 files changed

+58
-13
lines changed

7 files changed

+58
-13
lines changed

CHANGELOG.md

+8-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ 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.7.10
10+
11+
### Added
12+
13+
- Added `update_channel_id` to specify which channel autoupdate notifications were being sent to.
14+
- Added `show_timestamp` to specify if timestamps should be displayed in message embeds. ([GH #2885](https://github.com/kyb3r/modmail/issues/2885))
15+
916
# v3.7.9
1017

1118
### Fixed
1219

13-
- `perms add/remove` with permission levels should now work again. ([PR #2893](https://github.com/kyb3r/modmail/pull/2893))
20+
- `perms add/remove` with permission levels should now work again. ([GH #2892](https://github.com/kyb3r/modmail/issues/2892), [PR #2893](https://github.com/kyb3r/modmail/pull/2893))
1421

1522
### Improved
1623

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.7.9-7289da?style=for-the-badge&logo=data:image/gif;base64,R0lGODlhGAAYAPcAAAAAADQ+Yj5MdThCaEFOekNQfWt5e1lqfEdVhVpriVx1iVtsnFZpll1xlF1znFx5mGNtjGR7hWNzjGd5iWJunGNslmN0lGl1lGN5lWt7lWR0nGp1nWR5nGt8nHJ9l3J9jFxto1xtqlZqqF5zpF15pV10rVx5q1Z2ql1us150s114sV50uVd1smJupGNurGN0pGp1pGR6o2t7o2F0rml0rGR5rGt8q3J9pGNus2Fvu2Bzs2p2smR5s2t7tGF0u2N6vGp7u2l1uXJ+uGJ1wWV7w2l+xWl+yl5zwHWDiWyCmHODnHi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">
9+
<img src="https://img.shields.io/badge/Latest%20Version-v3.7.10-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

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.7.9"
1+
__version__ = "3.7.10"
22

33

44
import asyncio
@@ -270,6 +270,21 @@ def mention_channel(self):
270270

271271
return self.log_channel
272272

273+
@property
274+
def update_channel(self):
275+
channel_id = self.config["update_channel_id"]
276+
if channel_id is not None:
277+
try:
278+
channel = self.get_channel(int(channel_id))
279+
if channel is not None:
280+
return channel
281+
except ValueError:
282+
pass
283+
logger.debug("UPDATE_CHANNEL_ID was invalid, removed.")
284+
self.config.remove("update_channel_id")
285+
286+
return self.log_channel
287+
273288
async def wait_for_connected(self) -> None:
274289
await self.wait_until_ready()
275290
await self._connected.wait()
@@ -1027,8 +1042,9 @@ async def on_message(self, message):
10271042
title="Bot mention",
10281043
description=f"[Jump URL]({message.jump_url})\n{truncate(message.content, 50)}",
10291044
color=self.main_color,
1030-
timestamp=datetime.utcnow(),
10311045
)
1046+
if self.config["show_timestamp"]:
1047+
em.timestamp = datetime.utcnow()
10321048
await self.mention_channel.send(content=self.config["mention"], embed=em)
10331049

10341050
await self.process_commands(message)
@@ -1508,7 +1524,7 @@ async def autoupdate(self):
15081524

15091525
elif res != "Already up to date.":
15101526
logger.info("Bot has been updated.")
1511-
channel = self.log_channel
1527+
channel = self.update_channel
15121528
if self.hosting_method == HostingMethod.PM2:
15131529
embed = discord.Embed(title="Bot has been updated", color=self.main_color)
15141530
await channel.send(embed=embed)

cogs/modmail.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -996,11 +996,10 @@ async def contact(
996996
description = f"{ctx.author.name} has opened a Modmail thread."
997997

998998
em = discord.Embed(
999-
title="New Thread",
1000-
description=description,
1001-
color=self.bot.main_color,
1002-
timestamp=datetime.utcnow(),
999+
title="New Thread", description=description, color=self.bot.main_color,
10031000
)
1001+
if self.bot.config["show_timestamp"]:
1002+
em.timestamp = datetime.utcnow()
10041003
em.set_footer(icon_url=ctx.author.avatar_url)
10051004
await user.send(embed=em)
10061005

core/config.py

+3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ConfigManager:
4343
# logging
4444
"log_channel_id": None,
4545
"mention_channel_id": None,
46+
"update_channel_id": None,
4647
# threads
4748
"sent_emoji": "✅",
4849
"blocked_emoji": "🚫",
@@ -76,6 +77,7 @@ class ConfigManager:
7677
"close_on_leave": False,
7778
"close_on_leave_reason": "The recipient has left the server.",
7879
"alert_on_mention": False,
80+
"show_timestamp": True,
7981
# moderation
8082
"recipient_color": str(discord.Color.gold()),
8183
"mod_color": str(discord.Color.green()),
@@ -162,6 +164,7 @@ class ConfigManager:
162164
"transfer_reactions",
163165
"close_on_leave",
164166
"alert_on_mention",
167+
"show_timestamp",
165168
"confirm_thread_creation",
166169
"use_regex_autotrigger",
167170
"enable_plugins",

core/config_help.json

+18
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@
185185
"See also: `log_channel_id`"
186186
]
187187
},
188+
"update_channel_id": {
189+
"default": "Log Channel (normally `#bot-logs`)",
190+
"description": "This is the channel where update notifications are sent to.",
191+
"examples": [
192+
"`{prefix}config set update_channel_id 9234932582312` (9234932582312 is the channel ID)"
193+
],
194+
"notes": [
195+
"This has no effect unless `disable_autoupdates` is set to no.",
196+
"See also: `log_channel_id`"
197+
]
198+
},
188199
"sent_emoji": {
189200
"default": "",
190201
"description": "This is the emoji added to the message when when a Modmail action is invoked successfully (ie. DM Modmail, edit message, etc.).",
@@ -648,6 +659,13 @@
648659
"See also: `mention`"
649660
]
650661
},
662+
"show_timestamp": {
663+
"default": "Yes",
664+
"description": "Shows timestamps on thread embeds",
665+
"examples":[
666+
"`{prefix}config set show_timestamp no`"
667+
]
668+
},
651669
"confirm_thread_creation": {
652670
"default": "No",
653671
"description": "Ensure users confirm that they want to create a new thread",

core/thread.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -460,10 +460,10 @@ async def _close(
460460
# Thread closed message
461461

462462
embed = discord.Embed(
463-
title=self.bot.config["thread_close_title"],
464-
color=self.bot.error_color,
465-
timestamp=datetime.utcnow(),
463+
title=self.bot.config["thread_close_title"], color=self.bot.error_color,
466464
)
465+
if self.bot.config["show_timestamp"]:
466+
embed.timestamp = datetime.utcnow()
467467

468468
if not message:
469469
if self.id == closer.id:
@@ -823,7 +823,9 @@ async def send(
823823

824824
author = message.author
825825

826-
embed = discord.Embed(description=message.content, timestamp=message.created_at)
826+
embed = discord.Embed(description=message.content)
827+
if self.bot.config["show_timestamp"]:
828+
embed.timestamp = message.created_at
827829

828830
system_avatar_url = "https://discordapp.com/assets/f78426a064bc9dd24847519259bc42af.png"
829831

0 commit comments

Comments
 (0)