const { MessageEmbed } = require('discord.js') const ms = require('ms'); module.exports = { name: "reroll", description: "Get list of all command and even get to know every command detials", usage: "help ", category:"giveaway", run: async (bot, message, args) => { if(!message.member.hasPermission('MANAGE_MESSAGES') && !message.member.roles.cache.some((r) => r.name === "Giveaways")){ return message.channel.send(':x: You need to have the manage messages permissions to reroll giveaways.'); } // If no message ID or giveaway name is specified if(!args[0]){ return message.channel.send(':x: You have to specify a valid message ID!'); } // try to found the giveaway with prize then with ID let giveaway = // Search with giveaway prize bot.giveawaysManager.giveaways.find((g) => g.prize === args.join(' ')) || // Search with giveaway ID bot.giveawaysManager.giveaways.find((g) => g.messageID === args[0]); // If no giveaway was found if(!giveaway){ return message.channel.send('Es kann kein giveaway für `'+ args.join(' ') +'` gefunden werden.'); } // Reroll the giveaway bot.giveawaysManager.reroll(giveaway.messageID) .then(() => { // Success message message.channel.send('Giveaway neu gerollt!'); }) .catch((e) => { if(e.startsWith(`Giveaway mit Nachrichten-ID ${giveaway.messageID} ist nicht beendet.`)){ message.channel.send('Dieses Gewinnspiel ist noch nicht beendet!'); } else { console.error(e); message.channel.send('Es ist ein Fehler aufgetreten...'); } }); } }