Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

103
Views
¿Cómo puedo crear un código que se active cuando alguien mencione a cierto usuario y advierta al usuario que lo activa?

Esta es una idea de código que tenía para crear un código que se active al mencionar a un determinado usuario y advertir al usuario activado, pero simplemente no funciona.

 const Client = require("./Structures/Client.js"); const config = require("./Data/config.json"); const client = new Client(); client.on("messageCreate", message => { if(message.content == "<@USER2ID>") message.reply("User1#1234 has mentioned User2#1234"); }); client.start(config.token);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debería usar el objeto message.mentions en lugar de obtener el contenido del mensaje. También es client.start no es una función. Debería usar la función client.login en su lugar. También se olvidó de mencionar las intenciones que desea utilizar. Por favor, eche un vistazo al siguiente ejemplo:

 const {Client, Intents} = require('discord.js'); // Import the client and intents const config = require('./Data/config.json'); // Import the config const client = new Client({ intents: [Intents.FLAGS.GUILD_MESSAGES] // Uses the intent 'GUILD_MESSAGES' to be able to get the messages }); // Creates the client client.on('messageCreate', message => { // Creates an event listener if(message.author.bot || message.channel.type === `DM`) return; // Returns when the author is a bot or if the message is being send in a DM if(message.mentions.members.get(`0123456789`)){ // If the user with the user id '0123456789' has been mentioned in the message message.reply(`The user ${message.mentions.members.get(`0123456789`).user.tag} has been mentioned`); // Sends the reply } }); client.login(config.token); // Login to the bot
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!