From 9e23c3a5b8c1ced769f6b771d9f4d003fa48ca9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pred=C3=A4?= <46051820+PredaaA@users.noreply.github.com> Date: Thu, 10 Aug 2023 02:45:24 +0200 Subject: [PATCH] Add custom status support (#6226) Co-authored-by: Jakub Kuczys --- docs/cog_guides/core.rst | 29 +++++++++++++++++++++++++++++ redbot/core/core_commands.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/docs/cog_guides/core.rst b/docs/cog_guides/core.rst index 00f309b26..d3a3ed849 100644 --- a/docs/cog_guides/core.rst +++ b/docs/cog_guides/core.rst @@ -3769,6 +3769,35 @@ Maximum length for a competing status is 128 characters. **Arguments:** - ``[competing]`` - The text to follow ``Competing in``. Leave blank to clear the current activity status. +.. _core-command-set-status-custom: + +""""""""""""""""" +set status custom +""""""""""""""""" + +.. note:: |owner-lock| + +**Syntax** + +.. code-block:: none + + [p]set status custom [text] + +**Description** + +Sets Red's custom status. + +This will appear as ````. + +Maximum length for a custom status is 128 characters. + +**Examples:** + - ``[p]set status custom`` - Clears the activity status. + - ``[p]set status custom Running cogs...`` + +**Arguments:** + - ``[text]`` - The custom status text. Leave blank to clear the current activity status. + .. _core-command-set-status-dnd: """""""""""""" diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 05bdc390e..f59da0b13 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -3207,6 +3207,38 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic): else: await ctx.send(_("Competing cleared.")) + @_set_status.command(name="custom") + @commands.bot_in_a_guild() + @commands.is_owner() + async def _set_status_custom(self, ctx: commands.Context, *, text: str = None): + """Sets [botname]'s custom status. + + This will appear as ``. + + Maximum length for a custom status is 128 characters. + + **Examples:** + - `[p]set status custom` - Clears the activity status. + - `[p]set status custom Running cogs...` + + **Arguments:** + - `[text]` - The custom status text. Leave blank to clear the current activity status. + """ + + status = ctx.bot.guilds[0].me.status if len(ctx.bot.guilds) > 0 else discord.Status.online + if text: + if len(text) > 128: + await ctx.send(_("The maximum length of custom statuses is 128 characters.")) + return + activity = discord.Activity(name=text, state=text, type=discord.ActivityType.custom) + else: + activity = None + await ctx.bot.change_presence(status=status, activity=activity) + if activity: + await ctx.send(_("Custom status set to `{text}`.").format(text=text)) + else: + await ctx.send(_("Custom status cleared.")) + async def _set_my_status(self, ctx: commands.Context, status: discord.Status): game = ctx.bot.guilds[0].me.activity if len(ctx.bot.guilds) > 0 else None await ctx.bot.change_presence(status=status, activity=game)