Message
Message wraps a Discord message object and exposes resource methods to interact with it directly โ no manager lookups required.
import { Message } from "lunibee";import { Message } from "lunibee";Properties
Section titled โPropertiesโ| Property | Type | Description |
|---|---|---|
id |
string |
Snowflake ID of the message. |
content |
string |
Text content of the message. |
author |
User |
The user who sent the message. |
channelId |
string |
ID of the channel this message belongs to. |
channel |
Channel |
The channel this message was sent in. |
guildId |
string | undefined |
Guild ID, if the message is in a guild. |
flags |
number |
Raw message flags bitfield. |
timestamp |
Date |
When the message was created. |
createdAt |
Date |
Alias for timestamp. |
createdTimestamp |
number |
Unix timestamp (ms) of creation. |
attachments |
APIAttachment[] |
File attachments on this message. |
embeds |
APIEmbed[] |
Embeds on this message. |
components |
APIMessageComponent[] |
Interactive components on this message. |
mentions |
User[] |
Users mentioned in this message. |
mentionRoles |
string[] |
Role IDs mentioned in this message. |
mentionEveryone |
boolean |
Whether @everyone or @here was used. |
pinned |
boolean |
Whether the message is pinned. |
type |
number |
Message type (0 = default, 19 = reply, etc.). |
Boolean Getters
Section titled โBoolean Gettersโ| Getter | Description |
|---|---|
isEphemeral |
true if the message is only visible to the recipient. |
isPinned |
true if the message is pinned. |
isSystemMessage |
true if this is a system message (join, boost, etc.). |
isCrosspost |
true if crossposted from an announcement channel. |
hasAttachments |
true if the message has file attachments. |
hasEmbeds |
true if the message has embeds. |
hasComponents |
true if the message has interactive components. |
embedsSuppressed |
true if link embeds are suppressed. |
Methods
Section titled โMethodsโreply(options)
Section titled โreply(options)โclient.on("messageCreate", async (message) => { if (message.content === "!hello") { await message.reply("Hello back! ๐"); // or with a full payload: await message.reply({ content: "Hello!", embeds: [embed] }); }});client.on("messageCreate", async (message) => { if (message.content === "!hello") { await message.reply("Hello back! ๐"); // or with a full payload: await message.reply({ content: "Hello!", embeds: [embed] }); }});edit(options)
Section titled โedit(options)โconst updated = await message.edit({ content: "Edited content!" });const updated = await message.edit({ content: "Edited content!" });delete() / pin() / unpin() / crosspost() / suppressEmbeds()
Section titled โdelete() / pin() / unpin() / crosspost() / suppressEmbeds()โawait message.delete();await message.pin();await message.unpin();await message.crosspost();await message.suppressEmbeds();react(emoji) / removeReaction(emoji, userId?) / removeAllReactions()
Section titled โreact(emoji) / removeReaction(emoji, userId?) / removeAllReactions()โawait message.react("๐");await message.react("<:lunibee:123456789>");await message.removeReaction("๐"); // bot's ownawait message.removeReaction("๐", userId); // specific userawait message.removeAllReactions();await message.react("๐");await message.react("<:lunibee:123456789>");await message.removeReaction("๐");await message.removeReaction("๐", userId);await message.removeAllReactions();Examples
Section titled โExamplesโLog every message
client.on("messageCreate", (message) => { if (message.author.bot) return; console.log(`[${message.channelId}] ${message.author.username}: ${message.content}`);});client.on("messageCreate", (message) => { if (message.author.bot) return; console.log(`[${message.channelId}] ${message.author.username}: ${message.content}`);});Delete a message after 5 seconds
client.on("messageCreate", async (message) => { if (message.content === "!self-destruct") { const reply = await message.reply("๐ฃ Self-destructing in 5 seconds..."); setTimeout(() => reply.delete(), 5000); }});client.on("messageCreate", async (message) => { if (message.content === "!self-destruct") { const reply = await message.reply("๐ฃ Self-destructing in 5 seconds..."); setTimeout(() => reply.delete(), 5000); }});