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

274
Views
How to make a discord bot do something after I react to an emoji in an image sent by itself

I'm making my first discord bot and I'm trying to make it send a message after I react to one of its emojis, problem is, when I click the thumbs up emoji, the bot simply does not send the message, it's been a few hours now and I can't find the problem, I'm sorry if this has been solved somewhere else, I couldn't find anything that works.

if (command === "ping") {

    const attachment = new MessageAttachment('https://cdn.mcr.ea.com/3/images/ac394369-2801-4e09-87eb-82ca54e26254/1588018258-0x0-0-0.jpg'); 
    const sentMessage = await message.channel.send({files: [attachment] })
    sentMessage.react('๐Ÿ‘');
    //sentMessage.react('๐Ÿ‘Ž');
    const filter = (reaction, user) => {
        return reaction.emoji.name === '๐Ÿ‘' && user.id === message.author.id;
    };
    const collector = sentMessage.createReactionCollector(filter, { time: 15000 });
    collector.on('collect', (reaction, user) => {
        message.channel.send(`Collected ${reaction.emoji.name} from ${user.tag}`);
    });

    collector.on('end', collected => {
        message.channel.send(`Collected ${collected.size} items`);
        console.log(`Collected ${collected.size} items`);
    });

EDIT

I found that I was missing the "GUILD_MESSAGE_REACTIONS" intent, now i have these 3 "GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS", still not working sadly!

Here's the full code: https://pastebin.com/Q0eZ6VSz

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

enter image description here

Hi, this code is working except a small thing...

sentMessage.createReactionCollector(filter, { time: 15000 });

change this to:

sentMessage.createReactionCollector({filter, time: 15000 });

also I suggest you to add max: 1 option too.

so final code:

...
sentMessage.createReactionCollector({filter, max: 1,  time: 15000 });

in this situation only gets first react by you.

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!