Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Canvas = require('canvas')
- const credits = JSON.parse(fs.readFileSync("./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
- };
- fs.writeFileSync("./credits.json", JSON.stringify(credits, null, 4));
- if (args[0].toLowerCase() == `${prefix}credits` ||
- args[0].toLowerCase() === `${prefix}credit` ||
- args[0].toLowerCase() === `c`
- ) {
- const mention = message.mentions.users.first() || message.author;
- const mentionn = message.mentions.users.first();
- if (!args[2]) {
- message.channel.send(
- `**:bank: | ${mention.username}, Your :credit_card: balance is \`$${credits[mention.id].credits}\`**`
- );
- } else if (mentionn && args[2]) {
- if (isNaN(args[2])) return message.channel.send(`** :interrobang: | ${message.author.username}, i can't find it!**`);
- if (args[2] < 1) return message.channel.send(`** :interrobang: | ${message.author.username}, type the credit you need to transfer!**`);
- if (mention.bot) return message.channel.send(`**:thinking: | ${message.author.username}, bots do not have credits**`);
- if (mentionn.id === message.author.id)
- return message.channel.send(`**:interrobang: | ${message.author.username}, I can't find User **`);
- if (args[2] > credits[author].credits)
- return message.channel.send(
- `**:thinking: | ${message.author.username}, Your balance is not enough for that!**`
- );
- if (args[2].includes("-")) return message.channel.send(`**:interrobang: | ${message.author.username}, type the credit you need to transfer!**`);
- //let resulting = Math.floor(args[2] - args[2] * (5 / 100));
- let tax = Math.floor(args[2] * (5 / 100));
- let first = Math.floor(Math.random() * 10);
- let second = Math.floor(Math.random() * 10);
- let third = Math.floor(Math.random() * 10);
- let fourth = Math.floor(Math.random() * 10);
- let num = `${ first }${ second }${ third }${ fourth }`;
- let canvas = Canvas.createCanvas(100, 50);
- let ctx = canvas.getContext("2d");
- //let tax = message.content.split(" ")[1]
- let Price = message.content.split(" ")[2];
- //tax = tax.replace(/%5/g,"");
- let resulting = Math.floor(Price-(Price*(5/100))); const background = await Canvas.loadImage(
- "https://cdn.discordapp.com/attachments/365219235288317962/656362038884565014/captcha.png"
- );
- ctx.drawImage(background, 6, 3, canvas.width, canvas.height);
- ctx.font = "25px Tahoma";
- ctx.fontSize = "7px";
- ctx.fillStyle = "Yellow";
- message.delete();
- //let resulting = Math.floor(Price-(Price*(5/100)));
- message.channel.send(`**${message.author.username}, Transfer Fees \`${tax}\`, Amount :\`${resulting}\` **
- type these numbers to confirm : `
- ).then(m => {
- ctx.fillText(num, canvas.width / 4.8, canvas.height / 1.5);
- message.channel.sendFile(canvas.toBuffer()).then(s => {
- message.channel
- .awaitMessages(r => r.author.id === message.author.id, {
- max: 1,
- time: 20000,
- errors: ["time"]
- })
- .then(collected => {
- if (collected.first().content === num) {
- message.channel.send(
- `**:moneybag: | ${
- message.author.username
- }, has transferred \`$${resulting}\` to ${mentionn}**`
- ); m.delete();
- s.delete();
- mention.send(
- `**:atm: | Transfer Receipt**\`\`\`You Have Received \$${resulting}\ From User ${message.author.username}; (ID ${ message.author.id })\`\`\``);
- m.delete();
- s.delete();
- credits[author].credits += Math.floor(
- -resulting
- );
- credits[mentionn.id].credits += Math.floor(
- +resulting
- );
- fs.writeFileSync(
- "./credits.json",
- JSON.stringify(credits, null, 4)
- );
- } else {
- m.delete();
- }
- });
- });
- });
- }
- }
- if (args[0].toLowerCase() === `${prefix}daily` ||
- args[0].toLowerCase() === `d`
- ) {
- let cooldown = 8.64e7;
- let Daily = time[message.author.id];
- if (Daily !== null && cooldown - (Date.now() - Daily) > 0) {
- let times = cooldown - (Date.now() - Daily);
- message.channel.send( `**:rolling_eyes: | ${ message.author.username }, your daily credits refreshes in \'${pretty(times, { verbose: true })}'.\**`);
- fs.writeFile("./time.json", JSON.stringify(time), function(e) {
- if (e) throw e;
- });
- } else {
- let ammount = (300, 500, 100, 200, 120, 150, 350, 320, 220, 250);
- credits[author].credits += ammount;
- time[message.author.id] = Date.now();
- message.channel.send(
- `**:moneybag: ${message.author.username}, You got :dollar: ${ammount} daily credits!**`
- );
- fs.writeFile("./credits.json", JSON.stringify(credits), function(e) {
- if (e) throw e;
- });
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement