Advertisement
iBeAnthonyD

speed games

Mar 8th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. client.on('message', message => {
  2. if (!points[message.author.id]) points[message.author.id] = {
  3.     points: 0,
  4.   };
  5.   if(!message.guild) return;
  6.     let id = message.author.id,prefix="s!";
  7.     if (speed[id] && (new Date).getTime() - speed[id] < 15*1000) {
  8.         let r = (new Date).getTime() - speed[id];
  9.         r = 15*1000 - r;
  10.     }
  11.     if ( message.content == prefix+'speed'){
  12.        
  13.         try{
  14. }catch(e){
  15.  
  16. }
  17.  
  18.     if(!message.channel.guild) return message.reply('**هذا الأمر للسيرفرات فقط**').then(m => m.delete(3000));
  19.  
  20.  
  21. const item = speed[Math.floor(Math.random() * speed.length)];
  22. const filter = response => {  
  23.     return item.answers.some(answer => answer.toLowerCase() === response.content.toLowerCase());
  24. };
  25. message.channel.send('**Game is Start now...!**').then(msg => {
  26.  
  27.  const embed = new Discord.RichEmbed()
  28.  .setColor("0054dd")
  29.      .setAuthor(`⏳ |You have »15« seconds to type the word`)
  30.           .setImage(`${item.type}`)
  31.  .setFooter(`${message.author.tag}`, message.author.avatarURL)
  32.  
  33.  
  34.          
  35. msg.channel.send(embed).then(() => {
  36.         message.channel.awaitMessages(filter, { maxMatches: 1, time: 15000, errors: ['time'] })
  37.         .then((collected) => {
  38.                   const sh = new Discord.RichEmbed()
  39.   .setColor("04791c")
  40. .setDescription('**✅ |Good Job +1P**')
  41. .addField('Type $mypoints', 'To Show ur Points' , true)
  42. .setFooter(message.author.username, message.author.avatarURL)
  43. message.channel.sendEmbed(sh);
  44.             let won = collected.first().author; // في هذا السطر يقوم الكود بسحب الأي دي الذي قام بالأجابة اولاً
  45.             points[won.id].points++;
  46.           })
  47.           .catch(collected => { // في حال لم يقم أحد بالإجابة
  48.             message.channel.send(`🔚 |**Time Is End**`);
  49.           })
  50.           fs.writeFile("./points.json", JSON.stringify(points), (err) => {
  51.     if (err) console.error(err)
  52.           })
  53.         })
  54.     })
  55.     speed[id] = (new Date).getTime()
  56. }
  57. });
  58. client.on('message', message => {
  59. if (message.content.startsWith(prefix + 'mypoints')) {
  60.     if(!message.channel.guild) return message.reply('**هذا الأمر للسيرفرات فقط**').then(m => m.delete(3000));
  61.     let userData = points[message.author.id];
  62.     let embed = new Discord.RichEmbed()
  63.     .setAuthor(`${message.author.tag}`, message.author.avatarURL)
  64.     .setColor('#000000')
  65.     .setDescription(`نقاطك: \`${userData.points}\``)
  66.     message.channel.sendEmbed(embed)
  67.   }
  68.   fs.writeFile("./points.json", JSON.stringify(points), (err) => {
  69.     if (err) console.error(err)
  70.   })
  71. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement