Metadata-Version: 2.5
Name: statusbeat
Version: 0.1.0
Summary: Uptime and shard monitoring for Discord bots, from Statusbeat.
Project-URL: Homepage, https://statusbeat.app
Project-URL: Documentation, https://statusbeat.app/docs/bots
License-Expression: MIT
Keywords: discord,discord.py,disnake,monitoring,nextcord,pycord,status page,uptime
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.9
Requires-Dist: aiohttp>=3.8
Provides-Extra: test
Requires-Dist: pytest>=8; extra == 'test'
Description-Content-Type: text/markdown

# statusbeat

Uptime and shard monitoring for Discord bots. Add one line and [Statusbeat](https://statusbeat.app) knows within a couple of minutes when your bot, or any one of its shards, stops responding. It alerts you in Discord, Slack, or any webhook, and updates your status page.

Works with **discord.py**, **Pycord**, **nextcord**, and **disnake** on Python 3.9+.

## Install

```bash
pip install statusbeat
```

## Use

Create a bot monitor in your Statusbeat dashboard and save its token as the `STATUSBEAT_TOKEN` environment variable. Then:

```python
import discord
import statusbeat

client = discord.AutoShardedClient(intents=discord.Intents.default())
statusbeat.monitor(client)

client.run(os.environ["DISCORD_TOKEN"])
```

`monitor()` works before the bot starts (it hooks into `setup_hook`) or after, for example in `on_ready`. It returns a monitor with a `stop()` method, which you can call before a planned shutdown.

| Argument   | Default                    | What it does                                           |
| ---------- | -------------------------- | ------------------------------------------------------ |
| `token`    | `STATUSBEAT_TOKEN`         | Your monitor token, starting `sbhb_`.                  |
| `interval` | `45`                       | Seconds between beats until the dashboard's value arrives. |
| `endpoint` | Statusbeat                 | Heartbeat URL. Only needed for testing.                |

Turn on `logging.getLogger("statusbeat").setLevel(logging.DEBUG)` to see what it's doing.

## Shards

With `AutoShardedClient`, every shard is reported with its own status and ping. If some shards disconnect while the rest keep running, Statusbeat marks the bot as a partial outage once they've been offline for 2 minutes.

## What is sent

Your bot's gateway ping, guild count, each shard's id, status, and ping, process memory, uptime, and the library name. Never your bot token, messages, users, channel or guild names, or anything else.

## Behaviour

- It never raises into your bot. Network errors and bad responses are logged at debug level and retried.
- It backs off while Statusbeat is unreachable, up to 10 minutes, and honours `Retry-After`.
- A rejected token is logged once and retried every 10 minutes.

## License

MIT
