From 687c68ee4191e1cd8ea0cf0c4cfe9d2e12233c66 Mon Sep 17 00:00:00 2001 From: zv Date: Wed, 22 Apr 2026 20:21:30 +0200 Subject: [PATCH] Initial commit --- README.md | 28 ++++++++++++++++++++++++++++ __init__.py | 5 +++++ statusrotator.py | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 README.md create mode 100644 __init__.py create mode 100644 statusrotator.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..22607b2 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# StatusRotator + +Cog for Red-DiscordBot that rotates the bot's playing status in a simple timed loop. + +## What it does + +- Sets the bot activity to: + - `❓ Prefix: .help` for 60 seconds +- Then changes it to: + - `💻 I support 100+ commands` for 30 seconds +- Repeats this cycle forever in a loop +- Uses only `Playing` activity for both statuses + +## Rotation order + +The status loop works like this: + +1. `❓ Prefix: .help` for 60 seconds +2. `💻 I support 100+ commands` for 30 seconds +3. Repeat from the beginning + +## Installation + +1. Put this cog folder in your custom cogs path. +2. In Discord: + +```text +[p]load statusrotator \ No newline at end of file diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..c8474be --- /dev/null +++ b/__init__.py @@ -0,0 +1,5 @@ +from .statusrotator import StatusRotator + + +async def setup(bot): + await bot.add_cog(StatusRotator(bot)) \ No newline at end of file diff --git a/statusrotator.py b/statusrotator.py new file mode 100644 index 0000000..58155c9 --- /dev/null +++ b/statusrotator.py @@ -0,0 +1,36 @@ +import asyncio +import contextlib + +import discord +from redbot.core import commands + + +class StatusRotator(commands.Cog): + """Bot status rotation.""" + + def __init__(self, bot): + self.bot = bot + self._task = None + + async def cog_load(self): + self._task = asyncio.create_task(self.status_loop()) + + async def cog_unload(self): + if self._task: + self._task.cancel() + with contextlib.suppress(asyncio.CancelledError): + await self._task + + async def status_loop(self): + await self.bot.wait_until_ready() + + while not self.bot.is_closed(): + await self.bot.change_presence( + activity=discord.Game(name="❓ Prefix: .help") + ) + await asyncio.sleep(60) + + await self.bot.change_presence( + activity=discord.Game(name="💻 I support 100+ commands") + ) + await asyncio.sleep(30) \ No newline at end of file