π€π£ A general use-case discord bot
- Create an application in the Discord Developer Portal.
- Go to the Bot page and select the correct toggles.
- Go to OAuth and select Bot in the check boxes.
- Then select Admin.
- Copy the URL and add to a server.
- Install
uvfrom https://docs.astral.sh/uv/. - Install dependencies with
uv sync.
python3 main.pyTo enable the >update command (git pull + restart), launch via the wrapper instead:
./run.shThe wrapper relaunches the bot when it exits with code 42, which is what >update does after pulling. Set admin_id in bot.toml to the Discord user ID allowed to run >update.
Ping a computed set of members using set-algebra expressions.
Slash command (recommended):
/ping expression:<expr> message:<text>
The expression field has autocomplete β type a role name or @here and select from the dropdown. Operators (&, |, ^, !) must be typed manually between selections.
/ping expression:@here & Rusty Minecraft message:can someone review my PR
/ping expression:@here | Mods message:Hey there!
/ping expression:!(@here) message:you all missed it
Operands:
| Token | Members |
|---|---|
@here |
members currently online |
@everyone |
every member of the server |
@<role> |
members with that role (names may contain spaces) |
<@&id> |
a role mention |
<@id> |
a single member mention |
Operators (loosest to tightest precedence):
| Operator | Meaning |
|---|---|
| |
union β in either group |
^ |
symmetric difference β in exactly one group |
& |
intersection β in both groups |
! |
complement β everyone not in the group |
( ) |
grouping |
Bots are never pinged. @here requires the Presence Intent enabled in the Discord Developer Portal.
>activity [limit]
Shows message counts per member in the server. limit defaults to 1000 messages scanned.
>birthdays
>birthday channel check
Lists everyone's birthday (channel-restricted). >birthday channel check sends a test message to the configured announcements channel.
Configure birthdays in birthdays.toml:
birthdays = [
{ month = 1, day = 23, user_id = 12345, name = "Ubik" },
]Notification streams are configured in notification_streams.toml. Each stream points to a Python script implementing:
def get_new_events() -> list[str] | list[dict]: ...The script handles deduplication so only new events are returned each run. The bot checks streams once daily.
>notify list β list available streams
>notify signup <stream> [dm|channel] β subscribe
>notify unsubscribe <stream> β unsubscribe
>notify run β manually trigger all streams
>latex <expression>
Renders a LaTeX expression as an image. Example: >latex e^{i\pi} + 1 = 0
>kronicler
Shows a runtime plot from kronicler data.
>commit β show the latest git commit hash and date
>source β show the GitHub repository link
>link β show the bot invite link
>update β git pull and restart (admin only)
>eval β evaluate Hy (Lisp) code (admin only)