1

I have this code which advertises to server admins and mods when someone tags an important user on the server (a user who should not be tagged).

Here's the code.

client.on('messageCreate', message => {
    if(message.author.bot || message.channel.type === `DM`) return;

    if(message.mentions.members.get(`332599069027598336`)){
        message.reply(`The user ${message.author} has mentioned ${message.mentions.members.get(`332599069027598336`).user.tag}`);
    }
});
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
rs0021
  • 13
  • 2
  • Does this question help: https://stackoverflow.com/questions/52258064/discord-js-sending-a-message-to-a-specific-channel? – Luke Trenaman Nov 21 '21 at 02:08

1 Answers1

0

First you need to get the channel id. client.channels.cache.get('YOUR_CHANNEL_ID')

Then you send it to a specific channel. .send(`The user ${message.author} has mentioned ${message.mentions.members.get(`332599069027598336`).user.tag}`)

And your code should be like this:

client.on('messageCreate', message => {
    if(message.author.bot || message.channel.type === `DM`) return;

    if(message.mentions.members.get(`332599069027598336`)) {
        client.channels.cache.get('YOUR_CHANNEL_ID').send(`The user ${message.author} has mentioned ${message.mentions.members.get(`332599069027598336`).user.tag}`)
    }
});```
Latepate
  • 117
  • 1
  • 7