Discord Bot: Slash Commands and Server Management
Set up slash commands, manage roles, and send rich embeds to make your OpenClaw agent a powerful Discord community tool.
What You Will Get
By the end of this guide, your OpenClaw agent will be a fully functioning Discord bot with registered slash commands, role management capabilities, and beautifully formatted rich embed messages. Your community members will be able to interact with the agent using Discord-native slash commands that appear in the autocomplete menu.
Discord's slash command system provides a structured, discoverable way for users to interact with your bot. Combined with rich embeds, your agent's responses will stand out with colored sidebars, thumbnails, fields, and footers that match your server's branding.
You will also learn how to manage server roles through the bot, allowing automated role assignment based on user interactions, verified status, or custom criteria you define in your agent's logic.
Step-by-Step Setup
Configure slash commands, role management, and rich embeds for your Discord bot.
Open Discord Channel Settings
Navigate to your agent's Channels tab on the RunTheAgent dashboard and select Discord. Enter your bot token and application ID if you have not already connected. The bot must have the applications.commands scope enabled in the Discord developer portal.
Register Slash Commands
In the Discord channel settings, open the Slash Commands section. Define each command with a name, description, and optional parameters. For example, create a /ask command with a question parameter, or a /status command with no parameters. Commands are registered globally and become available in the autocomplete menu within an hour.
Configure Command Responses
For each slash command, define how your agent should respond. You can set up direct text replies, ephemeral messages visible only to the user, or deferred responses for longer processing tasks. Map each command to specific agent behaviors or prompts in your agent configuration.
Set Up Rich Embeds
Enable rich embed formatting in the response settings. Configure default embed colors, thumbnail images, and footer text that match your server branding. Your agent can dynamically populate embed fields, titles, and descriptions based on the conversation context. Test embeds by invoking a slash command and verifying the formatting looks correct.
Configure Role Management
Grant your bot the Manage Roles permission in your Discord server settings. Then configure role assignment rules in the channel settings panel. You can set up automatic role assignment when users complete certain interactions, or allow your agent to assign roles on request through a dedicated slash command.
Set Channel Permissions
Define which Discord channels the bot should monitor and respond in. You can restrict the bot to specific channels, allow it server-wide, or configure different behaviors per channel. This prevents the bot from responding in channels where it is not wanted and keeps interactions organized.
Test and Deploy
Invite the bot to a test server or use a test channel. Run through each slash command, verify embeds render correctly, and test role assignment. Check the RunTheAgent logs for any errors. Once everything works, enable the bot for your full server and announce it to your community.
Tips and Best Practices
Use Ephemeral Replies for Sensitive Data
Mark responses as ephemeral when they contain user-specific or sensitive information. Ephemeral messages are only visible to the user who triggered the command, keeping the channel clean.
Register Commands per Guild for Testing
During development, register commands as guild-specific rather than global. Guild commands update instantly, while global commands can take up to an hour to propagate.
Organize Commands with Subcommands
Group related functionality under a single parent command using subcommands. For example, /settings get and /settings update keeps things organized and easy to discover.
Respect the Role Hierarchy
Your bot can only manage roles that are below its own role in the server hierarchy. Position the bot's role appropriately in Server Settings to ensure it can assign the roles you need.
Frequently Asked Questions
Related Pages
Ready to get started?
Deploy your own OpenClaw instance in under 60 seconds. No VPS, no Docker, no SSH. Just your personal AI assistant, ready to work.
Starting at $24.50/mo. Everything included. 3-day money-back guarantee.