Message Builder Overview
Nezon.SmartMessage helps you build all types of content to send to Mezon (text, images, files, embeds, forms, buttons...). Sub-pages in the Message Builder section go deep into each type, but first let's review the main capabilities:
| Topic | Detail Page |
|---|---|
| Text, markdown, mention | Text Message |
| Images, files, audio, GIF | Attachments |
| Embed, Form input, Button/Dropdown | Embed / Form / Button |
| Send DM, DMHelper, ManagedMessage.sendDM | DM Message |
Mention User or Role
- In the message content, place a placeholder
{{placeholder_name}}where you want to mention. - Use
SmartMessage.addMention('placeholder_name', 'USER_ID')to mention a user by ID or pass an object{ user_id, username? }. - To mention a role, pass
{ role_id: 'ROLE_ID' }or{ role_name: 'Role Name' }. The SDK will find the corresponding role to render@Role. SmartMessageautomatically inserts amentionsarray with accurate positions (s,e) and replaces the placeholder with the user or role name.
See API details: SmartMessage → .addMention.
Quick Example
import {
Command,
AutoContext,
SmartMessage,
ButtonBuilder,
ButtonStyle,
} from "@n0xgg04/nezon";
import type { Nezon } from "@n0xgg04/nezon";
@Command("demo")
export class DemoCommand {
async execute(@AutoContext() [message]: Nezon.AutoContext) {
await message.reply(
SmartMessage.text("Choose an action:")
.addImage("https://picsum.photos/400/200", { filename: "banner.jpg" })
.addEmbed(
new Nezon.EmbedBuilder()
.setTitle("Survey")
.setDescription("What feature do you like most?")
.addTextField("Feedback", "feedback", {
placeholder: "Write your feedback here",
})
)
.addButton(
new ButtonBuilder()
.setLabel("Submit Feedback")
.setStyle(ButtonStyle.Success)
.setCustomId("/feedback/submit")
)
);
}
}
The feedback form will appear below the embed. When the user clicks the /feedback/submit button, you can read the data back using @FormData('feedback') in the component/onClick handler.
Basic SmartMessage
SmartMessage.text()– send regular message.SmartMessage.system()– wrap content in code block style.SmartMessage.build()– create empty message then attach embed/button/attachments.SmartMessage.addGIF(url)– add GIF (filetypeimage/gif).
Other methods:
| Method | Description |
|---|---|
.addButton(builder) | Add button or dropdown (when builder is select) |
.addEmbed(builder) | Add embed (combine with form inputs) |
.addImage(url) / .addFile() / .addVoice() | Add attachments |
.addMention(...) | Create placeholder to mention user/role with new form |
Details: see each page in the table above.
Suggested Flow
- Text & mention – page Text Message explains
SmartMessage.system, markdown,addMention. - Media – page Attachments describes
addImage,addFile,addVoice,addGIF. - Interactive embed – page Embed / Form / Button guides
EmbedBuilder, form input, button. - DM – page DM Message describes
DMHelperandManagedMessage.sendDM.
After building the message, see Sending Messages to know when to use ManagedMessage, ChannelHelper, or DMHelper depending on context.