Advertisement
Guest User

sethy tutorial help

a guest
Feb 20th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. const fs = require("fs");
  2. const money = require("../../money.js");
  3. const { RichEmbed } = require("discord.js");
  4. const Discord = require("discord.js")
  5. const ms = require("parse-ms")
  6. const cooldowns = require("../../cooldowns.js")
  7.  
  8. module.exports = {
  9. name: "daily",
  10. category: "economy",
  11. description: "gives your daily money.",
  12. usage: "[daily,]",
  13. run: async (client, message, args) => {
  14.  
  15. let timeout = 86400000;
  16. let reward = 100;
  17.  
  18. let embed = new RichEmbed();
  19. embed.setTitle("Daily Reward!")
  20.  
  21. if(!money[message.auhtor.id]) {
  22.  
  23. money[message.author.id] = {
  24. name: client.users.get(message.author.id).tag,
  25. money: reward
  26. }
  27. fs.writeFile("../../money.js", JSON.stringify(money), (err) => {
  28. if(err) console.log(err);
  29.  
  30. });
  31.  
  32. if(!cooldowns[message.author.id]) {
  33. cooldowns[message.author.id] = {
  34. name: client.users.get(message.author.id).tag,
  35. daily: Date.now()
  36. }
  37. fs.writeFile("../../cooldowns.js", JSON.stringify(cooldowns), (err) => {
  38. if(err) console.log(err)
  39. });
  40.  
  41.  
  42.  
  43. money[message.auhtor.id].money += reward;
  44. fs.writeFile("../../money.js", JSON.stringify(money), (err) => {
  45. if(err) console.log(err);
  46.  
  47. });
  48.  
  49. embed.setDescription(`You collectod your daily reward $${reward}. Current balance is ${money[message.author.id].money}.`);
  50. embed.setColor("#346beb");
  51.  
  52. message.channel.send(embed);
  53.  
  54.  
  55.  
  56.  
  57. } else {
  58.  
  59. if(timeout - (date.now() - cooldowns[message.author.id].daily) > 0) {
  60.  
  61. let time = ms(timeout - (date.now() - cooldowns[message.auhtor.id]));
  62.  
  63. embed.setColor("#ff0000")
  64. embed.setDescription(`**You already collected your daily reward!**`);
  65. embed.addField(`Collect again in`,`**${time.hours}h ${time.minutes}m ${time.seconds}s`);
  66. message.channel.send(embed);
  67. } else {
  68.  
  69. money[message.author.id].money += reward;
  70. fs.writeFile("../../money.js", JSON.stringify(money), (err) => {
  71. if(err) console.log(err);
  72.  
  73. });
  74. }
  75.  
  76. }
  77.  
  78.  
  79.  
  80.  
  81. }
  82. }
  83.  
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement