Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const moment = require('moment');
- client.on('message',async message => {
- var time = moment().format('Do MMMM YYYY , hh:mm');
- var room;
- var title;
- var duration;
- var gMembers;
- var currentTime = new Date(),
- hours = currentTime.getHours() + 3 ,
- minutes = currentTime.getMinutes(),
- done = currentTime.getMinutes() + duration / 60000 ,
- seconds = currentTime.getSeconds();
- if (minutes < 10) {
- minutes = "0" + minutes;
- }
- var suffix = "AM";
- if (hours >= 12) {
- suffix = "PM";
- hours = hours - 12;
- }
- if (hours == 0) {
- hours = 12;
- }
- var filter = m => m.author.id === message.author.id;
- if(message.content.startsWith(prefix + "gcreate")) {
- if(!message.guild.member(message.author).hasPermission('MANAGE_GUILD')) return message.channel.send(':heavy_multiplication_x:| **You dont have perms**');
- message.channel.send(`:one:| **Please type the name of a channel in this server**`).then(msg => {
- message.channel.awaitMessages(filter, {
- max: 1,
- time: 20000,
- errors: ['time']
- }).then(collected => {
- let room = message.guild.channels.find('name' , collected.first().content);
- if(!room) return message.channel.send(":heavy_multiplication_x:| **I couldn`f find the channel `You must rewrite the command` :( __(Don't tag the channel just write the channel name without `#`)__**");
- room = collected.first().content;
- collected.first().delete();
- msg.edit(':two:| **Time For The Giveaway (Please enter the duration of the giveaway in seconds. `(Example: 1 means 1 minute)`**').then(msg => {
- message.channel.awaitMessages(filter, {
- max: 1,
- time: 20000,
- errors: ['time']
- }).then(collected => {
- if(isNaN(collected.first().content)) return message.channel.send(':heavy_multiplication_x:| **You must set a correct time period.. `You must rewrite the command`**');
- duration = collected.first().content * 60000;
- collected.first().delete();
- msg.edit(':three:| **Please enter the giveaway prize. This will also begin the giveaway **').then(msg => {
- message.channel.awaitMessages(filter, {
- max: 1,
- time: 20000,
- errors: ['time']
- }).then(collected => {
- title = collected.first().content;
- collected.first().delete();
- msg.delete();
- message.delete();
- try {
- let giveEmbed = new Discord.RichEmbed()
- .setDescription(`**${title}** \nReact With 🎉 To Enter! \nTime remaining : ${duration / 60000} **Minutes**\n **Created at :** ${hours}:${minutes}:${seconds} ${suffix}`)
- .setFooter(message.author.username, message.author.avatarURL);
- message.guild.channels.find("name" , room).send('🎉 **Giveaway Created** 🎉' , {embed: giveEmbed}).then(m => {
- let re = m.react('🎉');
- setTimeout(() => {
- let users = m.reactions.get("🎉").users;
- let list = users.array().filter(u => u.id !== m.author.id !== client.user.id);
- let gFilter = list[Math.floor(Math.random() * list.length) + 0]
- let endEmbed = new Discord.RichEmbed()
- .setAuthor(message.author.username, message.author.avatarURL)
- .setTitle(title)
- .addField('Giveaway Ended !🎉',`Winners : ${gFilter} \nEnded at :`)
- .setTimestamp()
- m.edit('** 🎉 GIVEAWAY ENDED 🎉**' , {embed: endEmbed});
- message.guild.channels.find("name" , room).send(`**Congratulations __${gFilter}!__ You won The Giveaway 🎉-> \`${title}\`**` , {})
- },duration);
- });
- } catch(e) {
- message.channel.send(`:heavy_multiplication_x:| **I Don't Have Prems**`);
- console.log(e);
- }
- });
- });
- });
- });
- });
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement