discord-giveaways icon indicating copy to clipboard operation
discord-giveaways copied to clipboard

Giveaway not ending again

Open Tomato6966 opened this issue 3 years ago • 13 comments

So i did that for bonusEntries and exemptMembers with the new Function syntax

new Function('member', `return member.roles.cache.some((r) => r.id === \'${bonusentriesdata.mentions.roles.first().id}\') ? Math.floor(Number(\'${bonusentriesdata.content.split(" ")[1]}\')) ? Math.floor(Number(\'${bonusentriesdata.content.split(" ")[1]}\')) : 1 : null`),

But the giveaway is still sometimes not ending, especially after the bot restarts, or after a few days of giveaway hosting duration..

I dont know anything more what to do or how i could find the problem because i cant find the logs.. and there are no discord-giveaway syntax error styles

this is my whole code for the giveaway command:
const Discord = require("discord.js");
const {MessageEmbed, Permissions} = require("discord.js");
const config = require(`${process.cwd()}/botconfig/config.json`)
const ms = require("ms");
const {
  databasing, swap_pages
} = require(`${process.cwd()}/handlers/functions`);
module.exports = {
  name: "giveaway",
  aliases: ["g"],
  category: "🚫 Administration",
  description: "Giveaway manager",
  usage: "giveaway <start/end/reroll/edit/delete/list>",
  type: "server",
  run: async (client, message, args, cmduser, text, prefix) => {
  
      let es = client.settings.get(message.guild.id, "embed");let ls = client.settings.get(message.guild.id, "language")
      let adminroles = client.settings.get(message.guild.id, "adminroles")
      let cmdroles = client.settings.get(message.guild.id, "cmdadminroles.giveaway")
      var cmdrole = []
      if (cmdroles.length > 0) {
          for (const r of cmdroles) {
              if (message.guild.roles.cache.get(r)) {
                  cmdrole.push(` | <@&${r}>`)
              } else if (message.guild.members.cache.get(r)) {
                  cmdrole.push(` | <@${r}>`)
              } else {
                  
                  //console.log(r)
                  client.settings.remove(message.guild.id, r, `cmdadminroles.giveaway`)
              }
          }
      }
      if (([...message.member.roles.cache.values()] && !message.member.roles.cache.some(r => cmdroles.includes(r.id))) && !cmdroles.includes(message.author.id) && ([...message.member.roles.cache.values()] && !message.member.roles.cache.some(r => adminroles.includes(r ? r.id : r))) && !Array(message.guild.ownerId, config.ownerid).includes(message.author.id) && !message.member.permissions.has([Permissions.FLAGS.ADMINISTRATOR]))
          return message.reply({embeds : [new MessageEmbed()
              .setColor(es.wrongcolor)
              .setFooter(es.footertext, es.footericon)
              .setTitle(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable1"]))
              .setDescription(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable2"]))
          ]});
      if (!args[0]) return message.reply({embeds: [new MessageEmbed()
          .setColor(es.wrongcolor)
          .setFooter(es.footertext, es.footericon)
          .setTitle(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable3"]))
          .setDescription(`> \`${prefix}giveaway start\` ... to start a new giveaway

> \`${prefix}giveaway end <G-Id>\` ... to end a specific giveaway

> \`${prefix}giveaway reroll <G-Id> [winneramount]\` ... to reroll a specific giveaway

> \`${prefix}giveaway pause <G-Id>\` ... to pause a specific giveaway

> \`${prefix}giveaway resume <G-Id>\` ... to resume a specific giveaway

> \`${prefix}giveaway edit <G-Id>\` ... to edit a specific giveaway

> \`${prefix}giveaway delete <G-Id>\` ... to delete a specific giveaway

> \`${prefix}giveaway list [server/all]\` ... to list giveaways in here / globally
`)
      ]})
      var originalowner = message.author.id
      if (args[0].toLowerCase() === "start") {
          try{
              let giveawayChannel;
              await message.reply({
                  embeds: [new MessageEmbed()
                  .setColor(es.color).setThumbnail(es.thumb ? es.footericon : null)
                  .setFooter(es.footertext, es.footericon)
                  .setTitle(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable5"]))
                  .setDescription(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable6"]))
              ]})
              var collected = await message.channel.awaitMessages({filter: m=>m.author.id == originalowner,  max: 1, time: 60e3, errors: ['time'] })
              var channel = collected.first().mentions.channels.filter(ch=>ch.guild.id==message.guild.id).first() || message.guild.channels.cache.get(collected.first().content);
              if(!channel) throw { message: "You did not mentioned a valid Channel, where the Giveaway should start!" }
              giveawayChannel = channel;


              let giveawayDuration;
              await message.reply({
                  embeds: [new MessageEmbed()
                  .setColor(es.color).setThumbnail(es.thumb ? es.footericon : null)
                  .setFooter(es.footertext, es.footericon)
                  .setTitle(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable11"]))
                  .setDescription(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable12"]))
              ]})
              var collected = await message.channel.awaitMessages({filter: m=>m.author.id == originalowner,  max: 1, time: 60e3, errors: ['time'] })
              gargs = collected.first().content.split("+");
              giveawayDuration = 0;
              for(const a of gargs){
                  giveawayDuration += ms(a.split(" ").join(""))
              }
              if(!giveawayDuration || isNaN(giveawayDuration)) throw { message: "You added a not valid Time!" };


              let giveawayNumberWinners;
              await message.reply({
                  embeds: [new MessageEmbed()
                  .setColor(es.color).setThumbnail(es.thumb ? es.footericon : null)
                  .setFooter(es.footertext, es.footericon)
                  .setTitle(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable17"]))
                  .setDescription(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable18"]))
              ]})
              var collected = await message.channel.awaitMessages({filter: m=>m.author.id == originalowner,  max: 1, time: 60e3, errors: ['time'] })
              giveawayNumberWinners = collected.first().content;
              if(!giveawayNumberWinners || isNaN(giveawayNumberWinners) || (parseInt(giveawayNumberWinners) <= 0)) throw { message: "You added an invalid amount of Winners" };

          
              let giveawayPrize;
              await message.reply({
                  embeds: [new MessageEmbed()
                  .setColor(es.color).setThumbnail(es.thumb ? es.footericon : null)
                  .setFooter(es.footertext, es.footericon)
                  .setTitle(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable23"]))
                  .setDescription(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable24"]))
              ]})
              var collected = await message.channel.awaitMessages({filter: m=>m.author.id == originalowner,  max: 1, time: 60e3, errors: ['time'] })
              giveawayPrize = collected.first().content;
              
              giveawayNumberWinners = parseInt(giveawayNumberWinners);
              if(giveawayNumberWinners <= 0) giveawayNumberWinners = 1;
              let options = {
                  time: giveawayDuration,
                  duration: giveawayDuration,
                  prize: `<a:Gift:853993605868683285> ${giveawayPrize} <a:Gift:853993605868683285>`,
                  winnerCount: giveawayNumberWinners,
                  hostedBy: message.author,
                  thumbnail: es.thumb ? es.footericon : null,
                  botsCanWin: false,
                  embedColor: es.color,
                  embedColorEnd: es.wrongcolor,
                  reaction: '867721863151747092',
                  lastChance: {
                      enabled: true,
                      content: '⚠️ **LAST CHANCE TO ENTER!** ⚠️',
                      threshold: 60000,
                      embedColor: '#FEE75C'
                  },
                  pauseOptions: {
                      isPaused: false,
                      content: '⏸️ **THIS GIVEAWAY IS PAUSED!** ⏸️',
                      unPauseAfter: null,
                      embedColor: '#582812'
                  },
                  bonusEntries: [],
                  messages: {
                      inviteToParticipate: "***React with <a:Tada_Yellow:867721863151747092> to participate!***\n",
                      drawing: "> Ends: {timestamp}\n",
                      hostedBy: "**Hosted by:** {this.hostedBy}",
                      dropMessage: "Be the first to react with <a:Tada_Yellow:867721863151747092>",
                      noWinner: "\n**Giveaway cancelled!**\n> No valid participations. :cry:",
                      endedAt: "Ends at", 
                      giveaway: '<a:Tada_Yellow:867721863151747092> **GIVEAWAY STARTED** <a:Tada_Yellow:867721863151747092>',
                      giveawayEnded: '<a:Tada_Green:867721862858539048> **GIVEAWAY ENDED** <a:Tada_Green:867721862858539048>',
                      winMessage: '**Congrats** {winners}!\n> You won **{this.prize}**!\n> **Jump:** {this.messageURL}\nHosted by: {this.hostedBy}',
                      embedFooter: '{this.winnerCount} Winner{this.winnerCount > 1 ? "s" : ""}'
                  },
              }





              let bonusentriesdata;
              await message.reply({
                  embeds: [new MessageEmbed()
                  .setColor(es.color).setThumbnail(es.thumb ? es.footericon : null)
                  .setFooter(es.footertext, es.footericon)
                  .setTitle(`Do you want to add Bonus Entrie Roles?`)
                  .setDescription(`Type: \`no\` or \`0\` Bonus Entries, if you don't want to have any!\n\nTo add Bonus Entries, **Ping a Role and afterwards type the amount of Entries!**\n\n**Example:**\n> \`@ROLE 3\`\n\n> *If you want to add Multiple Bonus Entries do something like this:*\nExample:\n> \`@Role 2, @Role 2, @Role5\``)
              ]})
              var collected = await message.channel.awaitMessages({filter: m=>m.author.id == originalowner,  max: 1, time: 60e3, errors: ['time'] })
              bonusentriesdata = collected.first();
              if(bonusentriesdata.mentions.roles.size > 0){
                  let args = bonusentriesdata.content.split(",").map(i => i.trim());
                  if(bonusentriesdata.mentions.roles.size > 1){
                      if(!args[0]) return message.reply(":x: Invalid Input of Multiple Bonus Roles, check the EXAMPLE!")
                      options.messages.giveaway += "\n\n**BONUS ENTRIE ROLES:**\n";
                      options.messages.giveawayEnded += "\n\n**BONUS ENTRIE ROLES:**\n";
                      [ ...bonusentriesdata.mentions.roles.values() ].forEach((role, index) => {
                          let curData = args[index].split(" ");
                          let Amount = Math.floor(Number(curData[1]) || null) || null
                          options.bonusEntries.push({
                              // Members who have the "Nitro Boost" role get 2 bonus entries
                              bonus: new Function('member', `return member.roles.cache.some((r) => r.id === \'${role.id}\') ? \'${Amount}\' ? \'${Amount}\' : 1 : null`),
                              cumulative: true
                          })
                          options.messages.giveaway += `> <@&${role.id}> | \`${Amount ? Amount : 1} Points\`\n`
                          options.messages.giveawayEnded += `> <@&${role.id}> | \`${Amount ? Amount : 1} Points\`\n`
                      })
                  }
                  //One Bonus entrie
                  else {
                      options.bonusEntries.push({
                          // Members who have the "Nitro Boost" role get 2 bonus entries
                          bonus: new Function('member', `return member.roles.cache.some((r) => r.id === \'${bonusentriesdata.mentions.roles.first().id}\') ? Math.floor(Number(\'${bonusentriesdata.content.split(" ")[1]}\')) ? Math.floor(Number(\'${bonusentriesdata.content.split(" ")[1]}\')) : 1 : null`),
                          cumulative: true
                      })
                      options.messages.giveaway += `\n\n**BONUS ENTRIE ROLE:**\n> <@&${bonusentriesdata.mentions.roles.first().id}> | \`${Math.floor(Number(bonusentriesdata.content.split(" ")[1])) ? Math.floor(Number(bonusentriesdata.content.split(" ")[1])) : 1} Points\`\n`
                      options.messages.giveawayEnded += `\n\n**BONUS ENTRIE ROLE:**\n> <@&${bonusentriesdata.mentions.roles.first().id}> | \`${Math.floor(Number(bonusentriesdata.content.split(" ")[1])) ? Math.floor(Number(bonusentriesdata.content.split(" ")[1])) : 1} Points\`\n`
                  }
              }



              let requiredroles;
              await message.reply({
                  embeds: [new MessageEmbed()
                  .setColor(es.color).setThumbnail(es.thumb ? es.footericon : null)
                  .setFooter(es.footertext, es.footericon)
                  .setTitle(`Do you want a Required Role?`)
                  .setDescription(`Type: \`no\` or \`0\` Required Roles, if you don't want to have any!\n\nTo add Required Roles, **Ping all Roles** which should be **required (the Users just need at least one of them)**\n\n**Example:**\n> \`@ROLE1 @Role2\` (1 Role is also enough)\n\n**NOTE:**\n> *Users without the Role, can react, but __won't be drawn__!*`)
              ]})
              var collected = await message.channel.awaitMessages({filter: m=>m.author.id == originalowner,  max: 1, time: 60e3, errors: ['time'] })
              requiredroles = collected.first();
              if(requiredroles.mentions.roles.size >= 1){
                  let theRoles = [...requiredroles.mentions.roles.values()];
                  options.messages.giveaway += `\n\n**REQUIRED ROLES:**\n${[...theRoles].map(r=>`> <@&${r.id}>`).join("\n")}`;
                  options.messages.giveawayEnded += `\n\n**REQUIRED ROLES:**\n${[...theRoles].map(r=>`> <@&${r.id}>`).join("\n")}`;
                  theRoles = theRoles.map(r => r.id);
                  options.exemptMembers = new Function('member', `return !member.roles.cache.some((r) => \'${theRoles}\'.includes(r.id))`)
              }
              options.messages.giveaway = options.messages.giveaway.substr(0, 2000)
              options.messages.giveawayEnded = options.messages.giveawayEnded.substr(0, 2000)
              //role requirements
              client.giveawaysManager.start(giveawayChannel, options);

              message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable27"])});
          } catch (error){ 
              console.log(error)
              return message.reply({embeds: [new MessageEmbed()
                  .setColor(es.wrongcolor)
                  .setFooter(es.footertext, es.footericon)
                  .setTitle(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable25"]))
                  .setDescription(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable26"]))
              ]})
          }
          // And the giveaway has started!
      } else if (args[0].toLowerCase() === "end") {
          args.shift();
          if (!args[0]) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable28"])});
          }
          let giveaway = client.giveawaysManager.giveaways.find((g) => g.prize === args.join(' ')) ||
              client.giveawaysManager.giveaways.find((g) => g.messageId === args[0]);

          if (!giveaway) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable29"])});
          }

          client.giveawaysManager.edit(giveaway.messageId, {
                  setEndTimestamp: Date.now()
              })
              .then(() => {
                  message.reply({content : "Giveaway will end in less then 10 Seconds!"});
              })
              .catch((e) => {
                  if (e.startsWith(`Giveaway with message Id ${giveaway.messageId} is already ended.`)) {
                      message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable31"])});
                  } else {
                      console.error(e);
                      message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable32"])});
                  }
              });
      } else if (args[0].toLowerCase() === "reroll") {
          args.shift();
          if (!args[0]) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable33"])});
          }
          let rerollamount = parseInt(args[1]);
          let giveaway =
              client.giveawaysManager.giveaways.find((g) => g.prize === args.join(' ')) ||
              client.giveawaysManager.giveaways.find((g) => g.messageId === args[0]);
          if (!giveaway) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable34"])});
          }
          client.giveawaysManager.reroll(giveaway.messageId, { winnerCount: !isNaN(args[1]) ? Number(args[1]) : 1})
              .then(() => {
                  message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable35"]) + "Tipp!\nAdd the amount of reroll winners to the end!"});
              })
              .catch((e) => {
                  if (e.startsWith(`Giveaway with message Id ${giveaway.messageId} is not ended.`)) {
                      message.reply(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable36"]));
                  } else {
                      console.error(e);
                      message.reply({content : '<:no:833101993668771842> **An error occured...**```' + String(e.message).substr(0, 1900) + "```"});
                  }
              });


      } else if (args[0].toLowerCase() === "pause") {
          args.shift();
          if (!args[0]) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable33"])});
          }
          let giveaway = client.giveawaysManager.giveaways.find((g) => g.messageId === args[0]);
          if (!giveaway) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable34"])});
          }
          client.giveawaysManager.pause(giveaway.messageId)
              .then(() => {
                  message.reply( { content : "Successfully! Paused the Giveaway" } );
              })
              .catch((e) => {
                  if (e.startsWith(`Giveaway with message Id ${giveaway.messageId} is not ended.`)) {
                      message.reply(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable36"]));
                  } else {
                      console.error(e);
                      message.reply({content : '<:no:833101993668771842> **An error occured...**```' + String(e.message).substr(0, 1900) + "```"});
                  }
              });
      } else if (args[0].toLowerCase() === "unpause" || args[0].toLowerCase() === "resume") {
          args.shift();
          if (!args[0]) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable33"])});
          }
          let giveaway =
              client.giveawaysManager.giveaways.find((g) => g.prize === args.join(' ')) ||
              client.giveawaysManager.giveaways.find((g) => g.messageId === args[0]);
          if (!giveaway) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable34"])});
          }
          client.giveawaysManager.unpause(giveaway.messageId)
              .then(() => {
                  message.reply( { content : "Successfully! Unpaused the Giveaway!" } );
              })
              .catch((e) => {
                  if (e.startsWith(`Giveaway with message Id ${giveaway.messageId} is not ended.`)) {
                      message.reply(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable36"]));
                  } else {
                      console.error(e);
                      message.reply({content : '<:no:833101993668771842> **An error occured...**```' + String(e.message).substr(0, 1900) + "```"});
                  }
              });
      } else if (args[0].toLowerCase() === "edit") {
          args.shift();
          let messageId = args[0];
          if (!messageId) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable37"])});
          }
          let giveawayPrize = args.slice(1).join(' ');
          if (!giveawayPrize) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable38"])});
          }
          client.giveawaysManager.edit(messageId, {
              newWinnerCount: 3,
              newPrize: giveawayPrize,
              addTime: 5000
          }).then(() => {
              // here, we can calculate the time after which we are sure that the lib will update the giveaway
              const numberOfSecondsMax = client.giveawaysManager.options.updateCountdownEvery / 1000;
              message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable39"])});
          }).catch((err) => {
              message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable40"])});
          });
      } else if (args[0].toLowerCase() === "delete") {
          args.shift();
          let messageId = args[0];
          if (!messageId) {
              return message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable41"])});
          }
          client.giveawaysManager.delete(messageId).then(() => {
                  message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable42"])});
              })
              .catch((err) => {
                  message.reply({content : eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable43"])});
              });
      } else if (args[0].toLowerCase() === "list") {
          args.shift();
          if (args[0] && args[0].toLowerCase() === "server") {
              let allGiveaways = client.giveawaysManager.giveaways.filter((g) => g.guildId === message.guild.id && !g.ended); // [ {Giveaway}, {Giveaway} ]
              buffer = [];
              for (let i = 0; i < allGiveaways.length; i++) {
                  try{
                  buffer.push(`> Prize: ${allGiveaways[i].prize}\n> Duration: \`${ms(new Date() - allGiveaways[i].startAt)}\` | [\`JUMP TO IT\`](https://discord.com/channels/${allGiveaways[i].guildId}/${allGiveaways[i].channelId}/${allGiveaways[i].messageId})\n`)
              }catch{}
              }
              if(buffer.length < 1) return message.reply("No Giveaways available!")
              return swap_pages(client, message, buffer, eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable45"]));
          } else {
              let allGiveaways = client.giveawaysManager.giveaways.filter((g) => !g.ended); // [ {Giveaway}, {Giveaway} ]
              buffer = [];
              for (let i = 0; i < allGiveaways.length; i++) {
                  try{
                  let invite = client.guilds.cache.get(allGiveaways[i].guildId).invites.cache.size > 0 ? client.guilds.cache.get(allGiveaways[i].guildId).invites.cache.map(invite => invite.url)[0] : client.guilds.cache.get(allGiveaways[i].guildId).channels.cache.first().permissionsFor(message.guild.me).has(Permissions.FLAGS.CREATE_INSTANT_INVITE) ? await client.guilds.cache.get(allGiveaways[i].guildId).channels.cache.first().createInvite() : "";
                  buffer.push(`> Guild: [\`${client.guilds.cache.get(allGiveaways[i].guildId).name}\`](${invite})\n> Prize: ${allGiveaways[i].prize}\n> Duration: \`${ms(new Date() - allGiveaways[i].startAt)}\` | [\`JUMP TO IT\`](https://discord.com/channels/${allGiveaways[i].guildId}/${allGiveaways[i].channelId}/${allGiveaways[i].messageId})\n`)
              }catch{}
              }
              if(buffer.length < 1) return message.reply("No Giveaways available!")
              return swap_pages(client, message, buffer, eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable46"]));
          }

      } else {
          return message.reply({embeds: [new MessageEmbed()
              .setColor(es.wrongcolor)
              .setFooter(es.footertext, es.footericon)
              .setTitle(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable47"]))
              .setDescription(`> \`${prefix}giveaway start\` ... to start a new giveaway

> \`${prefix}giveaway end <G-Id>\` ... to end a specific giveaway

> \`${prefix}giveaway reroll <G-Id> [winneramount]\` ... to reroll a specific giveaway

> \`${prefix}giveaway pause <G-Id>\` ... to pause a specific giveaway

> \`${prefix}giveaway resume <G-Id>\` ... to resume a specific giveaway

> \`${prefix}giveaway edit <G-Id>\` ... to edit a specific giveaway

> \`${prefix}giveaway delete <G-Id>\` ... to delete a specific giveaway

> \`${prefix}giveaway list [server/all]\` ... to list giveaways in here / globally
`)
          ]})
      }

      if(client.settings.get(message.guild.id, `adminlog`) != "no"){
          try{
            var channel = message.guild.channels.cache.get(client.settings.get(message.guild.id, `adminlog`))
            if(!channel) return client.settings.set(message.guild.id, "no", `adminlog`);
            channel.send({embeds :[new MessageEmbed()
              .setColor(es.color).setThumbnail(es.thumb ? es.footericon : null).setFooter(es.footertext, es.footericon)
              .setAuthor(`${require("path").parse(__filename).name} | ${message.author.tag}`, message.author.displayAvatarURL({dynamic: true}))
              .setDescription(eval(client.la[ls]["cmds"]["administration"]["giveaway"]["variable49"]))
              .addField(eval(client.la[ls]["cmds"]["administration"]["ban"]["variablex_15"]), eval(client.la[ls]["cmds"]["administration"]["ban"]["variable15"]))
             .addField(eval(client.la[ls]["cmds"]["administration"]["ban"]["variablex_16"]), eval(client.la[ls]["cmds"]["administration"]["ban"]["variable16"]))
              .setTimestamp().setFooter("Id: " + message.author.id)
            ]})
          }catch (e){
            console.log(e.stack ? String(e.stack).grey : String(e).grey)
          }
        } 
  }
}

function delay(delayInms) {
  return new Promise(resolve => {
      setTimeout(() => {
          resolve(2);
      }, delayInms);
  });
}
And this is my creation of the giveaway manager:
const { GiveawaysManager } = require('discord-giveaways');
client.giveawayDB = new Enmap({ name: 'giveaways', dataDir: "./databases" });
const GiveawayManagerWithOwnDatabase = class extends GiveawaysManager {
  async getAllGiveaways() {
      return client.giveawayDB.fetchEverything().array();
  }
  async saveGiveaway(messageId, giveawayData) {
      client.giveawayDB.set(messageId, giveawayData);
      return true;
  }
  async editGiveaway(messageId, giveawayData) {
      client.giveawayDB.set(messageId, giveawayData);
      return true;
  }
  async deleteGiveaway(messageId) {
      client.giveawayDB.delete(messageId);
      return true;
  }
};

const manager = new GiveawayManagerWithOwnDatabase(client, {
    default: {
        botsCanWin: false,
        embedColor: require(`${process.cwd()}/botconfig/embed.json`).color,
        embedColorEnd: require(`${process.cwd()}/botconfig/embed.json`).wrongcolor,
        reaction: '🎉'
    }
});
// We now have a giveawaysManager property to access the manager everywhere!
client.giveawaysManager = manager;
client.giveawaysManager.on("giveawayReactionAdded", (giveaway, member, reaction) => {
    console.log(`${member.user.tag} entered giveaway #${giveaway.messageId} (${reaction.emoji.name})`);
});
client.giveawaysManager.on("giveawayReactionRemoved", (giveaway, member, reaction) => {
    console.log(`${member.user.tag} unreact to giveaway #${giveaway.messageId} (${reaction.emoji.name})`);
});
client.giveawaysManager.on("giveawayEnded", (giveaway, winners) => {
    console.log(`Giveaway #${giveaway.messageId} ended! Winners: ${winners.map((member) => member.user.username).join(', ')}`);
});

Tomato6966 avatar Nov 14 '21 19:11 Tomato6966

I would love to receive help

Tomato6966 avatar Nov 14 '21 19:11 Tomato6966

you're still using "auto" sharding I assume?

Nico105 avatar Nov 14 '21 20:11 Nico105

yes

Tomato6966 avatar Nov 14 '21 20:11 Tomato6966

im still using the internal sharding method provided by discord.js for the clientoption

Tomato6966 avatar Nov 14 '21 20:11 Tomato6966

anything?

Tomato6966 avatar Nov 15 '21 14:11 Tomato6966

Hi, is there any solution to this problem?

TomakataABC avatar Dec 05 '21 21:12 TomakataABC

idk

Tomato6966 avatar Dec 06 '21 10:12 Tomato6966

Same problem !

Mohamedamine2005 avatar May 04 '22 23:05 Mohamedamine2005

experiencing the same issue and wondering if anyone else has found a solution?

dylie-eth avatar May 06 '22 03:05 dylie-eth

Tried to fix, but made things worse it with #462 Its maybe fruitless to ask, but did anything change with discord.js v14 regarding this?

Nico105 avatar Aug 05 '22 12:08 Nico105

I dont know, i will soon test this package again tho, with psql this time tho

Tomato6966 avatar Aug 05 '22 15:08 Tomato6966

facing the same problem, can someone give us a solution for this?

coding-forest avatar Aug 14 '22 15:08 coding-forest

Still facing same issue..

ItsMorningstar avatar Oct 30 '22 14:10 ItsMorningstar