Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const fs = require("fs");
  3. let coins = require("../coins.json");
  4. module.exports.run = async (bot, message, args) => {
  5. if(!coins[message.author.id]){
  6. return message.reply("You don't have any coins!")
  7. }
  8. let pUser = message.guild.member(message.mentions.users.first()) || message.guild.members.get(args[0]);
  9. if(!coins[pUser.id]){
  10. coins[pUser.id] = {
  11. coins: 0
  12. };
  13. }
  14. let pCoins = coins[pUser.id].coins;
  15. let sCoins = coins[message.author.id].coins;
  16. if(sCoins < args[0]) return message.reply("Not enough coins there!");
  17. coins[message.author.id] = {
  18. coins: sCoins - parseInt(args[1])
  19. };
  20. coins[pUser.id] = {
  21. coins: pCoins + parseInt(args[1])
  22. };
  23. message.channel.send(`${message.author} has given ${pUser} ${args[1]} coins.`);
  24. fs.writeFile("./coins.json", JSON.stringify(coins), (err) => {
  25. if(err) cosole.log(err)
  26. });
  27. }
  28. module.exports.help = {
  29. name: "pay"
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement