mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Add custom status support (#6226)
Co-authored-by: Jakub Kuczys <me@jacken.men>
This commit is contained in:
parent
1248927fb6
commit
9e23c3a5b8
@ -3769,6 +3769,35 @@ Maximum length for a competing status is 128 characters.
|
|||||||
**Arguments:**
|
**Arguments:**
|
||||||
- ``[competing]`` - The text to follow ``Competing in``. Leave blank to clear the current activity status.
|
- ``[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:
|
.. _core-command-set-status-dnd:
|
||||||
|
|
||||||
""""""""""""""
|
""""""""""""""
|
||||||
|
|||||||
@ -3207,6 +3207,38 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
|
|||||||
else:
|
else:
|
||||||
await ctx.send(_("Competing cleared."))
|
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):
|
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
|
game = ctx.bot.guilds[0].me.activity if len(ctx.bot.guilds) > 0 else None
|
||||||
await ctx.bot.change_presence(status=status, activity=game)
|
await ctx.bot.change_presence(status=status, activity=game)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user