Custom Commands homeCustom Commands
  • Blog
  • Privacy
  • Premium
  • Support
Back to blog
// blog

Meet ask_ai — Real AI Inside Your Custom Commands

Drop a single line into any command and get a written AI response back — welcome messages, summaries, replies, and more, generated on the fly.

Md Shahriyar Alam

11 days ago

·6 min read

Your commands can now think out loud. With one awaited line, ask_ai sends a prompt to our built-in AI and hands back a finished, written response you can drop straight into a message, an embed, or a variable.

No API keys. No external setup. No webhooks.

python
answer = await ask_ai("Write a short, warm welcome message")

That's the whole thing. answer now holds real generated text, ready to use.

The signature

python
answer = await ask_ai(
    prompt,                 # required — what you want, in plain English
    instructions=None,      # optional — persona / tone / style
    max_words=None,         # optional — cap the answer length (words)
    use_context=True,       # optional — let the AI know about this server
)

Only prompt is required. It must be awaited — ask_ai is asynchronous, and without await you get an unfinished coroutine, not text.

It returns a plain string, so you can store it, template it into a response, save it to a variable, or pass it anywhere a string is expected. And it runs inside the same sandbox as the rest of your command, so it works alongside your options, variables, members, and everything else.

Your first command

A complete /ask command: one text option named question, and this in the code:

python
reply = await ask_ai(question)

Response content:

code
{reply}

Run /ask question: how do I set a nickname? and your members get a real, written answer.

instructions — give it a voice

The second argument sets a persona or style. The AI honors it, but it can never be used to override safety or identity.

python
answer = await ask_ai(
    "Welcome the new member",
    instructions="Talk like a friendly pirate",
)
python
answer = await ask_ai(
    "Explain our rules channel",
    instructions="Warm, concise, no more than a greeting and one tip",
)

max_words — keep it tidy

Cap the length of the reply. It can only lower the ceiling (the hard maximum is 1024 words), never raise it.

python
short = await ask_ai("Summarize this server's purpose", max_words=40)

Combine it with instructions for tightly controlled output:

python
tagline = await ask_ai(
    "Write a tagline for a gaming community",
    instructions="Punchy, no emoji",
    max_words=12,
)

use_context — it already knows your server

By default (use_context=True), the AI is handed a safe snapshot of the current server before it answers:

  • Who ran it — the member's name, roles, whether they're an admin, when they joined.
  • The server — name, member count, owner, boost tier, age.
  • Your commands and events — a compressed description of every command and event on the server, including each option's name, type, whether it's required, and what it does.

So this actually works:

python
answer = await ask_ai("What commands can I use here, and what do they do?")

The AI answers from your server's real command list — not a generic guess. It learns what your commands do (never their source code — only their behavior), and that knowledge is cached and only refreshed when your commands change.

Turn it off for pure, context-free generation:

python
answer = await ask_ai("Write a haiku about autumn", use_context=False)

Combine it with options and variables

python
topic = subject
answer = await ask_ai("Give three quick tips about " + topic)
python
name = member.display_name
greeting = await ask_ai(
    "Write a one-line welcome for " + name,
    instructions="Cheerful",
    max_words=25,
)

Response content:

code
{greeting}

Where it shines

  • Dynamic welcome messages — a fresh greeting for every new member instead of one static line.
  • On-demand answers — a /ask or /help command that responds in natural language, aware of your actual commands.
  • Summaries — feed it text, ask for a short version with max_words.
  • Rewrites and tone — turn a blunt note friendly, or the reverse, via instructions.
  • Flavor and fun — jokes, prompts, story hooks, roleplay, name ideas.

Premium and fair-use limits

ask_ai is a premium helper. Each tier gets a daily allowance of AI calls, a per-server cooldown between calls, and a prompt-length limit:

StarterBasicAdvanced
Daily AI calls100200500
Cooldown (whole server)1 call / 10s1 call / 5s1 call / 1s
Max prompt length500 chars1,000 chars2,000 chars

Watch usage live on the AI Usage card in your dashboard — daily, monthly, and total, with your tier's cap shown.

A few things to know:

  • The cooldown is server-wide, not per-member — it paces the whole server's usage.
  • Repeated prompts are free and instant. Ask the exact same thing again (same prompt and context) within the hour and the previous answer is replayed — no wait, no API call, no dent in your daily count.
  • When you hit the daily cap, ask_ai pauses until the next day; everything else in your command keeps running. Upgrading raises the ceiling.

If your server isn't premium, ask_ai politely stops the command with a message telling you it's a premium feature.

What it returns — and how to handle it

ask_ai always returns a string:

  • Normally, that string is the AI's answer.
  • If a request can't be answered safely, it returns a short refusal — "I can't help with that request." — and your command keeps running, so you can check for it:
python
answer = await ask_ai(question)
set_variable("last_answer", answer)

The only cases that actually stop the command (with a clear message) are the limits above — not premium, missing configuration, prompt too long, cooldown, or daily cap reached. Content is never a hard error; it's just a refusal string.

Built to stay safe

Every generated reply passes through moderation before it reaches your server — fail-closed, so if anything is uncertain, nothing questionable is posted. The assistant also has a fixed identity ("Custom Commands V1") and won't reveal or be talked out of it. You get the creativity without the risk.

Tips for great results

  • Be specific. "Write a two-sentence welcome mentioning our rules channel" beats "say hi."
  • Set the length with max_words — "one line," "two sentences," or a small number.
  • Set the tone with instructions.
  • Feed it context. Pass option values and variables so the answer fits the moment — and leave use_context on so it knows your server.
  • Remember the await. Leave it out and the value won't be there.

Try it today

Open any premium server, add a command, and drop in:

python
answer = await ask_ai("Introduce yourself in one friendly sentence")

Set the response to {answer}, save, and run it. That's AI in your commands — in under a minute.

Loading comments…

{}

Need help?

Have a question, a suggestion, or stuck on something? Reach out — we're happy to help.

DiscordJoin support server
Custom CommandsCustom Commands

The #1 custom commands Discord bot — build commands, events and databases with zero boilerplate.

Links

HomeBlogPrivacySupport

Contact

[email protected]

2 Frederick StreetLondon, WC1X 0ND

{ / } custom commands

© WEiRDSOFT LTD. All rights reserved.