Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const credits = JSON.parse(fs.readFileSync('./credits.json'));
- const creditsPath = './credits.json';
- var time = require("./time.json");
- client.on('message',async message => {
- if(message.author.bot || message.channel.type === 'dm') return;
- let args = message.content.split(' ');
- let author = message.author.id;
- if(!credits[author]) credits[author] = {
- credits: 0
- }
- if(!credits[author]) credits[author] = {
- blacklist: false
- }
- fs.writeFileSync(creditsPath, JSON.stringify(credits, null, 4));
- if(credits[message.author.id].blacklist === true) return undefined;
- if(args[0].toLowerCase() == `${prefix}credit` || args[0].toLowerCase() === `${prefix}credits`) {
- const mention = message.mentions.users.first() || client.users.get(args[1]) || message.author;
- const mentionn = message.mentions.users.first() || client.users.get(args[1]);
- if(!args[2]) {
- message.channel.send(`**💰 | ${mention.username}, Your credits \`$${credits[mention.id].credits}\`**`)
- } else if(mentionn && args[2]) {
- if(credits[message.author.id].blacklist === true) return undefined;
- if(isNaN(args[2])) return message.channel.send(`**<a:PureYes1:640231382060236819> Using: \`${prefix}credit [mentionuser] [amount]\`**`);
- if(args[2] < 1) return message.channel.send(`**<a:PureYes1:640231382060236819> Using: \`${prefix}credit [mentionuser] [amount]\`**`);
- if(mention.bot) return message.channel.send(`**<a:PureYes1:640231382060236819> Using: \`${prefix}credit [mentionuser] [amount]\`**`);
- if(mentionn.id === message.author.id) return message.channel.send(`**<a:PureYes1:640231382060236819> Using: \`${prefix}credit [mentionuser] [amount]\`**`);
- if(args[2] > credits[author].credits) return message.channel.send(`**<a:PureNo1:640233851062452224> | You don\'t have enough credit**`);
- if(args[2].includes("-")) return message.channel.send(`**<a:PureYes1:640231382060236819> Using: \`${prefix}credit [mentionuser] [amount]\`**`);
- if(args[2].includes(".")) return message.channel.send(`**<a:PureYes1:640231382060236819> Using: \`${prefix}credit [mentionuser] [amount]\`**`);
- let first = Math.floor(Math.random() * 9);
- let second = Math.floor(Math.random() * 9);
- let third = Math.floor(Math.random() * 9);
- let fourth = Math.floor(Math.random() * 9);
- let num = `${first}${second}${third}${fourth}`;
- message.channel.send(`**\`$${args[2]}\` will be converted to ${mentionn}, if you want to transfer type: \`${num}\`**`).then(m => {
- message.channel.awaitMessages(r => r.author.id === message.author.id, { max: 1, time: 20000, errors:['time'] }).then(collected => {
- if(collected.first().content === num) {
- client.channels.get("643132886899490817").send(`**
- تم التحول من : ${message.author.username} | (ID: \`${message.author.id}\`)
- تم التحول الي : ${mentionn.username} | (ID: \`${mentionn.id}\`)
- المبلغ : \`$${args[2]}\`
- **`);
- message.channel.send(`**<a:PureYes1:640231382060236819> | ${message.author.username}, The conversion was successful**`);
- mention.send(`**<a:PureYes1:640231382060236819> | New Transfer:\n You have received \`$${args[2]}\` from ${message.author.username} | (ID: \`${message.author.id}\`)**`);
- m.delete();
- credits[author].credits += Math.floor((-args[2]));
- credits[mentionn.id].credits += Math.floor((+args[2]));
- fs.writeFileSync(creditsPath, JSON.stringify(credits, null, 4));
- } else {
- m.delete();
- }
- })
- })
- }else {
- message.channel.send(`**<a:PureYes1:640231382060236819> Using: \`${prefix}credit [mentionuser] [amount]\`**`);
- }
- }
- if(args[0].toLowerCase() === `${prefix}daily`) {
- if(credits[message.author.id].blacklist === true) return undefined;
- let cooldown = 8.64e+7
- let Daily = time[message.author.id]
- if (Daily !== null && cooldown - (Date.now() - Daily) > 0) {
- let times = (cooldown - (Date.now() - Daily));
- message.channel.send(`**⏲ | ${message.author.username}, Wait \`(${pretty(times, {verbose:true})})\`**`);
- fs.writeFile("./time.json", JSON.stringify(time), function(e) {
- if(e)throw e;
- })
- }else{
- let ammount = Math.round(Math.random() * 1250);
- credits[author].credits += ammount;
- time[message.author.id] = Date.now();
- message.channel.send(`**💲 | ${message.author.username}, You've taken \`$${ammount}\`**`);
- fs.writeFile("./credits.json", JSON.stringify(credits), function(e) {
- if(e)throw e;
- })
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement