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

143
Views
Wait for user response Role
    message.channel.send(`\`DBump Reminders\` Have been enabled`)
    message.channel.send(`\`DBump Reminders\` What role would you like to ping? If None response with N`)

    const returnedMessageContent = await new Promise((resolve) => {
  const messageCollector = message.channel.createMessageCollector({ time: 60000 });




  messageCollector.on('collect', (msg) => {
    if (msg.author.id !== message.author.id) return;
    if(msg.content === 'N') return message.channel.send('Enabled without Ping')
    console.log(message.mentions.roles.first())
    const role = message.mentions.roles.first()
    if(msg.content.replace(/\D+/g, '') !== role.id){
   message.channel.send(`No Role was Found`)
  } else {
   message.channel.send(`${role} was set as the bump ping`)
  }


    messageCollector.stop();
    resolve(msg.content);
  });

  messageCollector.on('end', (collected, reason) => {
    if (reason === 'time') {
      message.channel.send('Time ran out, please call the command again');
      resolve(null);
    }
  });
 });

I'm trying to wait for user response however It can't read mentioned roles

[Mursy] Unhandled Rejection: TypeError: Cannot read properties of undefined (reading 'id') at MessageCollector. (C:\Users\aweso\Desktop\Mursy - Copy\Mursy\Files\Commands\Test\test.js:36:49) at MessageCollector.emit (node:events:390:28) at MessageCollector.handleCollect (C:\Users\aweso\Desktop\Mursy - Copy\Mursy\node_modules\discord.js\src\structures\interfaces\Collector.js:109:12) at processTicksAndRejections (node:internal/process/task_queues:96:5)

this is the error I keep getting

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

0

The mistake is clearly in your collector

It should be msg.mentions.roles.first()

    messageCollector.on('collect', (msg) => {
          if (msg.author.id !== message.author.id) return;
          if(msg.content === 'N') return message.channel.send('Enabled without Ping')
          console.log(msg.mentions.roles.first())

          const role = msg.mentions.roles.first()
          if(msg.content.replace(/\D+/g, '') !== role.id){
         message.channel.send(`No Role was Found`)
        } else {
         message.channel.send(`${role} was set as the bump ping`)
        }
    
    })
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!