diff --git a/docs/cog_guides/core.rst b/docs/cog_guides/core.rst index 28ccbe2069d..de09e25a386 100644 --- a/docs/cog_guides/core.rst +++ b/docs/cog_guides/core.rst @@ -2958,11 +2958,27 @@ set bot custominfo .. code-block:: none - [p]set bot custominfo [text] + [p]set bot custominfo **Description** -Customizes a section of ``[p]info``. +Customizes sections of ``[p]info``. + +.. _core-command-set-bot-custominfo-text: + +""""""""""""""""""""""" +set bot custominfo text +""""""""""""""""""""""" + +**Syntax** + +.. code-block:: none + + [p]set bot custominfo text [text] + +**Description** + +Customizes a section of optional text in ``[p]info``. The maximum amount of allowed characters is 1024. Supports markdown, links and "mentions". @@ -2970,13 +2986,42 @@ Supports markdown, links and "mentions". Link example: ``[My link](https://example.com)`` **Examples:** - - ``[p]set bot custominfo >>> I can use **markdown** such as quotes, ||spoilers|| and multiple lines.`` - - ``[p]set bot custominfo Join my [support server](discord.gg/discord)!`` - - ``[p]set bot custominfo`` - Removes custom info text. + - ``[p]set bot custominfo text >>> I can use **markdown** such as quotes, ||spoilers|| and multiple lines.`` + - ``[p]set bot custominfo text Join my [support server](discord.gg/discord)!`` + - ``[p]set bot custominfo text`` - Removes custom info text. **Arguments:** - ``[text]`` - The custom info text. +.. _core-command-set-bot-custominfo-image: + +"""""""""""""""""""""""" +set bot custominfo image +"""""""""""""""""""""""" + +**Syntax** + +.. code-block:: none + + [p]set bot custominfo text [text] + +**Description** + +Customizes an optional image sent inside the ``[p]info`` embed. + +You may provide an image URL or send an attachment. +Sending neither will remove the image from the embed. + +Images are not sent if embeds are disabled. + +**Examples:** + - ``[p]set bot custominfo image https://imgur.com/pY1WUFX.png`` + - ``[p]set bot custominfo image `` + - ``[p]set bot custominfo image`` - Removes custom image. + +**Arguments:** + - ``[url]`` - The URL of the image. + .. _core-command-set-bot-description: """"""""""""""""""" diff --git a/redbot/core/bot.py b/redbot/core/bot.py index bac5afcbc2e..6e277791119 100644 --- a/redbot/core/bot.py +++ b/redbot/core/bot.py @@ -121,6 +121,7 @@ def __init__(self, *args, cli_flags=None, bot_dir: Path = Path.cwd(), **kwargs): color=15158332, fuzzy=False, custom_info=None, + info_image=None, help__page_char_limit=1000, help__max_pages_in_guild=2, help__delete_delay=0, diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 93cacdeb840..468bb115dc0 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -464,6 +464,8 @@ async def info(self, ctx: commands.Context): embed.set_footer( text=_("Bringing joy since 02 Jan 2016 (over {} days ago!)").format(days_since) ) + image = await self.bot._config.info_image() + embed.set_image(url=image) await ctx.send(embed=embed) else: python_version = "{}.{}.{}".format(*sys.version_info[:3]) @@ -3088,10 +3090,14 @@ async def _set_bot_nickname(self, ctx: commands.Context, *, nickname: str = None else: await ctx.send(_("Done.")) - @_set_bot.command(name="custominfo") + @_set_bot.group(name="custominfo") @commands.is_owner() - async def _set_bot_custominfo(self, ctx: commands.Context, *, text: str = None): - """Customizes a section of `[p]info`. + async def _set_bot_custominfo(self, ctx: commands.Context): + """Customizes sections of `[p]info`.""" + + @_set_bot_custominfo.command(name="text") + async def _set_bot_custominfo_text(self, ctx: commands.Context, *, text: str = None): + """Customizes a section of optional text in `[p]info`. The maximum amount of allowed characters is 1024. Supports markdown, links and "mentions". @@ -3099,9 +3105,9 @@ async def _set_bot_custominfo(self, ctx: commands.Context, *, text: str = None): Link example: `[My link](https://example.com)` **Examples:** - - `[p]set bot custominfo >>> I can use **markdown** such as quotes, ||spoilers|| and multiple lines.` - - `[p]set bot custominfo Join my [support server](discord.gg/discord)!` - - `[p]set bot custominfo` - Removes custom info text. + - `[p]set bot custominfo text >>> I can use **markdown** such as quotes, ||spoilers|| and multiple lines.` + - `[p]set bot custominfo text Join my [support server](discord.gg/discord)!` + - `[p]set bot custominfo text` - Removes custom info text. **Arguments:** - `[text]` - The custom info text. @@ -3117,6 +3123,36 @@ async def _set_bot_custominfo(self, ctx: commands.Context, *, text: str = None): else: await ctx.send(_("Text must be fewer than 1024 characters long.")) + @_set_bot_custominfo.command(name="image") + async def _set_bot_custominfo_image(self, ctx: commands.Context, *, url: str = None): + """Customizes an optional image sent inside the `[p]info` embed. + + You may provide an image URL or send an attachment. + Sending neither will remove the image from the embed. + + Images are not sent if embeds are disabled. + + **Examples:** + - `[p]set bot custominfo image https://imgur.com/pY1WUFX.png` + - `[p]set bot custominfo image ` + - `[p]set bot custominfo image` - Removes custom image. + + **Arguments:** + - `[url]` - The URL of the image. + """ + if attachments := ctx.message.attachments: + if not attachments[0].content_type.startswith("image"): + await ctx.send(_("Attachment must be an image or GIF file.")) + return + url = attachments[0].url + elif not url: + await ctx.bot._config.info_image.clear() + await ctx.send(_("The custom image has been cleared.")) + return + await ctx.bot._config.info_image.set(url) + await ctx.send(_("The custom image has been set.")) + await ctx.invoke(self.info) + # -- End Bot Metadata Commands -- ### # -- Bot Status Commands -- ###