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

168
Views
DiscordJS filtra a los usuarios de los botones y limita los botones al usuario que usó el comando

Estoy tratando de hacer un bot que permita a los usuarios crear incrustaciones usando una serie de comandos y va bien. Pero encontré un problema, el bot usa botones pero para confirmar algo como "¿Estás seguro de que este es tu título?" cualquier usuario puede hacer clic en el botón; lo cual es un problema Solo quiero que el usuario que usó el comando pueda usar los botones.

Esto es lo que probé al principio:

 client.on('interactionCreate', async interaction => { const filter = m => !m.author.bot && m.author.id === interaction.user.id; const collector = interaction.channel.createMessageCollector({filter, max:1, time:10000}); if (!interaction.isButton() && interaction.user.id != interaction.message.author.id) return;

Traté de usar interaction.user.id != o === interaction.message.author.id pero eso no funciona

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

La mejor manera de hacer un botón solo para un solo usuario es poner la identificación del usuario en la identificación personalizada

Por ejemplo, establezca el ID en title-${interaction.user.id}

 if(!interaction.isButton()) return; if (!interaction.customId.endsWith(interaction.user.id)) { return interaction.reply({ content: "This button is not for you", ephemeral: true }) }
about 4 years ago · Juan Pablo Isaza Report

0

client.on("interactionCreate", async (interaction) => { //filter the user so it only works for the user who sent the command if (interaction.user.id !== message.author.id) { const embed = new MessageEmbed() .setDescription("You Cannot Interact With This Message!") .setColor("RED"); return interaction.reply({ embeds: [embed], ephemeral: true }); } else { //Code Here } });

nose si todavia lo necesitas pero

espero que funcione, a mi me funciona

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!