API reference
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.
set_content(content)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.
set_embed(embed)| Argument | What it does |
|---|---|
embed | The ID of an embed you saved on the dashboard, an embed object, or a Message(...). |
# 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.
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.
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.
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.
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.
set_response_message(message)message is text, or a Message(...) with text and an embed.
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.
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.
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.
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.
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.
add_attachment(file, filename=None)| Argument | What it does |
|---|---|
file | A file from load_file(...) or render_template(...). |
filename | A new name for the file, like "card.png". |
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.
end()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.
set_error_log_channel(channel)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.
load_embed(embed_id, **values)| Argument | What it does |
|---|---|
embed_id | The ID of the saved embed. |
**values | Extra values for the embed's variables. They win over variables with the same name. |
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.
load_components(component_id, **values)send_message(channel, "Pick your roles:", components=load_components("role-panel"))Pass extra values the same way as load_embed.