Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Mar 7, 2021
2 parents 049508f + baa7e5f commit 480ad57
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 9 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
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.

# v3.8.5

### Added

- `?msglink <message id>`, allows you to obtain channel + message ID for T&S reports. ([GH #2963](https://github.com/kyb3r/modmail/issues/2963), [PR #2964](https://github.com/kyb3r/modmail/pull/2964))
- `?mention disable/reset`, disables or resets mention on thread creation. ([PR #2951](https://github.com/kyb3r/modmail/pull/2951))

### Fixed

- Non-master/development branch deployments no longer cause errors to be raised.
- Autotriggers now can search for roles/channels in guild context. ([GH #2961](https://github.com/kyb3r/modmail/issues/2961))

# v3.8.4

This update is a quick hotfix for a weird behaviour experienced on 1 Feb 2021 where users were not properly cached.
Expand Down
5 changes: 3 additions & 2 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "3.8.4"
__version__ = "3.8.5"


import asyncio
Expand Down Expand Up @@ -939,6 +939,7 @@ async def get_contexts(self, message, *, cls=commands.Context):
async def trigger_auto_triggers(self, message, channel, *, cls=commands.Context):
message.author = self.modmail_guild.me
message.channel = channel
message.guild = channel.guild

view = StringView(message.content)
ctx = cls(prefix=self.prefix, view=view, bot=self, message=message)
Expand Down Expand Up @@ -967,7 +968,7 @@ async def trigger_auto_triggers(self, message, channel, *, cls=commands.Context)
ctxs = []
aliases = normalize_alias(alias)
if not aliases:
logger.warning("Alias %s is invalid as called in automove.", invoker)
logger.warning("Alias %s is invalid as called in autotrigger.", invoker)

for alias in aliases:
view = StringView(invoked_prefix + alias)
Expand Down
21 changes: 20 additions & 1 deletion cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,11 @@ async def move(self, ctx, *, arguments):

if self.bot.config["thread_move_notify_mods"]:
mention = self.bot.config["mention"]
await thread.channel.send(f"{mention}, thread has been moved.")
if mention is not None:
msg = f"{mention}, thread has been moved."
else:
msg = "Thread has been moved."
await thread.channel.send(msg)

sent_emoji, _ = await self.bot.retrieve_emoji()
await self.bot.add_reaction(ctx.message, sent_emoji)
Expand Down Expand Up @@ -601,6 +605,21 @@ async def sfw(self, ctx):
sent_emoji, _ = await self.bot.retrieve_emoji()
await self.bot.add_reaction(ctx.message, sent_emoji)

@commands.command()
@checks.has_permissions(PermissionLevel.SUPPORTER)
@checks.thread_only()
async def msglink(self, ctx, message_id: int):
"""Retrieves the link to a message in the current thread."""
try:
message = await ctx.thread.recipient.fetch_message(message_id)
except discord.NotFound:
embed = discord.Embed(
color=self.bot.error_color, description="Message not found or no longer exists."
)
else:
embed = discord.Embed(color=self.bot.main_color, description=message.jump_url)
await ctx.send(embed=embed)

@commands.command()
@checks.has_permissions(PermissionLevel.SUPPORTER)
@checks.thread_only()
Expand Down
27 changes: 23 additions & 4 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,20 +674,40 @@ async def ping(self, ctx):

@commands.command()
@checks.has_permissions(PermissionLevel.ADMINISTRATOR)
async def mention(self, ctx, *mention: Union[discord.Role, discord.Member]):
async def mention(self, ctx, *mention: Union[discord.Role, discord.Member, str]):
"""
Change what the bot mentions at the start of each thread.
Type only `{prefix}mention` to retrieve your current "mention" message.
`{prefix}mention disable` to disable mention.
`{prefix}mention reset` to reset it to default value.
"""
# TODO: ability to disable mention.
current = self.bot.config["mention"]

if not mention:
embed = discord.Embed(
title="Current mention:", color=self.bot.main_color, description=str(current)
)
elif (
len(mention) == 1
and isinstance(mention[0], str)
and mention[0].lower() in ["disable", "reset"]
):
option = mention[0].lower()
if option == "disable":
embed = discord.Embed(
description=f"Disabled mention on thread creation.", color=self.bot.main_color,
)
self.bot.config["mention"] = None
else:
embed = discord.Embed(
description="`mention` is reset to default.", color=self.bot.main_color,
)
self.bot.config.remove("mention")
await self.bot.config.update()
else:
for m in mention:
if not isinstance(m, (discord.Role, discord.Member)):
raise commands.BadArgument(f'Role or Member "{m}" not found.')
mention = " ".join(i.mention for i in mention)
embed = discord.Embed(
title="Changed mention!",
Expand Down Expand Up @@ -1778,7 +1798,6 @@ async def autotrigger_edit(self, ctx, keyword, *, command):
split_cmd = command.split(" ")
for n in range(1, len(split_cmd) + 1):
if self.bot.get_command(" ".join(split_cmd[0:n])):
print(self.bot.get_command(" ".join(split_cmd[0:n])))
valid = True
break

Expand Down
3 changes: 3 additions & 0 deletions core/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ async def from_url(cls, bot, url: str = "") -> "Changelog":
if not branch or err:
branch = "master" if not bot.version.is_prerelease else "development"

if branch not in ("master", "development"):
branch = "master"

url = url or f"https://raw.githubusercontent.com/kyb3r/modmail/{branch}/CHANGELOG.md"

async with await bot.session.get(url) as resp:
Expand Down
2 changes: 1 addition & 1 deletion core/config_help.json
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@
"`{prefix}config set confirm_thread_creation yes`"
],
"notes": [
"See also: `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny``"
"See also: `confirm_thread_creation_title`, `confirm_thread_response`, `confirm_thread_creation_accept`, `confirm_thread_creation_deny`"
]
},
"confirm_thread_creation_title": {
Expand Down
6 changes: 5 additions & 1 deletion core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,11 @@ def _format_info_embed(self, user, log_url, log_count, color):
# embed.add_field(name='Mention', value=user.mention)
# embed.add_field(name='Registered', value=created + days(created))

footer = "User ID: " + str(user.id)
if user.dm_channel:
footer = f"User ID: {user.id} • DM ID: {user.dm_channel}"
else:
footer = f"User ID: {user.id}"

embed.set_author(name=str(user), icon_url=user.avatar_url, url=log_url)
# embed.set_thumbnail(url=avi)

Expand Down

0 comments on commit 480ad57

Please sign in to comment.