Skip to content

Commit

Permalink
Fix contact with category and silent, #3076
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Aug 6, 2021
1 parent 0c9c129 commit 323a557
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 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
- 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))
- UnicodeEncodeError will no longer be raised on Windows. ([PR #3043](https://github.com/kyb3r/modmail/pull/3043))
- Notifications are no longer duplicated when using both `?notify` and `subscribe`. ([PR #3015](https://github.com/kyb3r/modmail/pull/3015))
- `?contact` now works properly with both category and silent. ([GH #3076](https://github.com/kyb3r/modmail/issues/3076))

## Internal

Expand Down
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def _cancel_tasks():
loop.run_until_complete(loop.shutdown_asyncgens())
finally:
logger.info("Closing the event loop.")
loop.close()
# loop.close()

if not future.cancelled():
try:
Expand Down
9 changes: 8 additions & 1 deletion cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,14 @@ async def contact(
if isinstance(category, str):
if "silent" in category or "silently" in category:
silent = True
category = None
category = category.strip("silently").strip("silent").strip()
try:
category = await SimilarCategoryConverter().convert(ctx, category) # attempt to find a category again
except commands.BadArgument:
category = None

if isinstance(category, str):
category = None

if user.bot:
embed = discord.Embed(color=self.bot.error_color, description="Cannot start a thread with a bot.")
Expand Down
7 changes: 7 additions & 0 deletions core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,17 @@ async def _close(self, closer, silent=False, delete_channel=True, message=None,
if self.bot.config["show_timestamp"]:
embed.timestamp = datetime.utcnow()

if not message:
if self.id == closer.id:
message = self.bot.config["thread_self_close_response"]
else:
message = self.bot.config["thread_close_response"]

message = self.bot.formatter.format(
message, closer=closer, loglink=log_url, logkey=log_data["key"] if log_data else None
)

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

Expand Down

0 comments on commit 323a557

Please sign in to comment.