mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-24 22:24:58 +05:00
Мелкие правки кода
This commit is contained in:
parent
f52ddc6e25
commit
3c560b5c7a
9 changed files with 53 additions and 30 deletions
|
@ -48,19 +48,18 @@ class Bank extends BaseCommand {
|
|||
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
|
||||
if (data.memberData.money < credits) return interaction.error("economy/bank:NOT_ENOUGH_CREDIT", { money: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` });
|
||||
|
||||
data.memberData.money -= credits;
|
||||
data.memberData.bankSold += credits;
|
||||
await data.memberData.save();
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/transactions:BANK"),
|
||||
amount: credits,
|
||||
date: Date.now(),
|
||||
type: "send"
|
||||
};
|
||||
|
||||
data.memberData.transactions.push(info);
|
||||
|
||||
data.memberData.money -= credits;
|
||||
data.memberData.bankSold += credits;
|
||||
await data.memberData.save();
|
||||
|
||||
interaction.success("economy/bank:SUCCESS_DEP", {
|
||||
money: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`
|
||||
});
|
||||
|
|
|
@ -82,16 +82,16 @@ class Number extends BaseCommand {
|
|||
guildId: interaction.guildId
|
||||
});
|
||||
|
||||
memberData.money += won;
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/transactions:NUMBERS"),
|
||||
amount: won,
|
||||
date: Date.now(),
|
||||
type: "got"
|
||||
};
|
||||
|
||||
data.memberData.transactions.push(info);
|
||||
|
||||
memberData.money += won;
|
||||
await memberData.save();
|
||||
}
|
||||
collector.stop();
|
||||
|
|
|
@ -53,20 +53,28 @@ class Pay extends BaseCommand {
|
|||
guildId: interaction.guildId
|
||||
});
|
||||
|
||||
const info = {
|
||||
user: member.user.tag,
|
||||
amount: amount,
|
||||
date: Date.now(),
|
||||
type: "send"
|
||||
};
|
||||
|
||||
data.memberData.transactions.push(info);
|
||||
data.memberData.money -= amount;
|
||||
await data.memberData.save();
|
||||
|
||||
memberData.money += amount;
|
||||
memberData.save();
|
||||
|
||||
const info1 = {
|
||||
user: member.user.tag,
|
||||
amount: amount,
|
||||
date: Date.now(),
|
||||
type: "send"
|
||||
};
|
||||
data.memberData.transactions.push(info1);
|
||||
|
||||
const info2 = {
|
||||
user: member.user.tag,
|
||||
amount: amount,
|
||||
date: Date.now(),
|
||||
type: "got"
|
||||
};
|
||||
data.memberData.transactions.push(info2);
|
||||
|
||||
interaction.success("economy/pay:SUCCESS", {
|
||||
user: member.toString(),
|
||||
amount: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`
|
||||
|
|
|
@ -48,6 +48,7 @@ class Rob extends BaseCommand {
|
|||
guildId: interaction.guildId
|
||||
});
|
||||
if (amount > memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: member.toString() });
|
||||
|
||||
const isInCooldown = memberData.cooldowns.rob || 0;
|
||||
if (isInCooldown) {
|
||||
if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: member.toString() });
|
||||
|
|
|
@ -101,6 +101,8 @@ class Slots extends BaseCommand {
|
|||
|
||||
const toAdd = credits - amount;
|
||||
|
||||
data.memberData.money += toAdd;
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/slots:DESCRIPTION"),
|
||||
amount: toAdd,
|
||||
|
@ -108,7 +110,6 @@ class Slots extends BaseCommand {
|
|||
type: "got"
|
||||
};
|
||||
data.memberData.transactions.push(info);
|
||||
data.memberData.money += toAdd;
|
||||
|
||||
if (!data.userData.achievements.slots.achieved) {
|
||||
data.userData.achievements.slots.progress.now += 1;
|
||||
|
|
|
@ -45,6 +45,9 @@ class TicTacToe extends BaseCommand {
|
|||
guildId: interaction.guildId
|
||||
});
|
||||
|
||||
memberData.money += 100;
|
||||
await memberData.save();
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/transactions:TTT"),
|
||||
amount: 100,
|
||||
|
@ -52,9 +55,6 @@ class TicTacToe extends BaseCommand {
|
|||
type: "got"
|
||||
};
|
||||
memberData.transactions.push(info);
|
||||
|
||||
memberData.money += 100;
|
||||
await memberData.save();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,16 +98,16 @@ class Work extends BaseCommand {
|
|||
]);
|
||||
}
|
||||
|
||||
data.memberData.money += won;
|
||||
await data.memberData.save();
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/work:SALARY"),
|
||||
amount: won,
|
||||
date: Date.now(),
|
||||
type: "got"
|
||||
};
|
||||
|
||||
data.memberData.transactions.push(info);
|
||||
data.memberData.money += won;
|
||||
await data.memberData.save();
|
||||
|
||||
const messageOptions = {
|
||||
embeds: [embed]
|
||||
|
|
|
@ -61,7 +61,7 @@ class MessageCreate extends BaseEvent {
|
|||
await data.userData.save();
|
||||
message.replyT("general/afk:DELETED", {
|
||||
username: message.author.username
|
||||
});
|
||||
}, { mention: true });
|
||||
}
|
||||
|
||||
message.mentions.users.forEach(async (u) => {
|
||||
|
|
|
@ -1,10 +1,26 @@
|
|||
// Thanks Stackoverflow <3
|
||||
function setDaysTimeout(callback, days) {
|
||||
// 86400 seconds in a day
|
||||
const msInDay = 86400 * 1000;
|
||||
|
||||
let dayCount = 0;
|
||||
const timer = setInterval(function () {
|
||||
dayCount++; // a day has passed
|
||||
|
||||
if (dayCount === days) {
|
||||
clearInterval(timer);
|
||||
callback.apply(this, []);
|
||||
}
|
||||
}, msInDay);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
*/
|
||||
module.exports.init = async function (client) {
|
||||
setInterval(async () => {
|
||||
const timestamp = Date.now() + (30 * 24 * 60 * 60 * 1000); // 1 month
|
||||
setDaysTimeout(async () => {
|
||||
const timestamp = Date.now() + (29 * 24 * 60 * 60 * 1000); // 29 days
|
||||
const members = client.membersData.find({ transactions: { $gt: [] } });
|
||||
|
||||
for (const member of members) {
|
||||
|
@ -17,10 +33,9 @@ module.exports.init = async function (client) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}, (7 * 24 * 60 * 60 * 1000)); // every 7 days
|
||||
}, 14);
|
||||
|
||||
/*
|
||||
setInterval(async () => {
|
||||
setDaysTimeout(async () => {
|
||||
client.usersData.find({}, function (err, res) {
|
||||
for (const user of res) {
|
||||
client.users.fetch(user.id).then(u => {
|
||||
|
@ -32,6 +47,5 @@ module.exports.init = async function (client) {
|
|||
});
|
||||
}
|
||||
});
|
||||
}, (7 * 24 * 60 * 60 * 1000)); // every 7 days
|
||||
*/
|
||||
}, 30);
|
||||
};
|
Loading…
Reference in a new issue