Dokumentation / Developers / Cookbook / 19) Starboard: repost popular messages
BuildSDK 0.10.1

19) Starboard: repost popular messages

These docs are public. To publish a plugin you need a YourBot account: sign in to open the Dev Portal.

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 arrive only with events:message_content (recipe 2's caveat applies).

from yourbot_sdk.events import ReactionAdd

STAR = "⭐"
THRESHOLD = 3

@plugin.on_slash_command("starboard-here")
def set_board(ctx: Context, event: dict):
    ctx.kv.set("starboard_channel_id", event["channel_id"])
    ctx.interaction.respond(content="This is now the starboard.")

@plugin.on_event("reaction_add")
def count_star(ctx: Context, event: ReactionAdd):
    if event.get("user_bot") or event.get("emoji") != STAR:
        return
    n = ctx.kv.increment(f"stars:{event['message_id']}")
    board = ctx.kv.get("starboard_channel_id")
    if n != THRESHOLD or not board or str(board) == str(event["channel_id"]):
        return
    link = (f"https://discord.com/channels/"
            f"{event.get('guild_id') or ctx.server_id}"
            f"/{event['channel_id']}/{event['message_id']}")
    ctx.discord.send_message(channel_id=str(board),
        content=f"{STAR} A message just hit {THRESHOLD} stars: {link}")
YourBot docs Reference tables are generated from the code that is running. Ask in Discord Suggest a correction