Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

123
Vistas
How do I check if the selected user in a slash command is a bot or not

So I'm making a discord bot which has a function to dm someone via slash command. Now how do i check if the user selected in the slash command is a bot or an actual user?

The slash command registerer

{
  '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
    }
  ]
}

The logic

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 }))
      }
     }
   }
 }

})

But the if (interaction.options.getUser('user') === interaction.user.bot) does not work

almost 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

There is a .bot property which you may use to check if the user is a bot or not.

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda