Skip to content

Commit c1df103

Browse files
committed
Squashed commit of the following:
commit 13437cd Author: baptiste0928 <[email protected]> Date: Tue Mar 21 22:29:24 2023 +0100 Format with black commit 8a6ecd6 Merge: d9e364e 02250e8 Author: Taku <[email protected]> Date: Tue Mar 21 13:30:40 2023 -0700 Merge branch 'development' into feat/guild-icon-size Signed-off-by: Taku <[email protected]> commit d9e364e Author: baptiste0928 <[email protected]> Date: Sun Mar 19 20:17:35 2023 +0100 Update changelog commit d0bfeb4 Author: baptiste0928 <[email protected]> Date: Sun Mar 19 20:06:20 2023 +0100 Set size for guild icons on embeds
1 parent 53b66c7 commit c1df103

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
@@ -91,12 +91,16 @@ def __init__(self):
9191
self.plugin_db = PluginDatabaseClient(self) # Deprecated
9292
self.startup()
9393

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

101105
def _resolve_snippet(self, name: str) -> typing.Optional[str]:
102106
"""
@@ -913,7 +917,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
913917
)
914918
embed.set_footer(
915919
text=self.config["disabled_new_thread_footer"],
916-
icon_url=self.get_guild_icon(guild=message.guild),
920+
icon_url=self.get_guild_icon(guild=message.guild, size=128),
917921
)
918922
logger.info("A new thread was blocked from %s due to disabled Modmail.", message.author)
919923
await self.add_reaction(message, blocked_emoji)
@@ -929,7 +933,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
929933
)
930934
embed.set_footer(
931935
text=self.config["disabled_current_thread_footer"],
932-
icon_url=self.get_guild_icon(guild=message.guild),
936+
icon_url=self.get_guild_icon(guild=message.guild, size=128),
933937
)
934938
logger.info("A message was blocked from %s due to disabled Modmail.", message.author)
935939
await self.add_reaction(message, blocked_emoji)
@@ -1338,7 +1342,7 @@ async def handle_react_to_contact(self, payload):
13381342
)
13391343
embed.set_footer(
13401344
text=self.config["disabled_new_thread_footer"],
1341-
icon_url=self.get_guild_icon(guild=channel.guild),
1345+
icon_url=self.get_guild_icon(guild=channel.guild, size=128),
13421346
)
13431347
logger.info(
13441348
"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
@@ -231,7 +231,9 @@ async def send_recipient_genesis_message():
231231
else:
232232
footer = self.bot.config["thread_creation_footer"]
233233

234-
embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.modmail_guild))
234+
embed.set_footer(
235+
text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.modmail_guild, size=128)
236+
)
235237
embed.title = self.bot.config["thread_creation_title"]
236238

237239
if creator is None or creator == recipient:
@@ -524,7 +526,7 @@ async def _close(self, closer, silent=False, delete_channel=True, message=None,
524526

525527
embed.description = message
526528
footer = self.bot.config["thread_close_footer"]
527-
embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.guild))
529+
embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.guild, size=128))
528530

529531
if not silent:
530532
for user in self.recipients:
@@ -960,7 +962,7 @@ async def send(
960962
name = tag
961963
avatar_url = self.bot.config["anon_avatar_url"]
962964
if avatar_url is None:
963-
avatar_url = self.bot.get_guild_icon(guild=self.bot.guild)
965+
avatar_url = self.bot.get_guild_icon(guild=self.bot.guild, size=128)
964966
embed.set_author(
965967
name=name,
966968
icon_url=avatar_url,

0 commit comments

Comments
 (0)