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

246
Visualizações
Message collector responds to other people's messages

I'm trying to make a collector which will collect the mentioned user's message. But even with filter my bot respond to it's own message and other peoples messages! Here is my test.js file code:

const mentioned = message.mentions.users.first();

const filter1 = (msg) => {
  return msg.author.id === mentioned.id
}

const collector1 = await message.channel.createMessageCollector({ filter1, max: 1, time: 120000 })

collector1.on('collect', message => {
  console.log(message.content)
})

collector1.on('end', (collected) => {
  if (collected.size === 0) return message.channel.send("Mentioned user did not respond in time!")

  collected.forEach((message) => {
    if (message.content.toLowerCase() == 'accept') {
      message.channel.send(`${mentioned} accepted!`)
    }
    if (message.content.toLowerCase() == 'cancel') return message.channel.send(`${mentioned} declined!`)
  })
})

I was changing my filter many times, but I still can't fix this problem, so what am I doing wrong? Also I use djs v13

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

0

The problem is you're trying to use Short-Hand Property Assignment to assign the filter option. However, you pass in "filter1" which results in {filter1: filter1}. Since this does not resolve to a filter option for TextChannel#createMessageCollector() the method disregards the unknown option and therefor your collector has no filter.

Change your filter1 variable to filter

const filter = (msg) => {
  return msg.author.id === mentioned.id
}

const collector1 = await message.channel.createMessageCollector({ filter, max: 1, time: 120000 })
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