Custom Commands docsCustom CommandsDocs

Search docs

Find a page, function or guide

HomeSupportDashboard

Getting started

  • Introduction
  • Your first command
  • How a command runs
  • Variables in replies
  • Text commands
  • Events
  • Using Slushy

Guides

  • Welcome messages
  • Role menus
  • Auto moderation
  • Social alerts
  • Moderation commands
  • Levels and XP
  • Economy and coins
  • Ticket system
  • Giveaways
  • Poll
  • Button game
  • Reminders

Concepts

  • Buttons and menus
  • Forms
  • Saving data
  • Permissions and cooldowns
  • Limits and premium
  • Common mistakes

API reference

  • Response
  • Messages
  • Embeds
  • Members and roles
  • Channels
  • Storage
  • Checks
  • Views
  • Components
  • Modals
  • Interactions
  • Paginators
  • Web and files
  • Scheduling
  • Server events and polls
  • Time
  • Waiting
  • Utilities
  • Objects
  • Event variables

Examples

  • /8ball
  • /coinflip
  • /avatar
  • /serverinfo
  • /rank
  • /remind

Getting started

View .md

Events

Run code on its own when something happens in your server, like a member joining or a button click.

A command runs when someone types it. An event runs on its own when something happens in your server. A member joins, a reaction is added, a button is clicked.

Make an event#

  1. Open Create → Event.
  2. Give it a Name. Only you see this.
  3. Pick a Type. This is what makes it run.
  4. Write the code in the Code box.
  5. Press Save.

An event has one code box. It has no Response box and no post-hook. To say something, the code sends its own message with send_message.

How many events can be on

Free servers can have 2 events turned on at once. Starter has 5. Basic and Advanced have no limit.

Event types#

TypeRuns whenExtra field
Member JoinA member joins the server
Member LeaveA member leaves or is kicked
Member UpdateA member's nickname, roles or timeout changes
Button Click / Select Menu ChangeSomeone clicks a button or picks from a menuCustom ids
Modal SubmitSomeone sends a formCustom ids
AutocompleteSomeone types in a command option with suggestions
Thread (Create/Delete)A thread is made, changed or deleted
Reaction (Add/Remove)Someone adds or removes a reactionReactions
MESSAGE (Pro Only)Someone sends a message. Premium servers only
ClockA timer you set with schedule_clock or a job goes offCustom ids
Voice JoinA member joins a voice channel
Voice LeaveA member leaves a voice channel
Voice ChangeA member moves to another voice channel
Vote (top.gg)Someone votes for the server on top.gg

Custom ids says which buttons, forms or timers this event listens to. Separate them with commas. For Clock, remind_* matches every id that starts with remind_.

Reactions says which emojis this event listens to. Use the emoji, a custom emoji name, or its ID.

Each type gets different variables, like user or channel. See Event variables for the full list.

Example: auto role on join#

Type: Member Join

python
add_roles(user, "Member")
send_message("welcome", f"Welcome {user.mention}! You are member #{server.member_count}.")

user is the member who joined. "Member" and "welcome" are a role name and a channel name. IDs and mentions work too.

Tip

For a simple welcome message, you do not need code. Use the Welcome & Leave page. See Welcome message.

Example: keyword auto reply#

Type: MESSAGE (Pro Only)

python
if user is None or user.is_bot:
    return

text = message.content.lower()

if "how do i join" in text:
    send_message(channel, "Read the steps in #how-to-join.", reply=message_id)

Always skip bots first

A message event also runs for the bot's own messages. Without the first two lines, the bot can reply to its own reply, again and again.

Example: log reactions#

Type: Reaction (Add/Remove). Reactions: ⭐

python
if action == "add":
    send_message("star-log", f"{user.mention} starred a message in {channel.mention}")

action is "add" or "remove".

Curly brackets do not work here#

Events have no reply box, so {user.mention} style variables do nothing. Build text with an f-string: f"Hi {user.mention}". The f before the quote matters.

Commands-only functions#

These only work in commands, not in events: set_content, set_embed, set_response_message, set_dm_response, set_components, set_view, add_attachment, end.

Use send_message instead.

PreviousText commandsNext Using Slushy

On this page

  • Make an event
  • Event types
  • Example: auto role on join
  • Example: keyword auto reply
  • Example: log reactions
  • Curly brackets do not work here
  • Commands-only functions
Custom CommandsCustom Commands

The #1 Custom Commands Discord bot — build commands, events and databases with zero boilerplate.

Join the support server

Product

  • Overview
  • Why us?
  • Premium
  • Template shop

Features

  • AI Agent
  • Reaction roles
  • Welcome messages
  • Embed builder
  • Social alerts
  • Custom bot

Resources

  • Docs
  • Blog
  • Support
  • Dashboard

Company

  • Privacy
  • Terms
  • Contact
contact@ccbot.app

2 Frederick Street, London, WC1X 0ND

Payments secured by Stripe

© WEiRDSOFT LTD. All rights reserved.

Custom Commands