Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require('discord.js');
- const Listing = require('./../modules/Listing');
- module.exports.run = async (bot,msg,args) => {
- let snipeChannel = msg.channel;
- const filter = m => !matchMedia.author.bot;
- let game = new Listing();
- let editLast3 = null;
- let startmsg = new Discord.RichEmbed()
- .setTitle("Fortnite Scrims")
- .setDescription("Please Write the Last 3 Codes From Your Server id")
- .setColor("#8600b3")
- .setFooter("HoldShift");
- msg.channel.send({embed: startmsg});
- let time = 30;
- let editTime = "";
- let timeEmbed = new Discord.RichEmbed()
- .setTitle("Next Match in approx...")
- .setDescription(time + "minutes")
- .setColor("#8600b3");
- setTimeout(async () => {
- editTime = await msg.channel.send({embed: timeEmbed}).catch( (err) => {
- console.log("Cant edit deleted msg");
- });
- }, 10);
- let timeInterval = setInterval(() => {
- if (time === 1){
- time -=1;
- timeEmbed.setDescription(time + " minutes");
- clearInterval(timeIn);
- }else {
- time -= 1;
- timeEmbed.setDescription(time = " minutes");
- }
- editTime.edit({embed: timeEmbed}).catch((err) => {
- console.log("cant edit");
- clearInterval(timeInterval);
- });
- },60000);
- let last3 = new Discord.RichEmbed()
- .setTitle("Last 3 code")
- .setColor("#8600b3");
- setTimeout(async () => {
- editLast3 = await message.channel.send({embed: last3});
- }, 10)
- const collector = snipecChannel.createMessageCollector(filter, {max: 200, maxMatches: 200, time: 180000});
- collector.on('collect', m => {
- console.log(`Collected ${m.content} | ${m.author.username}`);
- if(game.data.length === 0 && m.content.length === 3){
- game.addID(m.content.toUpperCase(), m.author.username);
- }else if (m.content.length === 3){
- if (game.userPresent(m.author.username)){
- game.deleteUserEntry(m.author.username);
- if (game.idPresent(m.content.toUpperCase())){
- game.addUser(m.content.toUpperCase(), m.author.username);
- }else {
- game.addID(m.content.toUpperCase(),m.author.username);
- }
- } else {
- if (game.idPresent(m.content.toUpperCase())){
- game.addUser(message.content.toUpperCase(), message.author.username);
- }else {
- game.addID(m.content.toUpperCase(), m.author.username);
- }
- }
- game.sort();
- let str = "";
- last3 = new Discord.RichEmbed()
- .setTitle("Last 3 code")
- .setColor("#8600b3")
- for (var i = 0; i < game.data.length; i++){
- str = "";
- for (var j = 0; j < game.data[i].users.length ; j++){
- str += game.data[i].users[j] + "\n";
- }
- last3.addField(`${game.data[i].id.toUpperCase()} - ${game.data[i].users.length} PLAYERS`, str, true);
- }
- editLast3.edit({embed: last3}).catch((err) => {
- console.log("Caught eddit error")
- });
- if (m.deleteable){
- m.delete().catch((err) => {
- console.log("Cant delete");
- console.log(err);
- });
- }
- };
- collector.on('end', collected => {
- console.log(`Collected ${collected.size} items`);
- });
- })
- }
- module.exports.help = {
- name: "start"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement