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

API reference

View .md

Scheduling

Do something later, or on a repeat. One-off actions, clocks and repeating jobs.

There are three ways to make the bot act later:

ToolUse it forRuns
scheduleOne ready action later, like "remove this role in 2 days".Once
schedule_clockYour own code later, like a reminder.Once
start_jobYour own code on a repeat, like a daily post.Again and again

Write await in front of every function on this page.

Times are plain words, like "in 10 minutes", "tomorrow 5pm" or "next friday". They use your server's timezone, set in the dashboard settings. Without one, the bot uses UTC.

Limits#

WhatFreeStarterBasicAdvanced
schedule actions waiting at once201002501,000
Clocks waiting at once1,00010,00010,00010,000
Repeating jobsnot availableavailableavailableavailable

A waiting action or clock frees its place when it runs.

schedule#

Runs one ready-made action at a later time. Returns the schedule ID.

python
await schedule(action, when, data=None, member=None, channel=None)
ArgumentWhat it does
actionWhat to do. See the list below.
whenWhen to do it, like "in 2 hours". Must be in the future.
dataThe details for the action. A dict, or one plain value.
memberThe member to act on. Defaults to the person who ran the command.
channelThe channel to act in. Defaults to the current channel.

Example: a temporary role

python
await schedule("remove_role", "in 7 days", data={"roles": ["Trial"]})
set_content("You have the Trial role for 7 days.")

Example: post a message later

python
await schedule("send_message", "tomorrow 9am", data="Good morning everyone!")

Actions you can schedule#

When you pass one plain value as data, it fills the field marked main.

Actiondata fields
send_messagecontent (main), embed, channel
send_dmcontent (main), embed, member
add_role, remove_roleroles (main), member
kick_membermember (main), reason
ban_membermember (main), reason, delete_days (0 to 7)
unban_memberuser (main), reason
delete_messagechannel, message
edit_messagechannel, message, content, embed
pin_message, unpin_messagechannel, message
purge_messagesamount (main, 1 to 100), channel
lock_channel, unlock_channelchannel (main)
set_slowmodeseconds (main, up to 21,600), channel
update_channelchannel, name, topic, nsfw, slowmode
delete_channelchannel (main)
mute_member, unmute_membermember (main)
create_pollchannel, question, answers (2 to 10), duration (hours)

embed is a saved embed ID or a built embed. An unknown action fails and lists the valid ones.

cancel_schedule#

Cancels a waiting schedule action.

python
await cancel_schedule(schedule_id)
python
sid = await schedule("send_message", "in 1 hour", data="Break is over!")
update_member_var("break_id", sid)
# later, in another command:
await cancel_schedule(member_var("break_id"))

Fails with "No schedule found with id ..." when it already ran or never existed.

list_schedules#

Lists the waiting schedule actions of this server.

python
await list_schedules()

Returns a list of dicts with id, action, run_at and data.

python
waiting = await list_schedules()
set_content(f"{len(waiting)} actions are waiting.")

schedule_clock#

Runs your Clock event once at a later time. Use it when the ready actions above are not enough.

python
await schedule_clock(custom_id, time, metadata)
ArgumentWhat it does
custom_idA name for this clock. Your Clock event listens for it.
timeWhen it fires, like "in 30 minutes".
metadataAny data you want back when it fires, like a dict.

Step 1. In a command, set the clock:

python
await schedule_clock(
    f"remind_{user.id}",
    when,
    {"user_id": user.id, "channel_id": channel.id, "text": text},
)
set_content("Got it. I will remind you.")

Step 2. Make an event of type Clock. In its custom IDs, enter remind_*. The * matches any ending.

python
send_message(metadata["channel_id"], f"<@{metadata['user_id']}> Reminder: {metadata['text']}")

Only the first Clock event that matches runs. See Events and Reminders.

start_job#

Starts a repeating job. Each time it is due, it fires your Clock event with the job's custom_id and metadata.

python
await start_job(
    custom_id,
    freq,
    interval=1,
    date=None,
    day_name="",
    month=None,
    hour=None,
    minute=None,
    second=None,
    metadata=None,
)
ArgumentWhat it does
custom_idA name for the job. Must be new in this server.
freqHow often: "hour", "day", "week", "month" or "year".
intervalEvery how many. 2 with "day" means every 2 days.
dateDay of the month, 1 to 31.
day_nameDay of the week, in lowercase, like "monday".
monthMonth of the year, 1 to 12.
hour, minute, secondTime of day, in your server's timezone.
metadataA dict your Clock event gets each time.

What each freq needs:

freqNeeds
hourminute, second
dayhour, minute, second
weekday_name, hour, minute, second
monthdate, hour, minute, second
yearmonth, date, hour, minute, second
python
# Every day at 9:00
await start_job("daily_quote", "day", hour=9, minute=0, second=0,
                metadata={"channel": "general"})

Premium for repeats

Jobs run only while the server has a paid plan. Without one, a job pauses itself when it is due. It picks up again after you renew.

Note

Run start_job from a command, once. A Clock event that starts its own job never runs, because the job must exist first.

You can also make jobs on the dashboard, under Jobs.

pause_job#

Pauses a running job. You can resume it from the dashboard.

python
await pause_job(custom_id)

cancel_job#

Stops a job and deletes it.

python
await cancel_job(custom_id)

Both fail when no job has that custom_id, or when it is not running.

PreviousWeb and filesNext Server events and polls

On this page

  • Limits
  • schedule
  • Actions you can schedule
  • cancel_schedule
  • list_schedules
  • schedule_clock
  • start_job
  • pause_job
  • cancel_job
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