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.
@plugin.on_event("message_create")
def count_messages(ctx: Context, event: dict):
if not event.get("author_bot"):
ctx.kv.increment("messages_today_total")
@plugin.on_event("member_join")
def count_joins(ctx: Context, event: dict):
ctx.kv.increment("new_members_today")
@plugin.on_slash_command("stats")
def stats(ctx: Context, event: dict):
msgs_today = ctx.kv.get("messages_today_total") or 0
new_today = ctx.kv.get("new_members_today") or 0
ctx.interaction.respond(content=(
f"**Server stats**\n"
f"Messages today: {msgs_today}\n"
f"New members today: {new_today}"
))