Skip to content

Set smaller size for guild icons urls on embed icons #3261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@ however, insignificant breaking changes do not guarantee a major version bump, s
- 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))
- Reply not being forwarded from DM. (PR [#3239](https://github.com/modmail-dev/modmail/pull/3239))

# [UNRELEASED]

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

### Changed
- 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))
- Repo moved to https://github.com/modmail-dev/modmail.

# v4.0.2
Expand Down
14 changes: 9 additions & 5 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,16 @@ def __init__(self):
self.plugin_db = PluginDatabaseClient(self) # Deprecated
self.startup()

def get_guild_icon(self, guild: typing.Optional[discord.Guild]) -> str:
def get_guild_icon(
self, guild: typing.Optional[discord.Guild], *, size: typing.Optional[int] = None
) -> str:
if guild is None:
guild = self.guild
if guild.icon is None:
return "https://cdn.discordapp.com/embed/avatars/0.png"
return guild.icon.url
if size is None:
return guild.icon.url
return guild.icon.with_size(size).url

def _resolve_snippet(self, name: str) -> typing.Optional[str]:
"""
Expand Down Expand Up @@ -912,7 +916,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
)
embed.set_footer(
text=self.config["disabled_new_thread_footer"],
icon_url=self.get_guild_icon(guild=message.guild),
icon_url=self.get_guild_icon(guild=message.guild, size=128),
)
logger.info("A new thread was blocked from %s due to disabled Modmail.", message.author)
await self.add_reaction(message, blocked_emoji)
Expand All @@ -928,7 +932,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
)
embed.set_footer(
text=self.config["disabled_current_thread_footer"],
icon_url=self.get_guild_icon(guild=message.guild),
icon_url=self.get_guild_icon(guild=message.guild, size=128),
)
logger.info("A message was blocked from %s due to disabled Modmail.", message.author)
await self.add_reaction(message, blocked_emoji)
Expand Down Expand Up @@ -1335,7 +1339,7 @@ async def handle_react_to_contact(self, payload):
)
embed.set_footer(
text=self.config["disabled_new_thread_footer"],
icon_url=self.get_guild_icon(guild=channel.guild),
icon_url=self.get_guild_icon(guild=channel.guild, size=128),
)
logger.info(
"A new thread using react to contact was blocked from %s due to disabled Modmail.",
Expand Down
8 changes: 4 additions & 4 deletions cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ async def snippet(self, ctx, *, name: str.lower = None):
color=self.bot.error_color, description="You dont have any snippets at the moment."
)
embed.set_footer(text=f'Check "{self.bot.prefix}help snippet add" to add a snippet.')
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild))
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128))
return await ctx.send(embed=embed)

embeds = []

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

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

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

for u in users:
Expand Down
9 changes: 6 additions & 3 deletions cogs/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -1020,15 +1020,17 @@ async def alias(self, ctx, *, name: str.lower = None):
color=self.bot.error_color, description="You dont have any aliases at the moment."
)
embed.set_footer(text=f'Do "{self.bot.prefix}help alias" for more commands.')
embed.set_author(name="Aliases", icon_url=self.bot.get_guild_icon(guild=ctx.guild))
embed.set_author(name="Aliases", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128))
return await ctx.send(embed=embed)

embeds = []

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

session = EmbedPaginatorSession(ctx, *embeds)
Expand Down Expand Up @@ -1612,7 +1614,8 @@ async def permissions_get(
)
embed = discord.Embed(color=self.bot.main_color, description=description)
embed.set_author(
name="Permission Overrides", icon_url=self.bot.get_guild_icon(guild=ctx.guild)
name="Permission Overrides",
icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128),
)
embeds.append(embed)

Expand Down
8 changes: 5 additions & 3 deletions core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,9 @@ async def send_recipient_genesis_message():
else:
footer = self.bot.config["thread_creation_footer"]

embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.modmail_guild))
embed.set_footer(
text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.modmail_guild, size=128)
)
embed.title = self.bot.config["thread_creation_title"]

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

embed.description = message
footer = self.bot.config["thread_close_footer"]
embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.guild))
embed.set_footer(text=footer, icon_url=self.bot.get_guild_icon(guild=self.bot.guild, size=128))

if not silent:
for user in self.recipients:
Expand Down Expand Up @@ -957,7 +959,7 @@ async def send(
name = tag
avatar_url = self.bot.config["anon_avatar_url"]
if avatar_url is None:
avatar_url = self.bot.get_guild_icon(guild=self.bot.guild)
avatar_url = self.bot.get_guild_icon(guild=self.bot.guild, size=128)
embed.set_author(
name=name,
icon_url=avatar_url,
Expand Down