Documentación / Developers / Cookbook / 1) Welcome new members
BuildSDK 0.10.1

1) Welcome new members

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

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()

@plugin.on_event("member_join")
def greet(ctx: Context, event: MemberJoin):
    channel_id = ctx.kv.get("welcome_channel_id")
    if not channel_id:
        return
    name = event.get("display_name") or event.get("username") or "friend"
    ctx.discord.send_message(channel_id=str(channel_id),
        content=f"Welcome, **{name}**! :wave:")

@plugin.on_slash_command("welcome-channel")
def set_channel(ctx: Context, event: dict):
    ctx.kv.set("welcome_channel_id", event["channel_id"])
    ctx.interaction.respond(content="This is now the welcome channel.")

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