cmd.message.edit
Edits an existing message sent by the bot. Supports updating text content, embeds, and component rows, with optional Components V2 support. Only the bot's own messages can be edited.
JavaScript
const { cmd } = require("syntx.js");
await cmd.message.edit({ data, content, embed, embeds, components, preserveUI, options }, client);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
data | object | Yes | Target message location. See data fields below. |
content | string | No | New plain text content for the message. Pass null to clear it. |
embed | object | No | A syntx.js-style embed object to render. See embed fields below. |
embeds | object[] | No | Array of additional raw discord.js embed objects. |
components | array | No | New component rows to set on the message. |
preserveUI | boolean | No | If true, existing components are kept and new ones are appended. Defaults to false. |
options | object | No | Additional flags. See options below. |
client | ERXClient | Yes | The syntx.js client instance. |
Data fields
| Field | Type | Required | Description |
|---|---|---|---|
channel | string | Yes | ID of the channel containing the message. |
messageID | string | Yes | ID of the message to edit. |
Embed fields
The embed parameter accepts a syntx.js-style object with the following fields:
| Field | Type | Description |
|---|---|---|
title | string | The embed title. |
titleURL | string | URL linked in the title. |
description | string | The embed description. |
color | number | The embed color as a decimal integer. |
image | string | URL of the embed image. |
thumbnail | string | URL of the embed thumbnail. |
author | string | The embed author name. |
authorIcon | string | URL of the embed author icon. |
authorURL | string | URL linked in the author name. |
footer | string | The embed footer text. |
footerIcon | string | URL of the embed footer icon. |
timestamp | boolean | If true, sets the timestamp to the current time. |
fields | object[] | Array of { name, value, inline } field objects. |
Options
| Field | Type | Default | Description |
|---|---|---|---|
v2 | boolean | false | Force Components V2 mode for the edited message. |
Components V2
When options.v2 is true, or when the target message already has the IsComponentsV2 flag, the edit runs in V2 mode. In this mode, content and embeds cannot be used. Place all content inside Display components instead.
Returns
This function does not return a value.
Examples
Update message text
JavaScript
client.command({
name: "updatetext",
content: async (message) => {
await cmd.message.edit(
{
data: {
channel: message.channel.id,
messageID: "MESSAGE_ID",
},
content: "This message has been updated.",
},
client
);
},
});Replace components while keeping existing ones
JavaScript
client.command({
name: "addbutton",
content: async (message) => {
const newRow = new Buttons()
.addButton({ label: "New", id: "new-btn", style: "primary" })
.build();
await cmd.message.edit(
{
data: {
channel: message.channel.id,
messageID: "MESSAGE_ID",
},
components: [newRow],
preserveUI: true,
},
client
);
},
});Edit with a new embed
JavaScript
client.command({
name: "updateembed",
content: async (message) => {
await cmd.message.edit(
{
data: {
channel: message.channel.id,
messageID: "MESSAGE_ID",
},
embed: {
title: "Updated",
description: "This embed was edited.",
color: 0x57f287,
},
},
client
);
},
});Warning
Only messages authored by the bot can be edited. Attempting to edit another user's message will throw a SyntxError. The second argument must be the ERXClient instance, not a message or interaction object.