Skip to content

Responding to messages

Not supported on TEBHOS

TEBHOS has no application commands (slash commands), no interactions endpoint, and no message components or modals. There is nothing to register and no INTERACTION_CREATE event. Bots implement commands by reading ordinary messages, as described on this page.

The usual pattern is a prefix command: the bot listens for MESSAGE_CREATE on the gateway, checks whether the message starts with its prefix (for example !), and answers with a REST call.

Receive messages

Every message posted in a channel the bot can view arrives as a MESSAGE_CREATE dispatch. The payload is a message object at the top level of d. Fields a command handler typically needs:

Field Type Description
id snowflake Message ID
channel_id snowflake Channel the message was posted in
guild_id? snowflake Guild of the channel. Absent for direct and group messages
author object The sender: id, username, discriminator, global_name, avatar, and bot: true for bot accounts
content string Full message text. Bots always receive it; there is no privileged intent to request
mentions array Users mentioned in the message
webhook_id? snowflake Present when a webhook posted the message
message_reference? object Present when the message replies to or forwards another message
member? object The author's guild member object, on guild messages
{
  "op": 0,
  "t": "MESSAGE_CREATE",
  "s": 17,
  "d": {
    "id": "1290851938027593728",
    "channel_id": "1290849012346880000",
    "guild_id": "1290848871133052928",
    "author": {
      "id": "1290845402212401152",
      "username": "deniz",
      "discriminator": "0042",
      "global_name": "Deniz",
      "avatar": null,
      "flags": 0
    },
    "type": 0,
    "content": "!ping",
    "timestamp": "2026-09-23T08:15:02.114Z",
    "edited_timestamp": null,
    "mentions": [],
    "mention_roles": [],
    "attachments": [],
    "embeds": []
  }
}

Edits arrive as MESSAGE_UPDATE and deletions as MESSAGE_DELETE (id, channel_id, and the deleted message's content and author_id). See Gateway events.

Ignore yourself and other bots

Compare author.id with the user.id from READY and skip your own messages. Also skip messages whose author.bot is true unless you really want bots to trigger each other; otherwise two bots can answer each other forever.

Parse a prefix command

const PREFIX = "!";

function parseCommand(message, botUserId) {
  if (message.author.id === botUserId || message.author.bot) return null;
  const content = message.content.trim();
  if (!content.startsWith(PREFIX)) return null;
  const [name, ...args] = content.slice(PREFIX.length).split(/\s+/);
  return { name: name.toLowerCase(), args };
}

Mentions are written in message text as <@user_id>, so a bot can also treat messages that start with <@{bot_user_id}> as commands.

Send a message

POST /channels/{channel_id}/messages

Posts a message as the bot. Requires the View Channel and Send Messages permissions in that channel. Rate limit: 20 messages per 10 seconds per sender per channel; see Rate limits.

Field Type Description
content? string Message text, up to 4000 characters for bots. Required unless embeds, attachments or sticker_ids are given
embeds? array Up to 10 rich embeds: title, description, url, color, timestamp, author, image, thumbnail, footer, fields. Requires Embed Links. See Embed limits
message_reference? object Makes the message a reply: {"message_id": "..."}
allowed_mentions? object Limits which mentions in content notify people
tts? boolean Text-to-speech; needs the Send TTS Messages permission
sticker_ids? array Up to 3 sticker IDs

The full field list, attachments included, is in Messages. The response is 200 with the created message object.

curl -X POST https://tebhos.com/api/v1/channels/1290849012346880000/messages \
  -H "Authorization: Bot $TEBHOS_BOT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"content": "pong"}'

Reply to a message

Add message_reference with the ID of the message you answer. The referenced message must be in the same channel.

{
  "content": "pong",
  "message_reference": { "message_id": "1290851938027593728" }
}

Other useful calls

Action Endpoint
Show "Bot is typing..." while you work POST /channels/{channel_id}/typing
Edit a message the bot sent PATCH /channels/{channel_id}/messages/{message_id} with {"content": "..."}
Delete a message DELETE /channels/{channel_id}/messages/{message_id} (another user's message needs Manage Messages)
React to a message PUT /channels/{channel_id}/messages/{message_id}/reactions/{emoji}/@me
Fetch recent messages GET /channels/{channel_id}/messages (needs Read Message History)

Permissions

A bot can only read and write where its roles allow. When the bot was added with a permissions value, TEBHOS created a role with exactly those permissions and gave it to the bot; guild administrators can change that role or channel overwrites at any time. A request the bot is not allowed to make fails with 403; branch on the status, not on the error text. See Permissions and Adding a bot to a guild.

Complete example

Examples has runnable JavaScript and Python bots that connect to the gateway, handle READY and MESSAGE_CREATE, and answer !ping with pong.