Skip to content

Commit 5ddb4e0

Browse files
Set smaller size for guild icons urls on embed icons (#3261)
* Set size for guild icons on embeds * Update changelog * Format with black * Fixed incorrect function return type --------- Signed-off-by: Taku <45324516+Taaku18@users.noreply.github.com> Co-authored-by: Taku <45324516+Taaku18@users.noreply.github.com>
1 parent fa1a949 commit 5ddb4e0

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,11 @@ however, insignificant breaking changes do not guarantee a major version bump, s
1313
- Loading the blocked list with the `?blocked` command takes a long time when the list is large. ([PR #3242](https://github.com/kyb3r/modmail/pull/3242))
1414
- Reply not being forwarded from DM. (PR [#3239](https://github.com/modmail-dev/modmail/pull/3239))
1515

16-
# [UNRELEASED]
17-
1816
### Added
1917
- New .env config option: `REGISTRY_PLUGINS_ONLY`, restricts to only allow adding registry plugins. ([PR #3247](https://github.com/modmail-dev/modmail/pull/3247))
2018

2119
### Changed
20+
- Guild icons in embed footers and author urls now have a fixed size of 128. ([PR #3261](https://github.com/modmail-dev/modmail/pull/3261))
2221
- Repo moved to https://github.com/modmail-dev/modmail.
2322

2423
# v4.0.2

bot.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,16 @@ def __init__(self):
9090
self.plugin_db = PluginDatabaseClient(self) # Deprecated
9191
self.startup()
9292

93-
def get_guild_icon(self, guild: typing.Optional[discord.Guild]) -> str:
93+
def get_guild_icon(
94+
self, guild: typing.Optional[discord.Guild], *, size: typing.Optional[int] = None
95+
) -> str:
9496
if guild is None:
9597
guild = self.guild
9698
if guild.icon is None:
9799
return "https://cdn.discordapp.com/embed/avatars/0.png"
98-
return guild.icon.url
100+
if size is None:
101+
return guild.icon.url
102+
return guild.icon.with_size(size).url
99103

100104
def _resolve_snippet(self, name: str) -> typing.Optional[str]:
101105
"""
@@ -912,7 +916,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
912916
)
913917
embed.set_footer(
914918
text=self.config["disabled_new_thread_footer"],
915-
icon_url=self.get_guild_icon(guild=message.guild),
919+
icon_url=self.get_guild_icon(guild=message.guild, size=128),
916920
)
917921
logger.info("A new thread was blocked from %s due to disabled Modmail.", message.author)
918922
await self.add_reaction(message, blocked_emoji)
@@ -928,7 +932,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
928932
)
929933
embed.set_footer(
930934
text=self.config["disabled_current_thread_footer"],
931-
icon_url=self.get_guild_icon(guild=message.guild),
935+
icon_url=self.get_guild_icon(guild=message.guild, size=128),
932936
)
933937
logger.info("A message was blocked from %s due to disabled Modmail.", message.author)
934938
await self.add_reaction(message, blocked_emoji)
@@ -1335,7 +1339,7 @@ async def handle_react_to_contact(self, payload):
13351339
)
13361340
embed.set_footer(
13371341
text=self.config["disabled_new_thread_footer"],
1338-
icon_url=self.get_guild_icon(guild=channel.guild),
1342+
icon_url=self.get_guild_icon(guild=channel.guild, size=128),
13391343
)
13401344
logger.info(
13411345
"A new thread using react to contact was blocked from %s due to disabled Modmail.",

cogs/modmail.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,15 @@ async def snippet(self, ctx, *, name: str.lower = None):
160160
color=self.bot.error_color, description="You dont have any snippets at the moment."
161161
)
162162
embed.set_footer(text=f'Check "{self.bot.prefix}help snippet add" to add a snippet.')
163-
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild))
163+
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128))
164164
return await ctx.send(embed=embed)
165165

166166
embeds = []
167167

168168
for i, names in enumerate(zip_longest(*(iter(sorted(self.bot.snippets)),) * 15)):
169169
description = format_description(i, names)
170170
embed = discord.Embed(color=self.bot.main_color, description=description)
171-
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild))
171+
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128))
172172
embeds.append(embed)
173173

174174
session = EmbedPaginatorSession(ctx, *embeds)
@@ -1031,7 +1031,7 @@ async def anonadduser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
10311031
name = tag
10321032
avatar_url = self.bot.config["anon_avatar_url"]
10331033
if avatar_url is None:
1034-
avatar_url = self.bot.get_guild_icon(guild=ctx.guild)
1034+
avatar_url = self.bot.get_guild_icon(guild=ctx.guild, size=128)
10351035
em.set_footer(text=name, icon_url=avatar_url)
10361036

10371037
for u in users:
@@ -1120,7 +1120,7 @@ async def anonremoveuser(self, ctx, *users_arg: Union[discord.Member, discord.Ro
11201120
name = tag
11211121
avatar_url = self.bot.config["anon_avatar_url"]
11221122
if avatar_url is None:
1123-
avatar_url = self.bot.get_guild_icon(guild=ctx.guild)
1123+
avatar_url = self.bot.get_guild_icon(guild=ctx.guild, size=128)
11241124
em.set_footer(text=name, icon_url=avatar_url)
11251125

11261126
for u in users:

cogs/utility.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1020,15 +1020,17 @@ async def alias(self, ctx, *, name: str.lower = None):
10201020
color=self.bot.error_color, description="You dont have any aliases at the moment."
10211021
)
10221022
embed.set_footer(text=f'Do "{self.bot.prefix}help alias" for more commands.')
1023-
embed.set_author(name="Aliases", icon_url=self.bot.get_guild_icon(guild=ctx.guild))
1023+
embed.set_author(name="Aliases", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128))
10241024
return await ctx.send(embed=embed)
10251025

10261026
embeds = []
10271027

10281028
for i, names in enumerate(zip_longest(*(iter(sorted(self.bot.aliases)),) * 15)):
10291029
description = utils.format_description(i, names)
10301030
embed = discord.Embed(color=self.bot.main_color, description=description)
1031-
embed.set_author(name="Command Aliases", icon_url=self.bot.get_guild_icon(guild=ctx.guild))
1031+
embed.set_author(
1032+
name="Command Aliases", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128)
1033+
)
10321034
embeds.append(embed)
10331035

10341036
session = EmbedPaginatorSession(ctx, *embeds)
@@ -1612,7 +1614,8 @@ async def permissions_get(
16121614
)
16131615
embed = discord.Embed(color=self.bot.main_color, description=description)
16141616
embed.set_author(
1615-
name="Permission Overrides", icon_url=self.bot.get_guild_icon(guild=ctx.guild)
1617+
name="Permission Overrides",
1618+
icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128),
16161619
)
16171620
embeds.append(embed)
16181621

core/thread.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,9 @@ async def send_recipient_genesis_message():
228228
else:
229229
footer = self.bot.config["thread_creation_footer"]
230230

231-
embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.modmail_guild))
231+
embed.set_footer(
232+
text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.modmail_guild, size=128)
233+
)
232234
embed.title = self.bot.config["thread_creation_title"]
233235

234236
if creator is None or creator == recipient:
@@ -521,7 +523,7 @@ async def _close(self, closer, silent=False, delete_channel=True, message=None,
521523

522524
embed.description = message
523525
footer = self.bot.config["thread_close_footer"]
524-
embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.guild))
526+
embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.guild, size=128))
525527

526528
if not silent:
527529
for user in self.recipients:
@@ -957,7 +959,7 @@ async def send(
957959
name = tag
958960
avatar_url = self.bot.config["anon_avatar_url"]
959961
if avatar_url is None:
960-
avatar_url = self.bot.get_guild_icon(guild=self.bot.guild)
962+
avatar_url = self.bot.get_guild_icon(guild=self.bot.guild, size=128)
961963
embed.set_author(
962964
name=name,
963965
icon_url=avatar_url,

0 commit comments

Comments
 (0)