Estoy tratando de codificar un bot de obsequio en discord.js, es la primera vez que codifico en Javascript, por lo que si tiene alguna recomendación, ¡me encantaría escucharla!
Estoy tratando de lanzar un sorteo en un canal específico, el canal generalmente está bloqueado para @todos, cuando comienza el sorteo, abro el canal y empiezo a escuchar las entradas.
Me gustaría escuchar todos los mensajes, verificar si es una billetera ethereum correcta, si lo es, recopilarla, si no lo es, eliminar el mensaje del canal.
Quería usar un createMessageCollector sin ningún filtro y verificar todo manualmente. Sin embargo, los mensajes no activan el evento de collect .
Aquí está el código:
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`); }); }Incluso probé con el código predeterminado de este tutorial , pero no registra nada en mi consola.
Muchas gracias por su ayuda,
Chronoxx