2019-12-27 05:06:50 +00:00
|
|
|
const {
|
|
|
|
table
|
|
|
|
} = require("quick.db");
|
|
|
|
const ms = require("parse-ms");
|
|
|
|
const random = require("random-all");
|
|
|
|
|
|
|
|
const Users = new table("users");
|
|
|
|
const Backend = new table("backend");
|
|
|
|
let d;
|
2019-11-10 08:42:09 +00:00
|
|
|
let hasVoted = false;
|
2019-12-27 05:06:50 +00:00
|
|
|
let Placeholder = "318044130796109825";
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
CalculateFromMessage: async function (Message) {
|
|
|
|
let hasVoted = await Users.get(`${Message.author.id}.voted`);
|
|
|
|
content = Message.content;
|
|
|
|
length = Message.content.length;
|
2020-01-03 16:27:32 +00:00
|
|
|
if (hasVoted) d = 1
|
2019-12-27 05:06:50 +00:00
|
|
|
else d = 0.01;
|
|
|
|
e = (length * d).toFixed(1);
|
|
|
|
return await Users.add(`${Message.author.id}.money.bank`, e);
|
|
|
|
},
|
|
|
|
Dailies: async function (User = Placeholder) {
|
|
|
|
let timeout = 86400000;
|
|
|
|
let amount = Math.floor(Math.random() * (200 - 150) + 150);
|
|
|
|
|
|
|
|
let daily = await Users.get(`${User}.money.daily`);
|
|
|
|
if (daily !== null && timeout - (Date.now() - daily) > 0) {
|
|
|
|
let time = ms(timeout - (Date.now() - daily));
|
|
|
|
|
|
|
|
throw new Error(`${time.hours}h ${time.minutes}m ${time.seconds}s`);
|
|
|
|
} else {
|
|
|
|
Users.add(`${User}.money.bank`, amount);
|
|
|
|
Users.set(`${User}.money.daily`, Date.now());
|
|
|
|
|
|
|
|
return {
|
|
|
|
success: true,
|
|
|
|
amount
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
weekly: async function (User = Placeholder) {
|
|
|
|
let timeout = 604800000;
|
|
|
|
let amount = Math.floor(Math.random() * (500 - 300) + 300);
|
|
|
|
|
|
|
|
let weekly = await Users.get(`${User}.money.weekly`);
|
|
|
|
if (weekly !== null && timeout - (Date.now() - weekly) > 0) {
|
|
|
|
let time = ms(timeout - (Date.now() - weekly));
|
|
|
|
throw new Error(
|
|
|
|
`${time.days}d ${time.hours}h ${time.minutes}m ${time.seconds}s`
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
Users.add(`${User}.money.bank`, amount);
|
|
|
|
Users.set(`${User}.money.weekly`, Date.now());
|
2019-11-10 08:42:09 +00:00
|
|
|
|
2019-12-27 05:06:50 +00:00
|
|
|
return {
|
|
|
|
success: true,
|
|
|
|
amount
|
|
|
|
};
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Math.floor(Math.random() * (500 - 300) + 300);
|
|
|
|
quick: async function (kind, User = Placeholder) {
|
|
|
|
let way = {
|
|
|
|
work: {
|
|
|
|
payout: Math.floor(Math.random() * (500 - 300) + 300),
|
|
|
|
fine: Math.floor(Math.random() * (300 - 50) + 50),
|
|
|
|
probability: random.getBoolean(85)
|
|
|
|
},
|
|
|
|
slut: {
|
|
|
|
payout: Math.floor(Math.random() * (500 - 300) + 300),
|
|
|
|
fine: Math.floor(Math.random() * (300 - 50) + 50),
|
|
|
|
probability: random.getBoolean(60)
|
|
|
|
},
|
|
|
|
crime: {
|
|
|
|
payout: Math.floor(Math.random() * (500 - 300) + 300),
|
|
|
|
fine: Math.floor(Math.random() * (300 - 50) + 50),
|
|
|
|
probability: random.getBoolean(55)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
if (way.hasOwnProperty(kind)) {
|
|
|
|
if (way[kind].probability) {
|
|
|
|
Users.add(`${User}.money.cash`, way[kind].payout);
|
|
|
|
return {
|
|
|
|
money: way[kind].payout,
|
2020-01-03 16:27:32 +00:00
|
|
|
text: `You got ${way[kind].payout}<:coin:574116462260912138> from doing ${kind}`
|
2019-12-27 05:06:50 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Users.subtract(`${User}.money.cash`, way[kind].fine);
|
|
|
|
return {
|
|
|
|
money: way[kind].fine,
|
2020-01-03 16:27:32 +00:00
|
|
|
text: `You were fined **${way[kind].fine}**<:coin:574116462260912138> `
|
2019-12-27 05:06:50 +00:00
|
|
|
}
|
2019-11-10 08:42:09 +00:00
|
|
|
|
2019-12-27 05:06:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|