Skip to content

Commit

Permalink
Add custom status support (Cog-Creators#6226)
Browse files Browse the repository at this point in the history
Co-authored-by: Jakub Kuczys <me@jacken.men>
  • Loading branch information
PredaaA and Jackenmen committed Aug 10, 2023
1 parent 5ac50e0 commit 8063255
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/cog_guides/core.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3758,6 +3758,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 ``<text>``.

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:

""""""""""""""
Expand Down
32 changes: 32 additions & 0 deletions redbot/core/core_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2739,6 +2739,38 @@ async def _set_status_competing(self, ctx: commands.Context, *, competing: str =
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 `<text>`.
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)
Expand Down

0 comments on commit 8063255

Please sign in to comment.