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

155
Views
¿Cómo puedo usar el USER ID en lugar de usar las menciones?

Recientemente hice un comando de discordia llamado -dm que básicamente envía mensajes directos al usuario mencionado en el mensaje. Algo como: -dm @Omega Hello! y enviaría "¡Hola!" al usuario mencionado.

Pero a algunas personas les resulta molesto cuando se les hace ping varias veces, por lo que quiero saber si hay alguna forma en que pueda usar la ID DE USUARIO en lugar de mencionar al usuario. Eso haría la vida mucho más fácil. Para quien pueda interesar, mi código se proporciona a continuación.

 const Discord = require('discord.js') module.exports = { name: 'dm', description: 'DMs the person with the User ID mentioned', execute(client, msg, args) { if(!msg.member.permissions.has("ADMINISTRATOR")) return msg.channel.send("You cannot do that!") //if(msg.author.id !== 'CENSORED') return msg.channel.send("You cannot do that!") const user = msg.mentions.users.first() if(!user) return msg.channel.send("That user ID doesn't exist OR that person isn't in the same server as me!") const str = args.slice(1).join(" ") user.send(str) msg.channel.send("Message sent to the user!") var dmLogger = new Discord.MessageEmbed() .setTitle("DM Sent") .setColor("RANDOM") .addField("MESSAGE SENT BY", msg.author.tag) .addField("MESSAGE SENT TO", user) .addField("MESSAGE CONTENT", str) .setTimestamp() client.channels.cache.get('CENSORED_2.0').send(dmLogger) } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede agregar await message.guild.members.fetch(args[0]) pero si aún desea mantener las menciones, puede agregarlo a su variable de usuario.

 const user = msg.mentions.users.first() || await msg.guild.members.fetch(args[0])

Si desea solo con ID de usuario, elimine la parte de menciones.

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!