Skip to content

Commit 323a557

Browse files
committed
Fix contact with category and silent, #3076
1 parent 0c9c129 commit 323a557

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ however, insignificant breaking changes do not guarantee a major version bump, s
1919
- Blocked users are now no longer allowed to use `?contact` and react to contact. ([COMMENT #819004157](https://github.com/kyb3r/modmail/issues/2969#issuecomment-819004157), [PR #3027](https://github.com/kyb3r/modmail/pull/3027))
2020
- UnicodeEncodeError will no longer be raised on Windows. ([PR #3043](https://github.com/kyb3r/modmail/pull/3043))
2121
- Notifications are no longer duplicated when using both `?notify` and `subscribe`. ([PR #3015](https://github.com/kyb3r/modmail/pull/3015))
22+
- `?contact` now works properly with both category and silent. ([GH #3076](https://github.com/kyb3r/modmail/issues/3076))
2223

2324
## Internal
2425

bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def _cancel_tasks():
284284
loop.run_until_complete(loop.shutdown_asyncgens())
285285
finally:
286286
logger.info("Closing the event loop.")
287-
loop.close()
287+
# loop.close()
288288

289289
if not future.cancelled():
290290
try:

cogs/modmail.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,14 @@ async def contact(
10381038
if isinstance(category, str):
10391039
if "silent" in category or "silently" in category:
10401040
silent = True
1041-
category = None
1041+
category = category.strip("silently").strip("silent").strip()
1042+
try:
1043+
category = await SimilarCategoryConverter().convert(ctx, category) # attempt to find a category again
1044+
except commands.BadArgument:
1045+
category = None
1046+
1047+
if isinstance(category, str):
1048+
category = None
10421049

10431050
if user.bot:
10441051
embed = discord.Embed(color=self.bot.error_color, description="Cannot start a thread with a bot.")

core/thread.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,17 @@ async def _close(self, closer, silent=False, delete_channel=True, message=None,
487487
if self.bot.config["show_timestamp"]:
488488
embed.timestamp = datetime.utcnow()
489489

490+
if not message:
491+
if self.id == closer.id:
492+
message = self.bot.config["thread_self_close_response"]
493+
else:
494+
message = self.bot.config["thread_close_response"]
495+
490496
message = self.bot.formatter.format(
491497
message, closer=closer, loglink=log_url, logkey=log_data["key"] if log_data else None
492498
)
493499

500+
embed.description = message
494501
footer = self.bot.config["thread_close_footer"]
495502
embed.set_footer(text=footer, icon_url=self.bot.guild.icon_url)
496503

0 commit comments

Comments
 (0)