[3.4] Make embeds in help output consistent (#5452) (#5507)

* Add `check_permissions` kwarg to `bot.embed_requested()`

* Make embeds in help consistent regardless of why it's being sent
(cherry picked from commit ff7c146b62)

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>

Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
Red-GitHubBot
2021-12-31 02:03:11 +01:00
committed by GitHub
parent fb08cd0520
commit 1027d95092
3 changed files with 27 additions and 10 deletions

View File

@@ -1220,12 +1220,14 @@ class RedBase(
channel: Union[discord.abc.GuildChannel, discord.abc.PrivateChannel],
user: discord.abc.User,
command: Optional[commands.Command] = None,
*,
check_permissions: bool = False,
) -> bool:
"""
Determine if an embed is requested for a response.
Parameters
----------
Arguments
---------
channel : `discord.abc.GuildChannel` or `discord.abc.PrivateChannel`
The channel to check embed settings for.
user : `discord.abc.User`
@@ -1233,6 +1235,13 @@ class RedBase(
command : `redbot.core.commands.Command`, optional
The command ran.
Keyword Arguments
-----------------
check_permissions : `bool`
If ``True``, this method will also check whether the bot can send embeds
in the given channel and if it can't, it will return ``False`` regardless of
the bot's embed settings.
Returns
-------
bool
@@ -1249,6 +1258,9 @@ class RedBase(
if (user_setting := await self._config.user(user).embeds()) is not None:
return user_setting
else:
if not channel.permissions_for(channel.guild.me).embed_links:
return False
if (channel_setting := await self._config.channel(channel).embeds()) is not None:
return channel_setting