cmd.message.mentions
Fetches a message by ID from a given channel and returns all the user, channel, and role mentions it contains.
JavaScript
const { cmd } = require("syntx.js");
await cmd.message.mentions({ channel, message }, msg);Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
channel | string | Yes | ID of the channel that contains the target message. |
message | string | Yes | ID of the message to read mentions from. |
msg | discord.js Message | Interaction | Yes | The message or interaction context. |
Returns
TypeScript
{
users: string[] | null,
channels: string[] | null,
roles: string[] | null
}Each key holds an array of IDs, or null if nothing of that type was mentioned.
Example
JavaScript
client.command({
name: "mentions",
content: async (message) => {
const result = await cmd.message.mentions(
{
channel: message.channel.id,
message: "MESSAGE_ID",
},
message
);
const users = result.users?.map(id => `<@${id}>`).join(", ") ?? "None";
const channels = result.channels?.map(id => `<#${id}>`).join(", ") ?? "None";
const roles = result.roles?.map(id => `<@&${id}>`).join(", ") ?? "None";
message.reply(`Users: ${users}\nChannels: ${channels}\nRoles: ${roles}`);
},
});