Docs / Developers / Cookbook
Build21 topicsSDK 0.10.1

Cookbook

Copy-pasteable recipes: welcome messages, reaction roles, leaderboards, polls, tickets, autoresponders and more.

Manifest declarations for these recipes

One block covers every slash command below — copy the entries you use into your manifest.json : "slash_commands": [ {"name": "welcome-channel", "description": "Make this channel…

1) Welcome new members

Greet every new member in a channel an admin configures via /welcome-channel . from yourbot_sdk import Plugin, Context from yourbot_sdk.events import MemberJoin plugin = Plugin()…

2) Reaction roles (click ✓ to get a role)

Admin posts a message, configures the role+emoji pair, and any user who reacts gets the role. Reaction events carry custom emoji as their bare name, so normalize the stored form…

3) Daily announcement (the daily-gate pattern)

Two ways to run daily work. The wall-clock way: declare the task in your manifest's "cron" array and handle it with @plugin.cron ( Build: Cron schedules ). The zero-manifest way…

4) /leaderboard top 10 users by messages

Track per-user message count; `/leaderboard` posts the top 10. from yourbot_sdk.events import MessageCreate @plugin.on_event("message_create") def count(ctx: Context, event:…

5) AFK status

/afk <reason> sets the user's status; the bot replies when they're mentioned. Parsing mentions reads message text, so this recipe needs events:message_content . import re from…

6) Custom commands stored in KV

Server admins add their own !shortcut commands without redeploying. from yourbot_sdk.events import MessageCreate @plugin.on_event("message_create") def custom(ctx: Context, event:…

7) Reaction-based polls

/poll creates a message with ✓/✗ reactions; tallies via reaction count later. @plugin.on_slash_command("poll") def poll(ctx: Context, event: dict): opts = {o["name"]: o["value"]…

8) Message logger

Log every non-bot message to a configurable mod channel (useful for audit trails). Reads message text, so it needs events:message_content . from yourbot_sdk.events import…

9) /stats: server stat card

Show message and join counts. The two counter handlers keep the numbers the command reads; reset them with the daily-gate pattern from recipe 3 if you want true per-day figures.…

10) Role menu (dropdown)

Admin runs /role-menu , gets a dropdown listing self-assignable roles. from yourbot_sdk import ActionRow, SelectMenu, SelectOption @plugin.on_slash_command("role-menu") def…

11) Ticket triage: /ticket opens a thread

User runs /ticket <subject> ; the bot creates a private thread and posts the details there. create_thread needs discord:manage_channels (auto-detected).…

12) Auto-respond to keywords

Trigger a reply when a message contains a configured keyword. Useful for FAQs. from yourbot_sdk.events import MessageCreate @plugin.on_event("message_create") def…

13) Birthday reminders

Users register their birthday via /birthday MM-DD ; the daily gate (recipe 3) announces the day's birthdays with the first message after midnight UTC. The mentions render but do…

14) Member of the week

Count messages per user, then announce the week's top sender on Sunday after 09:00 UTC using the daily-gate pattern. The winner mention renders without pinging. from datetime…

15) Voice channel time tracker

Track how long each user spends in voice channels. Useful for activity-based rewards. from yourbot_sdk.events import VoiceStateUpdate import time…

16) Call an external API: /price

Fetch live data from a third-party API through the platform proxy. Add "proxy_domains_requested": ["api.coingecko.com"] to your manifest (the upload scan usually detects it from…

17) XP levels that scale: /rank with SQL

Recipe 4's KV leaderboard scans at most 100 keys per call. When your plugin lands on big servers, keep counts in ctx.sql instead — a real table sorts any number of users. Needs…

18) Keyword moderation: auto-timeout + embed mod-log

Time out members who use a banned word and post an embed to a mod-log channel. Reads message text ( events:message_content ) and uses discord:moderate_members (Dangerous tier —…

19) Starboard: repost popular messages

When a message collects enough ⭐ reactions, celebrate it in a dedicated channel. The KV counter crosses the threshold exactly once, so no dedup flag is needed. Reaction emoji…

20) Weekly digest on a real schedule (production cron)

The daily-gate pattern (recipe 3) needs traffic to fire. When a job must run at a wall-clock time even on a quiet server, use a cron task: decorate the handler and declare it in…

YourBot docs Reference tables are generated from the code that is running. Ask in Discord Suggest a correction