Skip to main content

Messages

These examples use a connected client and a string channelId.

Send, edit, and reply

Send accepts a string or a message body. For text supplied by users, you can disable mention parsing explicitly:
Use message.reply() inside a messageCreate handler to attach a reply reference:
Replies default to allowed_mentions: { parse: [], replied_user: false }, so they do not ping the original author. Pass your own allowed_mentions in the message body to change that behaviour. Plain send() does not set this default. Message objects hold frozen snapshots. edit() returns a new Message; an older object still contains the original content. The raw payload is available as message.data.

Attach files

Pass Blob values and filenames through the second options argument. Talos builds the multipart body and attachment IDs:
For the API’s separate upload flow, upload first and pass the returned attachment descriptors into the message body:
uploads.upload() accepts 1–10 files, has a five-minute deadline by default, and does not send a message. Instance limits still apply. Its onProgress callback reports completed file bytes rather than progress within each transfer.

Read history

Fetch a single message when you know its ID:
Use history() to iterate newest first. It fetches pages as you consume them, with up to 100 messages per request:
Set before to a message ID to start further back. Omitting limit walks all available history. Breaking out of the loop stops further page requests. Use list() if you need a single page; its query fields follow the API schema, so a page limit is a string such as { limit: "50" }.

Cancel an operation

Message methods accept signal, timeoutMs, and reason in their options. For example:
Cancellation stops local waiting and network work. It does not undo a message already accepted by the server. See REST retries before retrying a failed send.

Pins and deletion

message.pin(), message.unpin(), and message.delete() operate on that message. client.messages.pins(channelId) returns { items, hasMore }; each item contains a message and pinnedAt timestamp. client.messages.bulkDelete(channelId, ids) requires 1–100 unique IDs. Talos checks that shape locally; the server decides whether the bot is allowed to delete those messages. Message-update events are partial payloads. Use messageUpdate to learn which message changed, then fetch it if your handler needs complete data. See gateway events.