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

127
Views
Discord.js: MessageCollector, messages doesn't trigger collect event

I'm trying to code a giveaway bot in discord.js, it is the first time that I code in Javascript so if you have any recommendations I would be happy to hear them !

I am trying to launch a giveaway on a specific channel, the channel is usually locked for @everyone, when the giveaway starts, I open the channel and start listening for inputs.

I would like to listen for every messages, check if it is a correct ethereum wallet, if it is, gather it, if it is not, delete the message from the channel.

I wanted to use a createMessageCollector without any filter, and manually check everything. However, messages doesn't trigger the collect event..

Here is the code:

async function launch_giveaway(interaction) {
    const giveawayChannel = interaction.options.getChannel("in");
    const giveawayName = interaction.options.getString("name");
    const numWinner = interaction.options.getInteger("num_winners");
    const hours = interaction.options.getInteger("hours");
    const minutes = interaction.options.getInteger("minutes");
    const channelWinner = interaction.options.getChannel("winner_channel")

    let endTime = Math.round(Date.now()/1000) + hours*3600 + minutes*60;
    await interaction.reply(`Starting the giveaway of **${giveawayName}** in ${giveawayChannel} for ${hours}:${minutes}, I will put the ${numWinner} winners in ${channelWinner} !`);
    await open_giveaway(interaction, giveawayChannel, giveawayName, numWinner, endTime, channelWinner)
    await interaction.followUp(`Done ! ${giveawayChannel} is now open and members can send there wallets !`);

    setTimeout(close_channel, hours*3600000 + minutes*60000, interaction, giveawayChannel, channelWinner, giveawayName);
    let wallets = [];

    const filter = m => {return true;};
    const collector = giveawayChannel.createMessageCollector({ filter, time: 15000 });

    collector.on('collect', m => {
        console.log("someone typed in #giveaway");
        // check ethereum wallet regex etc
        // add to wallets list
    });

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

I even tested with the default code from this tutorial, but it doesn't log anything on my console.

Thank you very much for your help,

Chronoxx

about 4 years ago · Juan Pablo Isaza
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!