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

125
Views
¿Cómo verifico si el usuario seleccionado en un comando de barra diagonal es un bot o no?

Así que estoy creando un bot de discordia que tiene una función para enviar mensajes directos a alguien a través del comando de barra oblicua. Ahora, ¿cómo verifico si el usuario seleccionado en el comando de barra oblicua es un bot o un usuario real?

El registrador de comandos de barra

 {
 'name': 'dm',
 'description': 'Dm someone if you are an admin',
 'type':1,
 "default_member_permissions": 'ADMINISTRATOR',
 'options': [
 {
 'name': 'user',
 'description': 'which user do you wanna dm?',
 'type': 6,
 'required': true
 },{
 'name': 'message',
 'description': 'The message you wanna send',
 'type':3,
 'required': true
 }
 ]
}

La lógica

 client.on('interactionCreate', (interaction) =>{
 if (!interaction.isChatInputCommand) return;
 if (interaction.commandName === 'apanker'){
 if (interaction.options.getSubcommand() === 'dm'){
 const message = interaction.options.getString('message')
 if (interaction.options.getUser('user') === interaction.user.bot) {
 interaction.reply(({ content: `Bots can't be`, ephemeral: true }))
 
 }
 else{
 const rec = interaction.options.getUser('user')
 const user = interaction.user.id
 try {
 rec.send({ embeds:[ new EmbedBuilder().setDescription(`<@${user}> says to you: ${message} `).setColor("#f05c51")
 .then(interaction.reply(({ content: 'Successfully sent', ephemeral: true })))

 ] })
 } catch (error) {
 interaction.reply(({ content: `Could not send message, maybe dm's off? -> ${error}`, ephemeral: true }))
 }
 }
 }
 }

})

Pero el if (interaction.options.getUser('user') === interaction.user.bot) no funciona

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hay una propiedad .bot que puede usar para verificar si el usuario es un bot o no.

 const user = interaction.options.getUser("user");
if (user.bot) {
 console.log("User is bot");
} else {
 console.log("User isn't bot")
};
almost 4 years ago · Santiago Trujillo 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!