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

247
Vistas
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 Respuestas
Responde la pregunta

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