Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fs = require("fs");
- const money = require("../../money.js");
- const { RichEmbed } = require("discord.js");
- const Discord = require("discord.js")
- const ms = require("parse-ms")
- const cooldowns = require("../../cooldowns.js")
- module.exports = {
- name: "daily",
- category: "economy",
- description: "gives your daily money.",
- usage: "[daily,]",
- run: async (client, message, args) => {
- let timeout = 86400000;
- let reward = 100;
- let embed = new RichEmbed();
- embed.setTitle("Daily Reward!")
- if(!money[message.auhtor.id]) {
- money[message.author.id] = {
- name: client.users.get(message.author.id).tag,
- money: reward
- }
- fs.writeFile("../../money.js", JSON.stringify(money), (err) => {
- if(err) console.log(err);
- });
- if(!cooldowns[message.author.id]) {
- cooldowns[message.author.id] = {
- name: client.users.get(message.author.id).tag,
- daily: Date.now()
- }
- fs.writeFile("../../cooldowns.js", JSON.stringify(cooldowns), (err) => {
- if(err) console.log(err)
- });
- money[message.auhtor.id].money += reward;
- fs.writeFile("../../money.js", JSON.stringify(money), (err) => {
- if(err) console.log(err);
- });
- embed.setDescription(`You collectod your daily reward $${reward}. Current balance is ${money[message.author.id].money}.`);
- embed.setColor("#346beb");
- message.channel.send(embed);
- } else {
- if(timeout - (date.now() - cooldowns[message.author.id].daily) > 0) {
- let time = ms(timeout - (date.now() - cooldowns[message.auhtor.id]));
- embed.setColor("#ff0000")
- embed.setDescription(`**You already collected your daily reward!**`);
- embed.addField(`Collect again in`,`**${time.hours}h ${time.minutes}m ${time.seconds}s`);
- message.channel.send(embed);
- } else {
- money[message.author.id].money += reward;
- fs.writeFile("../../money.js", JSON.stringify(money), (err) => {
- if(err) console.log(err);
- });
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement