Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const Listing = require('./../modules/Listing');
  3.  
  4.  
  5. module.exports.run = async (bot,msg,args) => {
  6. let snipeChannel = msg.channel;
  7. const filter = m => !matchMedia.author.bot;
  8. let game = new Listing();
  9.  
  10. let editLast3 = null;
  11.  
  12. let startmsg = new Discord.RichEmbed()
  13. .setTitle("Fortnite Scrims")
  14. .setDescription("Please Write the Last 3 Codes From Your Server id")
  15. .setColor("#8600b3")
  16. .setFooter("HoldShift");
  17.  
  18. msg.channel.send({embed: startmsg});
  19.  
  20. let time = 30;
  21. let editTime = "";
  22.  
  23. let timeEmbed = new Discord.RichEmbed()
  24. .setTitle("Next Match in approx...")
  25. .setDescription(time + "minutes")
  26. .setColor("#8600b3");
  27.  
  28. setTimeout(async () => {
  29. editTime = await msg.channel.send({embed: timeEmbed}).catch( (err) => {
  30. console.log("Cant edit deleted msg");
  31. });
  32. }, 10);
  33.  
  34. let timeInterval = setInterval(() => {
  35. if (time === 1){
  36. time -=1;
  37. timeEmbed.setDescription(time + " minutes");
  38. clearInterval(timeIn);
  39. }else {
  40. time -= 1;
  41. timeEmbed.setDescription(time = " minutes");
  42. }
  43.  
  44. editTime.edit({embed: timeEmbed}).catch((err) => {
  45. console.log("cant edit");
  46. clearInterval(timeInterval);
  47. });
  48.  
  49. },60000);
  50.  
  51. let last3 = new Discord.RichEmbed()
  52. .setTitle("Last 3 code")
  53. .setColor("#8600b3");
  54.  
  55. setTimeout(async () => {
  56. editLast3 = await message.channel.send({embed: last3});
  57. }, 10)
  58.  
  59. const collector = snipecChannel.createMessageCollector(filter, {max: 200, maxMatches: 200, time: 180000});
  60.  
  61. collector.on('collect', m => {
  62. console.log(`Collected ${m.content} | ${m.author.username}`);
  63.  
  64. if(game.data.length === 0 && m.content.length === 3){
  65. game.addID(m.content.toUpperCase(), m.author.username);
  66. }else if (m.content.length === 3){
  67. if (game.userPresent(m.author.username)){
  68. game.deleteUserEntry(m.author.username);
  69. if (game.idPresent(m.content.toUpperCase())){
  70. game.addUser(m.content.toUpperCase(), m.author.username);
  71. }else {
  72. game.addID(m.content.toUpperCase(),m.author.username);
  73. }
  74. } else {
  75. if (game.idPresent(m.content.toUpperCase())){
  76. game.addUser(message.content.toUpperCase(), message.author.username);
  77. }else {
  78. game.addID(m.content.toUpperCase(), m.author.username);
  79. }
  80. }
  81.  
  82.  
  83. game.sort();
  84.  
  85. let str = "";
  86. last3 = new Discord.RichEmbed()
  87. .setTitle("Last 3 code")
  88. .setColor("#8600b3")
  89.  
  90. for (var i = 0; i < game.data.length; i++){
  91. str = "";
  92. for (var j = 0; j < game.data[i].users.length ; j++){
  93. str += game.data[i].users[j] + "\n";
  94. }
  95. last3.addField(`${game.data[i].id.toUpperCase()} - ${game.data[i].users.length} PLAYERS`, str, true);
  96. }
  97.  
  98. editLast3.edit({embed: last3}).catch((err) => {
  99. console.log("Caught eddit error")
  100. });
  101.  
  102. if (m.deleteable){
  103. m.delete().catch((err) => {
  104. console.log("Cant delete");
  105. console.log(err);
  106. });
  107. }
  108.  
  109. };
  110.  
  111. collector.on('end', collected => {
  112. console.log(`Collected ${collected.size} items`);
  113. });
  114. })
  115.  
  116. }
  117.  
  118.  
  119.  
  120. module.exports.help = {
  121. name: "start"
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement