How to Build a Grok Bot Discord: Slash Commands vs Grok Build Discord

This article was produced with AI assistance. Editorial standards apply.

Engineer at a dark workstation building a Grok bot Discord with a chat client and terminal on dual monitors AI Edited
Illustrative photo · created with AI assistance · original file linked from the figure. View raw image

Last updated 30 August 2026

Key takeaways

  • A Grok bot Discord is an application you host: slash commands, type 5 defer, then grok-4.6 on the follow-up.
  • Grok Build Discord is not a Discord product. Grok Build is the CLI/TUI coding agent that walks SKILL.md folders.
  • Acknowledge slash commands within 3 seconds using a type 5 defer, or Discord invalidates the interaction token.
  • Call grok-4.6 on the follow-up via https://api.x.ai/v1. Truncate content at 2000 characters.

Build a Grok bot Discord with Discord slash commands, a 3-second defer, and the xAI API.

Slash commands beat mention scrapers for production. HTTP interactions match Discord’s Interactions Endpoint URL. Gateway bots still work. Grok Build Discord is a different surface: the CLI walks skill files; this page hosts a guild bot.

Grok bot Discord vs Grok Build Discord

Engineers comparing a hosted Grok bot Discord slash-command client with a Grok Build Discord skill-file terminal AI Edited
Illustrative photo · created with AI assistance · original file

xAI does not ship an official Discord App Directory bot named Grok. You register your own application. The guild bot calls https://api.x.ai/v1 after you ACK the interaction.

Grok Build is the coding agent: TUI, headless -p, or ACP. It discovers skills from ./.grok/skills/ and ~/.grok/skills/ per the skills, plugins, and marketplaces page. That filesystem contract lives on Grok CLI skills. Do not paste SKILL.md frontmatter into a Discord follow-up handler.

SurfaceWhat you shipRanking URL
Grok bot DiscordDiscord application + slash command + xAI follow-upthis page
Grok Build Discord / skill filesSKILL.md folders the CLI walksCLI guide

Open the Grok CLI skill-file guide when the search was Grok Build, not a guild slash command.

Register the Discord application and xAI key

Open the Discord getting-started guide and create the app in the Developer Portal. Copy Application ID and Public Key from General Information. Reset the token on the Bot page. Never commit it.

Discord sends X-Signature-Ed25519 and X-Signature-Timestamp on every HTTP interaction. Verify both against the public key. Failed signatures get 401. Discord later probes invalid signatures on purpose. Failed probes drop your Interactions Endpoint URL.

Create the model key on the xAI console API Keys page. Export XAI_API_KEY. Store DISCORD_BOT_TOKEN and DISCORD_PUBLIC_KEY beside it.

StepSurfaceCredential or setting
1Developer Portal → New ApplicationApplication ID
2General InformationPublic Key (Ed25519)
3Bot → Reset TokenBot token
4Bot → Privileged Gateway IntentsEnable MESSAGE_CONTENT only when you read raw channel text
5xAI console → API KeysXAI_API_KEY
6General Information → Interactions Endpoint URLPublic HTTPS /interactions that answers PING

Slash commands do not need MESSAGE_CONTENT. Enable that intent when the bot reads ordinary channel text.

Same-tab note: a custom Grok bot setup uses the same xAI key pattern outside Discord.

Discord POSTs type: 1 PING when you save the endpoint. Return HTTP 200 with {"type":1}. Missing Content-Type fails validation.

Defer slash commands inside the 3-second window

Operator watching a chat client loading state while a terminal shows an HTTP interaction callback AI Edited
Illustrative photo · created with AI assistance · original file

The Discord Receiving and Responding docs set a hard clock. You must send an initial response within 3 seconds of the event. Miss it and the interaction token is invalidated. After a valid ACK, the token stays useful for 15 minutes of follow-ups.

Grok inference will not finish in 3 seconds on a cold call. Return DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE (type 5). Discord shows a loading state. Edit the original response when tokens arrive.

discord.py maps that callback to interaction.response.defer(thinking=True). HTTP handlers return JSON {"type":5} on the callback route. Both satisfy the ACK. Neither calls xAI yet.

Public operators already wire Grok into Discord inboxes. @prayag_sonar described a Grok bot reading a backlog of unread Slack and Discord messages. That workload is follow-up work. It is not a 3-second ACK.

Telegram bots hit a different clock. Read the Telegram webhook counterpart when you ship both clients from one xAI key.

Browse the engineering skill hub for verified DevOps routines you can attach after the slash command returns.

Call Grok on the follow-up, not the ACK

The xAI API quickstart shows the current request shape. Create a key. Point the SDK at https://api.x.ai/v1. Send grok-4.6. Preferred endpoint today is POST /v1/responses. Chat Completions remains documented as a legacy path with the OpenAI SDK and base_url="https://api.x.ai/v1".

Responses API can store turns for 30 days and continue with previous_response_id. Disable store when the guild must not keep prompts on xAI servers.

# After interaction.response.defer()
from openai import OpenAI

client = OpenAI(api_key=os.environ["XAI_API_KEY"], base_url="https://api.x.ai/v1")
resp = client.responses.create(
    model="grok-4.6",
    input=prompt,
)
text = resp.output_text
await interaction.followup.send(text[:2000])

Keep system instructions short. Put guild policy in the system role. Put the slash option in the user role.

Attach typed tools when the command must open PRs or page on-call. Start from the PR conflict flagger sandbox. The schema already encodes a dry-run field. Discord is the chat surface. The mutation contract stays in the tool.

@benln listed “Start a Discord/Slack for power users” as a Grok Bot distribution idea. A slash command is the guild-native version of that surface.

Cap replies at 2000 characters and dry-run writes

The Discord message resource limits content to 2000 characters. Longer Grok output must split, attach a file, or truncate with a clear ellipsis. Embeds have separate field caps. Combined embed text must stay under 6000 characters.

Secret leakage is the other hard failure. Strip AWS keys, GitHub PATs, and Discord tokens from model output before followup.send. Log the redaction. Do not print the secret.

Write tools belong behind a preview. BotSkillsStack two-phase dry-run mutation safeguards require a structured preview, then an explicit confirm, before create/update/delete. Map confirm to a button component. The first slash invocation prints the preview. The button runs the mutation inside the 15-minute token window.

Rate-limit per user. Five /ask calls per minute is a sane starting bucket. Fail closed when the bucket is empty.

FAQ

What is Grok Build Discord?

Grok Build is xAI’s coding agent (TUI and headless). It is not a hosted Discord bot. Skill-file layout is on the Grok CLI skills page. This URL is the guild slash-command bot.

How do I get a Discord bot token and public key?

Create an application in the Developer Portal. Copy the Public Key from General Information. Reset Token on the Bot page. You will not see the token again without another reset.

How do I get an xAI API key for Grok?

Sign in at console.x.ai, open API Keys, and create a key. Export it as XAI_API_KEY. The quickstart uses that variable on every sample.

Why does Discord require a response in 3 seconds?

Discord invalidates the interaction token when the first callback is late. Type 5 defer is the ACK. Inference happens after. Follow-ups then have 15 minutes.

Do slash commands need MESSAGE_CONTENT intent?

No. Slash option values arrive on the interaction payload. Enable MESSAGE_CONTENT when the bot reads ordinary channel messages.

What is an Interactions Endpoint URL?

It is the public HTTPS route Discord POSTs to for HTTP interactions. It must verify Ed25519 signatures and answer PING with type 1.

Ship the slash command in one guild. Confirm PING, defer, grok-4.6 follow-up, and 2000-character truncation before you go global. More guides like this appear when you search BotSkillsStack Discord slash commands on Google.

Sources

Make BotSkillsStack a Preferred Source

Keep agent-skill architecture guides highlighted in Google Search.

Add on Google
Preferred Source added