Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

129
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda