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

196
Views
Discord Js - Bot can't react to message

I want to make a poll command, where the bot send an embed with the poll and afterwards reacts to it with some emojis. I added the reaction Intent to my index.js but still get an error everytime I call the command. This is my code:

const { SlashCommandBuilder } = require('@discordjs/builders')
const { MessageEmbed } = require('discord.js')

module.exports = {
    data: new SlashCommandBuilder()
        .setName("poll")
        .setDescription("Create a quick poll.")
        .addStringOption(option => option.setName("question").setDescription("The question").setRequired(true)),
    async execute(interaction) {
        const question = interaction.options.getString("question")
        const message = await interaction.reply({embeds: [
            new MessageEmbed()
                .setColor('GREEN')
                .setTitle(`Discord Poll`)
                .setAuthor(`Requested by ${interaction.member.user.tag}`, interaction.member.user.avatarURL())
                .setDescription(question)
                .setThumbnail('https://pngimg.com/uploads/question_mark/question_mark_PNG126.png')
                .setTimestamp()
                .setFooter('Bot by Iuke#4681', 'https://cdn.discordapp.com/emojis/912052946592739408.png?size=96')
        ]})
        message.react(':check:')
        .then(() => message.react(':neutral:')
        .then(() => message.react(':xmark:')))
    }
}

And get this error:

TypeError: Cannot read properties of undefined (reading 'react')

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

0

You will need to fetch the reply. You can use the fetchReply option and set it to true.

module.exports = {
  data: new SlashCommandBuilder()
    .setName('poll')
    .setDescription('Create a quick poll.')
    .addStringOption((option) =>
      option
        .setName('question')
        .setDescription('The question')
        .setRequired(true),
    ),
  async execute(interaction) {
    const question = interaction.options.getString('question');
    const message = await interaction.reply({
      embeds: [
        new MessageEmbed()
          .setColor('GREEN')
          .setTitle(`Discord Poll`)
          .setAuthor(
            `Requested by ${interaction.member.user.tag}`,
            interaction.member.user.avatarURL(),
          )
          .setDescription(question)
          .setThumbnail(
            'https://pngimg.com/uploads/question_mark/question_mark_PNG126.png',
          )
          .setTimestamp()
          .setFooter(
            'Bot by Iuke#4681',
            'https://cdn.discordapp.com/emojis/912052946592739408.png?size=96',
          ),
      ],
      fetchReply: true,
    });

    // you could use await to react in sequence instead of then()s
    await message.react(':check:');
    await message.react(':neutral:');
    await message.react(':xmark:');
  },
};
about 4 years ago · Juan Pablo Isaza Report

0

According to the docs you need to add the fetchReply option on interaction.reply like this:

const message = await interaction.reply({ content: 'Pong!', fetchReply: true });
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!