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

Response

Change the command's own reply from code. Set the text, the embed, where it goes, and what buttons it has.

A slash or text command sends one reply after the pre-hook runs. You can type that reply in the Response box on the dashboard. The functions on this page let you change it from code instead.

These functions work in the pre-hook of slash commands and text commands. They do not exist in events. To learn the order in which a command runs, read How commands run.

You do not need to write await in front of any function on this page.

The reply is free

The command's own reply does not count toward the message limit. Use these functions for the answer. Keep send_message for extra messages. See Limits.

set_content#

Sets the text of the reply. It replaces the text from the Response box.

python
set_content(content)
python
roll = randomNumber(1, 6)
set_content(f"{user.mention} rolled a **{roll}**!")

Note

set_content is for slash commands only. In a text command, write the text in the Response box and use { } variables in it.

set_embed#

Sets the embed of the reply.

python
set_embed(embed)
ArgumentWhat it does
embedThe ID of an embed you saved on the dashboard, an embed object, or a Message(...).
python
# A saved embed. Its { } variables are filled in when the reply is sent.
set_embed("welcome-card")

# An embed built in code
set_embed(Message(title="Your balance", description=f"{coins} coins", color="#F1C40F"))

In a text command, set_embed takes a saved embed ID only.

set_response_channel#

Sends the reply to another channel instead of the channel where the command ran.

python
set_response_channel(channel)

channel is a channel object, a channel ID (a number), or the exact channel name. It must be a text channel or a thread.

python
set_response_channel("announcements")

The person who ran the command still gets a short answer in the first channel. It says "Command executed ✅". Change that text with set_response_message.

set_dm_response#

Sends the reply as a direct message.

python
set_dm_response(member=None)

With no argument, the reply goes to the person who ran the command. Pass a member to send it to someone else.

python
set_dm_response()
set_response_message("Check your DMs!")

When the DM fails, for example because the member has DMs turned off, the bot posts "Failed to DM @member" in the channel.

set_response_message#

Sets the short answer shown in the channel when the reply goes somewhere else. It only matters together with set_response_channel or set_dm_response.

python
set_response_message(message)

message is text, or a Message(...) with text and an embed.

python
set_response_channel("staff-reports")
set_response_message("Thanks! Your report was sent to the staff.")

set_components#

Adds buttons and menus to the reply.

python
set_components(builder)

builder is a ComponentBuilder. Clicks go to a handler that you make on the dashboard, or to an on_click function. See Components.

python
c = ComponentBuilder()
c.add_link_button("Open website", "https://example.com")
set_components(c)

set_view#

Adds a View to the reply. A View is a set of buttons and menus whose clicks are handled inside the same command.

python
set_view(view)

The bot sends the reply, then waits for clicks. The post-hook runs when the View has finished. Do not call view.wait() yourself after set_view.

python
view = Confirm()
view.interaction = interaction
set_view(view)
set_content("Are you sure?")

See Views for a full example.

add_attachment#

Adds a file to the reply. Call it more than once to add more files.

python
add_attachment(file, filename=None)
ArgumentWhat it does
fileA file from load_file(...) or render_template(...).
filenameA new name for the file, like "card.png".
python
card = await render_template("rank-card", name=user.display_name, level=5)
add_attachment(card)

end#

Stops the reply and the post-hook from running.

python
end()
python
if user.is_bot:
    end()

end() does not stop the pre-hook

The lines below end() still run. To stop at once and show a message, use set_error("text") instead. See Checks.

end is for slash commands only.

set_error_log_channel#

Picks a channel where the bot posts errors from this run, like an error in the post-hook.

python
set_error_log_channel(channel)
python
set_error_log_channel("bot-errors")

Errors also show on the dashboard under Logs → Error Logs.

load_embed#

Loads an embed you saved on the dashboard. Its { } variables are filled in.

python
load_embed(embed_id, **values)
ArgumentWhat it does
embed_idThe ID of the saved embed.
**valuesExtra values for the embed's variables. They win over variables with the same name.
python
embed = load_embed("level-up", level=12)
send_message("level-ups", embed=embed)

load_embed works in commands and events. It fails with "Embed with id: … not found" when the ID is wrong.

load_components#

Loads buttons and menus you saved on the dashboard under Components.

python
load_components(component_id, **values)
python
send_message(channel, "Pick your roles:", components=load_components("role-panel"))

Pass extra values the same way as load_embed.

PreviousCommon mistakesNext Messages

On this page

  • set_content
  • set_embed
  • set_response_channel
  • set_dm_response
  • set_response_message
  • set_components
  • set_view
  • add_attachment
  • end
  • set_error_log_channel
  • load_embed
  • load_components
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