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

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

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 Denunciar

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