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

Concepts

View .md

Permissions and cooldowns

Choose who can use a command, where it works, and how often.

There are two ways to limit a command:

  • On the form. No code. Best for most commands.
  • In code. For rules the form cannot express, like "only on weekends" or "once per day per server".

On the form#

Switch the command form to Advanced, then open Permissions.

Discord permissions#

Pick the Discord permissions a member needs, like Ban Members. Discord hides the command from members without them.

This works for top-level slash commands only. It is not available in sub commands.

Roles and channels#

FieldWhat it does
Allowed rolesOnly members with one of these roles can use it.
Blocked rolesMembers with any of these roles cannot use it.
Allowed channelsIt only works in these channels.
Blocked channelsIt does not work in these channels.

Empty means no limit: Everyone and Every channel.

In code#

Put these at the top of the Pre-hook. Each one stops the command with an error when the check fails. You do not need an if around them.

require_permission#

python
require_permission("ban_members")

The member needs every permission listed. Administrators always pass. Permission names are lowercase with underscores, like manage_messages, kick_members, manage_server.

Roles#

python
allowed_roles("Staff", "Moderator")
banned_roles("Muted")

allowed_roles passes when the member has any of the roles. Use names, IDs or mentions.

Channels#

python
allowed_channels("bot-commands")
banned_channels("general", "announcements")

Every check takes error_message= for your own text:

python
allowed_roles("VIP", error_message="This command is for VIP members.")

Cooldowns#

A cooldown stops people from running a command too often.

python
cooldown("30 seconds")

The time is plain English: "10 seconds", "5 minutes", "1 hour", "1 day".

Per user, per server, or shared#

By default each user has their own cooldown. Change who shares it with key=:

CodeWho shares the cooldown
cooldown("1 hour")Each user on their own
cooldown("1 hour", key=server.id)The whole server
cooldown("1 hour", key=channel.id)Everyone in one channel

Allow a few uses first#

count= lets someone run it several times before the cooldown starts:

python
cooldown("1 minute", count=3)

A nice message#

error_message= can show when the cooldown ends:

python
cooldown("1 day", error_message="You already claimed today. Come back %relative%.")
PlaceholderShows
%time%How long to wait, like 5 minutes
%relative%A live countdown, like in 5 minutes
%at%The time it ends, in each reader's own timezone
%timestamp%The raw time number, for your own Discord timestamp

Tip

Put cooldown(...) after your other checks. Then someone who fails a role check does not use up their cooldown.

Checks in your own logic#

To decide something without stopping the command, use has_role or has_permission. They give True or False:

python
if has_role(user, "VIP"):
    reward = 200
else:
    reward = 100

Full list: Checks reference.

PreviousSaving dataNext Limits and premium

On this page

  • On the form
  • Discord permissions
  • Roles and channels
  • In code
  • require_permission
  • Roles
  • Channels
  • Cooldowns
  • Per user, per server, or shared
  • Allow a few uses first
  • A nice message
  • Checks in your own logic
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