Advertisement
Guest User

Coinflip command

a guest
Feb 18th, 2019
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. const Discord = require('discord.js');
  2. const fs = require('fs');
  3.  
  4.  
  5. module.exports.run = async(bot, message, args) => {
  6.  
  7. const filter = m => m.author.id === message.author.id;
  8. message.reply("Choose either heads or tails. This message will expire in 10 seconds.").then(r => r.delete(10000));
  9. message.channel.awaitMessages(filter, {min: 2, max: 2, time: 10000}).then(collected => {
  10. if(collected.first().content === "cancel"){
  11. return message.reply("Canceled.");
  12. }
  13. else{
  14. var chance = Math.floor(Math.random() * 2) + 1;
  15.  
  16. if(chance == 1){
  17. result1 = "heads"
  18. }
  19. else{
  20. result1 = "tails"
  21. }
  22.  
  23. if(collected.first().content === result1){
  24. message.channel.send("You won!")
  25.  
  26. let flipwonembed = new Discord.RichEmbed()
  27. .setColor("#FF900")
  28. .setAuthor(message.author.tag)
  29. .addField("Flip", result1)
  30. .setThumbnail(message.author.avatarURL)
  31.  
  32. message.channel.send(flipwonembed)
  33.  
  34. }
  35.  
  36. if(collected.first().content !== result1){ //not equal to result1
  37. message.channel.send("You lost!")
  38.  
  39. let fliplostembed = new Discord.RichEmbed()
  40. .setColor("#FF900") //You can set the color to whatever you want
  41. .setAuthor(message.author.tag)
  42. .addField("Flip", result1)
  43. .setThumbnail(message.author.avatarURL)
  44.  
  45. message.channel.send(fliplostembed)
  46. }
  47.  
  48.  
  49.  
  50.  
  51.  
  52. }
  53. })
  54.  
  55. }
  56.  
  57.  
  58. module.exports.help = {
  59. name: "coinflip"
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement