Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const ms = require('ms')
- if (message.content.startsWith(prefix + "giveaway")) {
- if (!message.guild) return;
- if (!message.member.hasPermission("ADMINISTRATOR")) {
- return message.channel.send(":x: | You must be an administrator of this server");
- }
- let time = args[1]
- if (!time) return message.channel.send('You did not specify a time!');
- if (
- !args[1].endsWith("d") &&
- !args[1].endsWith("h") &&
- !args[1].endsWith("m") &&
- !args[1].endsWith("s")
- )
- return message.channel.send('You need to use d (days), h (hours), m (minutes), or s (seconds)')
- let channel = message.mentions.channels.first();
- if (!channel) return message.channel.send("I can't find that channel in the server!")
- let prize = args.slice(3).join(" ")
- if (!prize) return message.channel.send('Arguement missing. What is the prize?')
- let item = args.slice(3).join(" ")
- channel.send(":tada: **NEW GIVEAWAY** :tada:")
- var embed = new Discord.MessageEmbed()
- .setTitle("New Giveaway!")
- .setDescription(`React with :tada: to enter the giveaway!\nHosted By: **${message.author}**\nTime: **${time}**\nPrize: **${prize}**`)
- .setTimestamp(Date.now + ms(args[1]))
- .setColor(3447003)
- .addField(`Duration : `, ms(ms(time), {
- long: true
- }), true);
- try {
- const sent = message.channel.send(embed);
- message.react('🎉');
- setTimeout(async () => {
- try {
- const peopleReactedBot = sent.reactions.cache
- .get('🎉')
- .users.fetch();
- const peopleReacted = peopleReactedBot
- .array()
- .filter((u) => u.id !== client.user.id);
- console.log({ peopleReacted });
- } catch (e) {
- message.channel.send(
- `An unknown error happened during the draw of the giveaway **${item}**: \`${e}\``
- );
- }
- }, timeout);
- } catch (e) {
- message.channel.send(
- `An error occurred while running the command You shouldn't ever receive an error like this Please contact <@390690088348024843> in this server **${item}**: \`${e}\``
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment