diff --git a/CHANGELOG.md b/CHANGELOG.md index 28e5151b07..a18c8d8eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ 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.10.0-dev4 +# v3.10.0-dev5 v3.10 adds group conversations while resolving othre bugs and QOL changes. It is potentially breaking to some plugins that adds functionality to threads. @@ -18,6 +18,7 @@ v3.10 adds group conversations while resolving othre bugs and QOL changes. It is - Ability to have group conversations. ([GH #143](https://github.com/kyb3r/modmail/issues/143)) - Snippets are invoked case insensitively. ([GH #3077](https://github.com/kyb3r/modmail/issues/3077), [PR #3080](https://github.com/kyb3r/modmail/pull/3080)) +- Default tags now use top hoisted role. ([GH #3014](https://github.com/kyb3r/modmail/issues/3014)) ## Fixed diff --git a/README.md b/README.md index 7659898399..42a8f812ec 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@
- +
diff --git a/bot.py b/bot.py index 26fac619d2..9a61101707 100644 --- a/bot.py +++ b/bot.py @@ -1,4 +1,4 @@ -__version__ = "v3.10.0-dev4" +__version__ = "v3.10.0-dev5" import asyncio diff --git a/cogs/modmail.py b/cogs/modmail.py index 74b99dde76..c7be64e046 100644 --- a/cogs/modmail.py +++ b/cogs/modmail.py @@ -891,7 +891,7 @@ async def anonadduser(self, ctx, *users_arg: Union[discord.Member, discord.Role, tag = self.bot.config["mod_tag"] if tag is None: - tag = str(ctx.author.top_role) + tag = str(get_top_hoisted_role(ctx.author)) name = self.bot.config["anon_username"] if name is None: name = tag @@ -976,7 +976,7 @@ async def anonremoveuser(self, ctx, *users_arg: Union[discord.Member, discord.Ro tag = self.bot.config["mod_tag"] if tag is None: - tag = str(ctx.author.top_role) + tag = str(get_top_hoisted_role(ctx.author)) name = self.bot.config["anon_username"] if name is None: name = tag diff --git a/core/thread.py b/core/thread.py index 91f30417a8..b2adbffe76 100644 --- a/core/thread.py +++ b/core/thread.py @@ -22,6 +22,7 @@ match_other_recipients, truncate, format_channel_name, + get_top_hoisted_role, ) logger = getLogger(__name__) @@ -888,7 +889,7 @@ async def send( # Anonymously sending to the user. tag = self.bot.config["mod_tag"] if tag is None: - tag = str(author.top_role) + tag = str(get_top_hoisted_role(author)) name = self.bot.config["anon_username"] if name is None: name = tag @@ -1005,7 +1006,7 @@ async def send( elif not anonymous: mod_tag = self.bot.config["mod_tag"] if mod_tag is None: - mod_tag = str(message.author.top_role) + mod_tag = str(get_top_hoisted_role(message.author)) embed.set_footer(text=mod_tag) # Normal messages else: embed.set_footer(text=self.bot.config["anon_tag"]) diff --git a/core/utils.py b/core/utils.py index 173eda25d5..8f4e1a01ff 100644 --- a/core/utils.py +++ b/core/utils.py @@ -32,6 +32,7 @@ "escape_code_block", "format_channel_name", "tryint", + "get_top_hoisted_role", ] @@ -394,3 +395,10 @@ def tryint(x): return int(x) except (ValueError, TypeError): return x + + +def get_top_hoisted_role(member: discord.Member): + roles = sorted(member.roles, key=lambda r: r.position, reverse=True) + for role in roles: + if role.hoist: + return role diff --git a/pyproject.toml b/pyproject.toml index e038685a61..1d97e42e33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,7 @@ extend-exclude = ''' [tool.poetry] name = 'Modmail' -version = '3.10.0-dev4' +version = '3.10.0-dev5' 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." license = 'AGPL-3.0-only' authors = [