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

334
Vistas
Discord.js Adding Emojis to a send message and grab the message id

Hey Stack Overflow Community, I have another question in regard to discord.js.I want to send a message and add an emoji to it, from which I later want to get the list of users who have reacted. In order to do so I have 2 questions:

-How can I add an emoji? Do I need a separate event listener for a message or can I do it within my interactionCreate event? I have tried pannel.react("👍") which gives me the error: 'TypeError: pannel.react is not a function'. Does anyone know how to let this work?

-My other question is if there is a way to access the message id from the send message, in order to check who has participated later on in another command?

I have an index file with my command and event handlers. The script is from my "setup.js" command in the "commands" folder:

const { SlashCommandBuilder } = require("@discordjs/builders");
const Discord = require("discord.js");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("setup")
        .setDescription("Setup Tweet to be rewarded")
        .addChannelOption(option =>
            option
            .setName('destination')
            .setDescription('Select a channel for the reward pannel')
            .setRequired(true)
            )
        .addStringOption(option =>
            option
                .setName("twitterlink")
                .setDescription("Enter the Twitter Link")
                .setRequired(false)
                ),

    async execute(interaction) {

        interaction.reply({
            content: "Pannel send",
            ephemeral: true
        }).then( function () {

        const channel = interaction.options.getChannel("destination");
        const channelid = channel.id;
        const twitterlink = interaction.options.getString("twitterlink");

       const pannel = interaction.guild.channels.cache.get(channelid).send(twitterlink);
    });
    }
};

Thank you very much for your assistance in advance.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Okay with the help from @Gh0st I was able to find a solution:

The problem in order to send a message is that the .get() function need the channel id. I have accessd it to interaction.options.getChannel("destination").id);. I couldnt add a reaction because my .send command was not await: const pannel = await channel.send(twitterlink). The message id is easiy to find by using .id on the variable of the message: const pannelid = pannel.id.

The resulting code can be found below:

const { SlashCommandBuilder } = require("@discordjs/builders");
const Discord = require("discord.js");




module.exports = {
    data: new SlashCommandBuilder()
        .setName("setup")
        .setDescription("Setup Tweet to be rewarded")
        .addChannelOption(option =>
            option
            .setName('destination')
            .setDescription('Select a channel for the reward pannel')
            .setRequired(true)
            )
        .addStringOption(option =>
            option
                .setName("twitterlink")
                .setDescription("Enter the Twitter Link")
                .setRequired(false)
                ),

                async execute(interaction) { // Fixed below here and simplified it
                    const channel = interaction.guild.channels.cache.get(interaction.options.getChannel("destination").id);
                    const twitterlink = interaction.options.getString("twitterlink");
            
                    const pannel = await channel.send(twitterlink)
                    pannel.react('🍎');
                    const pannelid = pannel.id
            
                    return interaction.reply({
                        content: "Pannel send",
                        ephemeral: true,
                    });
                },
            };
about 4 years ago · Juan Pablo Isaza Denunciar

0

Cleaned it up a bit and this should work for you

const {
    SlashCommandBuilder,
} = require("@discordjs/builders");
const Discord = require("discord.js");

module.exports = {
    data: new SlashCommandBuilder()
        .setName("setup")
        .setDescription("Setup Tweet to be rewarded")
        .addChannelOption(option =>
            option
                .setName('destination')
                .setDescription('Select a channel for the reward pannel')
                .setRequired(true),
        )
        .addStringOption(option =>
            option
                .setName("twitterlink")
                .setDescription("Enter the Twitter Link")
                .setRequired(false),
        ),
    async execute(interaction) { // Fixed below here and simplified it
        const channel = interaction.guild.channels.cache.get(interaction.options.getChannel("destination").id);
        const twitterlink = interaction.options.getString("twitterlink");

        channel.send(twitterlink).then(msg => {
            msg.react('🍎'),
        });

        return interaction.reply({
            content: "Pannel send",
            ephemeral: 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