Skip to content

Commit 71bf970

Browse files
committed
fix: anonreply showing None
This fixes a bug where, if no `anon_username` is set and the moderator has no roles, the `anon_username` is not showing as `None` anymore, and will show as intended. The logic now works as follows: - If a config anon_username is set → use it - Else, if a mod_tag is set → use it - Else, if the moderator has a top role → use that - Else → use "Anonymous"
1 parent 18947c8 commit 71bf970

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

cogs/modmail.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,10 +1121,9 @@ async def anonadduser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
11211121

11221122
tag = self.bot.config["mod_tag"]
11231123
if tag is None:
1124-
tag = str(get_top_role(ctx.author, self.bot.config["use_hoisted_top_role"]))
1125-
name = self.bot.config["anon_username"]
1126-
if name is None:
1127-
name = tag
1124+
top_role = get_top_role(ctx.author, self.bot.config["use_hoisted_top_role"])
1125+
tag = str(top_role) if top_role else None
1126+
name = self.bot.config["anon_username"] or tag or "Anonymous"
11281127
avatar_url = self.bot.config["anon_avatar_url"]
11291128
if avatar_url is None:
11301129
avatar_url = self.bot.get_guild_icon(guild=ctx.guild, size=128)
@@ -1212,10 +1211,9 @@ async def anonremoveuser(self, ctx, *users_arg: Union[discord.Member, discord.Ro
12121211

12131212
tag = self.bot.config["mod_tag"]
12141213
if tag is None:
1215-
tag = str(get_top_role(ctx.author, self.bot.config["use_hoisted_top_role"]))
1216-
name = self.bot.config["anon_username"]
1217-
if name is None:
1218-
name = tag
1214+
top_role = get_top_role(ctx.author, self.bot.config["use_hoisted_top_role"])
1215+
tag = str(top_role) if top_role else None
1216+
name = self.bot.config["anon_username"] or tag or "Anonymous"
12191217
avatar_url = self.bot.config["anon_avatar_url"]
12201218
if avatar_url is None:
12211219
avatar_url = self.bot.get_guild_icon(guild=ctx.guild, size=128)

core/thread.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1652,10 +1652,9 @@ async def send(
16521652
# Anonymously sending to the user.
16531653
tag = self.bot.config["mod_tag"]
16541654
if tag is None:
1655-
tag = str(get_top_role(author, self.bot.config["use_hoisted_top_role"]))
1656-
name = self.bot.config["anon_username"]
1657-
if name is None:
1658-
name = tag
1655+
top_role = get_top_role(author, self.bot.config["use_hoisted_top_role"])
1656+
tag = str(top_role) if top_role else None
1657+
name = self.bot.config["anon_username"] or tag or "Anonymous"
16591658
avatar_url = self.bot.config["anon_avatar_url"]
16601659
if avatar_url is None:
16611660
avatar_url = self.bot.get_guild_icon(guild=self.bot.guild, size=128)

0 commit comments

Comments
 (0)