Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

179
Visualizações
DiscordJS filtering users from buttons and limiting buttons to user who used command

I'm trying to make a bot that lets users create embeds using a series of commands and its going well. But I encountered a problem, the bot uses buttons but to confirm something like "Are you sure this is your title?" any user can click the button; which is a problem. I only want the user who used the command to be able to use the buttons.

Here is what I tried at the start:

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;

I tried to use interaction.user.id != or === interaction.message.author.id but that doesn't work

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The best way to make a button only for a single user is to put the user ID in the custom ID

For example, set the ID to 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 Relatório

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

idk if you still need it but

hope it works, it works for me

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda