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

145
Views
Discord.js Interaction await messages cannot get message objects

Once a user creates an interaction in a discord channel I want to listen for new incoming messages in that channel. Here is the code I got

if (interaction.customId.startsWith('TRIGGER')) {
  let filter = (m) => m.author.id === interaction.author.id;
  interaction.channel
    .send(`Are you sure to delete all data? \`YES\` / \`NO\``)
    .then(() => {
      interaction.channel
        .awaitMessages(filter, {
          max: 1,
          time: 30000,
          errors: ['time'],
        })
        .then((message) => {
          message = message.first();
          if (
            message.content.toUpperCase() == 'YES' ||
            message.content.toUpperCase() == 'Y'
          ) {
            message.channel.send(`Deleted`);
          } else if (
            message.content.toUpperCase() == 'NO' ||
            message.content.toUpperCase() == 'N'
          ) {
            message.channel.send(`Terminated`);
          } else {
            message.channel.send(`Terminated: Invalid Response`);
          }
        })
        .catch((collected) => {
          interaction.channel.send('Timeout');
        });
    });
}

However I don't get the message objects. Its like no messages are send

How can I solve this issue ?

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

0

Your issue most likely lies in your filter as no interaction has an author property. Consider changing your filter to the following:

let filter = m => m.author.id === interaction.user.id;
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!