Sorteo.js
Recibo este error y no sé cómo solucionarlo, pero los tutoriales usan lo mismo y no obtienen este error.
Cannot read properties of undefined (reading 'start')
Mi código:
case 'start': { const gchannel = options.getChannel('channel') || interaction.channel; const duration = options.getString('duration'); const winnerCount = options.getInteger('winners'); const prize = options.getString('prize'); client.giveawaysManager .start(gchannel, { duration: ms(duration), winnerCount, prize, messages: { giveaway: '🎉 **GIVEAWAY STARTED**🎉', giveawayEnded: '🎊 **GIVEAWAY ENDED** 🎊', winMessage: 'Congratulations, {winners}! You won **{this.prize}**!', }, }) .then(async () => { successembed.setDescription('giveaway successfully started.'); wait(4000); interaction.reply({ embeds: [successembed], ephemeral: true }); }) .catch((err) => { errorembed.setDescription(`An error has occured \n\`${err}\``); wait(4000); interaction.reply({ embeds: [errorembed], ephemeral: true }); }); }El error está en:
client.giveawaysManager.start(gchannel, { duration: ms(duration), winnerCount, prize, messages: { giveaway: '🎉 **GIVEAWAY STARTED**🎉', giveawayEnded: '🎊 **GIVEAWAY ENDED** 🎊', winMessage: 'Congratulations, {winners}! You won **{this.prize}**!', }, })No es client.giveawaysManager, debe construirse por sí mismo:
manager= new GiveawaysManager(client, options(opt), init(opt));Y luego se llama así:
manager.start(gchannel, { duration: ms(duration), winnerCount, prize, messages: { giveaway: '🎉 **GIVEAWAY STARTED**🎉', giveawayEnded: '🎊 **GIVEAWAY ENDED** 🎊', winMessage: 'Congratulations, {winners}! You won **{this.prize}**!', }, })