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

ParameterTypeRequiredDescription
channelstringYesID of the channel that contains the target message.
messagestringYesID of the message to read mentions from.
msgdiscord.js Message | InteractionYesThe 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}`);
  },
});