diff --git a/!TO REWRITE/Economy/achievements.js b/!TO REWRITE/Economy/achievements.js deleted file mode 100644 index 1ba6ba0b..00000000 --- a/!TO REWRITE/Economy/achievements.js +++ /dev/null @@ -1,103 +0,0 @@ -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -class Achievements extends Command { - constructor(client) { - super(client, { - name: "achievements", - dirname: __dirname, - enabled: true, - guildOnly: false, - aliases: ["ac"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - let member = message.guild ? message.member : message.author; - if (args[0]) member = await this.client.resolveMember(args[0], message.guild); - if (message.guild && member.user.bot) return message.error("economy/profile:BOT_USER"); - - const userData = (member.id === message.author.id ? data.userData : await this.client.findOrCreateUser({ - id: member.id - })); - - const embed = new Discord.EmbedBuilder() - .setAuthor({ - name: message.translate("economy/achievements:TITLE") - }) - .setColor(data.config.embed.color) - .setFooter({ - text: data.config.embed.footer - }); - - embed.addFields([ - { - name: message.translate("economy/achievements:SEND_CMD"), - value: message.translate("economy/achievements:PROGRESS", { - now: userData.achievements.firstCommand.progress.now, - total: userData.achievements.firstCommand.progress.total, - percent: Math.round(100 * (userData.achievements.firstCommand.progress.now / userData.achievements.firstCommand.progress.total)) - }) - }, - { - name: message.translate("economy/achievements:CLAIM_SALARY"), - value: message.translate("economy/achievements:PROGRESS", { - now: userData.achievements.work.progress.now, - total: userData.achievements.work.progress.total, - percent: Math.round(100 * (userData.achievements.work.progress.now / userData.achievements.work.progress.total)) - }) - }, - { - name: message.translate("economy/achievements:MARRY"), - value: message.translate("economy/achievements:PROGRESS", { - now: userData.achievements.married.progress.now, - total: userData.achievements.married.progress.total, - percent: Math.round(100 * (userData.achievements.married.progress.now / userData.achievements.married.progress.total)) - }) - }, - { - name: message.translate("economy/achievements:SLOTS"), - value: message.translate("economy/achievements:PROGRESS", { - now: userData.achievements.slots.progress.now, - total: userData.achievements.slots.progress.total, - percent: Math.round(100 * (userData.achievements.slots.progress.now / userData.achievements.slots.progress.total)) - }) - }, - { - name: message.translate("economy/achievements:TIP"), - value: message.translate("economy/achievements:PROGRESS", { - now: userData.achievements.tip.progress.now, - total: userData.achievements.tip.progress.total, - percent: Math.round(100 * (userData.achievements.tip.progress.now / userData.achievements.tip.progress.total)) - }) - }, - { - name: message.translate("economy/achievements:REP"), - value: message.translate("economy/achievements:PROGRESS", { - now: userData.achievements.rep.progress.now, - total: userData.achievements.rep.progress.total, - percent: Math.round(100 * (userData.achievements.rep.progress.now / userData.achievements.rep.progress.total)) - }) - }, - { - name: message.translate("economy/achievements:INVITE"), - value: message.translate("economy/achievements:PROGRESS", { - now: userData.achievements.invite.progress.now, - total: userData.achievements.invite.progress.total, - percent: Math.round(100 * (userData.achievements.invite.progress.now / userData.achievements.invite.progress.total)) - }) - } - ]); - - message.reply({ - embeds: [embed] - }); - } -} - -module.exports = Achievements; \ No newline at end of file diff --git a/!TO REWRITE/Economy/birthdate.js b/!TO REWRITE/Economy/birthdate.js deleted file mode 100644 index 30e12059..00000000 --- a/!TO REWRITE/Economy/birthdate.js +++ /dev/null @@ -1,50 +0,0 @@ -const Command = require("../../base/Command"); - -class Birthdate extends Command { - constructor(client) { - super(client, { - name: "birthdate", - dirname: __dirname, - enabled: true, - guildOnly: false, - aliases: ["bd"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const date = args[0]; - if (!date) return message.error("economy/birthdate:MISSING_DATE"); - - const tArgs = date.split("/"); - const [day, month, year] = tArgs; - if (!day || !month || !year) return message.error("economy/birthdate:INVALID_DATE"); - - const match = date.match(/\d+/g); - if (!match) return message.error("economy/birthdate:INVALID_DATE"); - - const tday = +match[0], - tmonth = +match[1] - 1; - let tyear = +match[2]; - - if (tyear < 100) tyear += tyear < 50 ? 2000 : 1900; - - const d = new Date(tyear, tmonth, tday); - if (!(tday == d.getDate() && tmonth == d.getMonth() && tyear == d.getFullYear())) return message.error("economy/birthdate:INVALID_DATE"); - if (d.getTime() > Date.now()) return message.error("economy/birthdate:DATE_TOO_HIGH"); - if (d.getTime() < (Date.now() - 2.523e+12)) return message.error("economy/birthdate:DATE_TOO_LOW"); - - data.userData.birthdate = d; - data.userData.save(); - - message.success("economy/birthdate:SUCCESS", { - date: this.client.printDate(d) - }); - } -} - -module.exports = Birthdate; \ No newline at end of file diff --git a/!TO REWRITE/Economy/deposit.js b/!TO REWRITE/Economy/deposit.js deleted file mode 100644 index 3cdd2547..00000000 --- a/!TO REWRITE/Economy/deposit.js +++ /dev/null @@ -1,52 +0,0 @@ -const Command = require("../../base/Command"); - -class Deposit extends Command { - constructor(client) { - super(client, { - name: "deposit", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["bank", "dep"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - let amount = args[0]; - - if (!(parseInt(data.memberData.money, 10) > 0)) return message.error("economy/deposit:NO_CREDIT"); - - if (args[0] === "all") { - amount = parseInt(data.memberData.money, 10); - } else { - if (isNaN(amount) || parseInt(amount, 10) < 1) return message.error("economy/deposit:MISSING_AMOUNT"); - amount = parseInt(amount, 10); - } - - if (data.memberData.money < amount) return message.error("economy/deposit:NOT_ENOUGH_CREDIT", { money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` }); - - const info = { - user: message.translate("economy/transactions:BANK"), - amount: amount, - date: Date.now(), - type: "send" - }; - - data.memberData.transactions.push(info); - - data.memberData.money = data.memberData.money - amount; - data.memberData.bankSold = data.memberData.bankSold + amount; - data.memberData.save(); - - message.success("economy/deposit:SUCCESS", { - money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` - }); - } -} - -module.exports = Deposit; \ No newline at end of file diff --git a/!TO REWRITE/Economy/divorce.js b/!TO REWRITE/Economy/divorce.js deleted file mode 100644 index 84aabcf4..00000000 --- a/!TO REWRITE/Economy/divorce.js +++ /dev/null @@ -1,45 +0,0 @@ -const Command = require("../../base/Command"); - -class Divorce extends Command { - constructor(client) { - super(client, { - name: "divorce", - dirname: __dirname, - enabled: true, - guildOnly: false, - aliases: ["di"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - if (!data.userData.lover) return message.error("economy/divorce:NOT_MARRIED"); - - const user = this.client.users.cache.get(data.userData.lover) || await this.client.users.fetch(data.userData.lover); - - data.userData.lover = null; - data.userData.save(); - - const oldLover = await this.client.findOrCreateUser({ - id: user.id - }); - oldLover.lover = null; - oldLover.save(); - - message.success("economy/divorce:DIVORCED", { - username: user.username - }); - - user.send({ - content: message.translate("economy/divorce:DIVORCED_U", { - username: message.author.username - }) - }); - } -} - -module.exports = Divorce; \ No newline at end of file diff --git a/!TO REWRITE/Economy/horserace.js b/!TO REWRITE/Economy/horserace.js deleted file mode 100644 index 650db328..00000000 --- a/!TO REWRITE/Economy/horserace.js +++ /dev/null @@ -1,184 +0,0 @@ -const Command = require("../../base/Command"); - -const games = {}; - -class Horserace extends Command { - constructor(client) { - super(client, { - name: "horserace", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["hr"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - if (!args[0]) return message.error("economy/horserace:MISSING_STATUS"); - const author = message.author; - - if (args[0] === "create") { - let thisGame = games[message.channel.id]; - - if (thisGame) return message.error("economy/horserace:GAME_RUNNING"); - else { - games[message.channel.id] = { - horseSpeeds: [], - bets: [] - }; - - thisGame = games[message.channel.id]; - - const f = []; - for (let i = 0; i < 5; i++) { - const speed = this.client.functions.randomNum(1, 5); - const profit = { - 1: 3.5, - 2: 3, - 3: 2.5, - 4: 2, - 5: 1.5, - }; - // const profit = Math.floor((((8.9 / 9) * (6 - speed)) + 1.1) * 10) / 10; - thisGame.horseSpeeds.push(speed); - f.push({ - name: message.translate("economy/horserace:HORSE_NAME", { - number: i + 1 - }), - value: message.translate("economy/horserace:HORSE_VALUE", { - speed, - profit: profit[speed] - }) - }); - } - message.reply({ - embeds: [{ - color: data.config.embed.color, - title: message.translate("economy/horserace:EMBED_T"), - fields: f - }] - }); - } - } else if (args[0] === "bet") { - const thisGame = games[message.channel.id]; - const horse = parseInt(args[1]); - const amount = parseInt(args[2]); - - if (horse > 5) return message.error("economy/horserace:HORSE_NUM"); - if (!thisGame) return message.error("economy/horserace:NO_GAME_RUNNING"); - - if (!amount || isNaN(amount) || parseInt(amount, 10) <= 0) return message.error("economy/pay:INVALID_AMOUNT"); - if (amount > data.memberData.money) return message.error("economy/pay:ENOUGH_MONEY", { - amount: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDITS:1"), message.translate("misc:NOUNS:CREDITS:2"), message.translate("misc:NOUNS:CREDITS:5"))}` - }); - - thisGame.bets[author.id] = { - amount, - horse - }; - - message.sendT("economy/horserace:BET", { - user: author, - amount: `**${Math.floor(amount)}** ${message.getNoun(Math.floor(amount), message.translate("misc:NOUNS:CREDITS:1"), message.translate("misc:NOUNS:CREDITS:2"), message.translate("misc:NOUNS:CREDITS:5"))}`, - horse - }); - - } else if (args[0] === "go") { - const thisGame = games[message.channel.id]; - const horsePositions = [0, 0, 0, 0, 0]; - - if (!thisGame) return message.error("economy/horserace:NO_GAME_RUNNING"); - - // eslint-disable-next-line no-constant-condition - while (true) { - for (let i = 0; i < 5; i++) { - if (thisGame.horseSpeeds[i] >= Math.floor(Math.random() * 15)) { - horsePositions[i] += 1; - if (horsePositions[i] === 3) { - const winnings = []; - - const profit = { - 1: 3.5, - 2: 3, - 3: 2.5, - 4: 2, - 5: 1.5, - }; - - // const profit = Math.floor((((8.9 / 9) * (6 - thisGame.horseSpeeds[i])) + 1.1) * 10) / 10; - - for (let j = 0; j < Object.keys(thisGame.bets).length; j++) { - if (Object.values(thisGame.bets)[j].horse === i + 1) { - winnings.push([Object.keys(thisGame.bets)[j], Object.values(thisGame.bets)[j].amount * profit[thisGame.horseSpeeds[i]]]); - } - } - - if (winnings.length === 0) { - for (let j = 0; j < Object.keys(thisGame.bets).length; j++) { - if (Object.values(thisGame.bets)[j].horse !== i + 1) { - const memberData = await this.client.findOrCreateMember({ - id: Object.keys(thisGame.bets)[j], - guildID: message.guild.id - }); - - const info = { - user: message.translate("economy/transactions:HORSERACE"), - amount: Object.values(thisGame.bets)[j].amount, - date: Date.now(), - type: "send" - }; - - memberData.transactions.push(info); - memberData.money -= Object.values(thisGame.bets)[j].amount; - } - } - - message.sendT("economy/horserace:NO_WINNERS", { - horse: i + 1 - }); - } else { - let winners = ""; - for (let j = 0; j < winnings.length; j++) { - winners += `\n<@${winnings[j][0]}> выиграл **${Math.floor(winnings[j][1])}** ${message.getNoun(Math.floor(winnings[j][1]), message.translate("misc:NOUNS:CREDITS:1"), message.translate("misc:NOUNS:CREDITS:2"), message.translate("misc:NOUNS:CREDITS:5"))}!`; - - const memberData = await this.client.findOrCreateMember({ - id: winnings[j][0], - guildID: message.guild.id - }); - - const toAdd = Math.floor(winnings[j][1]) - Object.values(thisGame.bets)[j].amount; - - const info = { - user: message.translate("economy/transactions:HORSERACE"), - amount: toAdd, - date: Date.now(), - type: "got" - }; - - memberData.transactions.push(info); - memberData.money += toAdd; - memberData.save(); - } - - message.sendT("economy/horserace:WINNERS", { - horse: i + 1, - winners - }); - } - - delete games[message.channel.id]; - return; - } - } - } - } - } - } -} - -module.exports = Horserace; \ No newline at end of file diff --git a/!TO REWRITE/Economy/importmee6.js b/!TO REWRITE/Economy/importmee6.js deleted file mode 100644 index c76f0352..00000000 --- a/!TO REWRITE/Economy/importmee6.js +++ /dev/null @@ -1,29 +0,0 @@ -const { getUserXp } = require("mee6-levels-api"); -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -class ImportMee6 extends Command { - constructor(client) { - super(client, { - name: "money", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: [], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - await getUserXp(message.guild.id, message.author.id).then(user => { - Levels.setLevel(message.author.id, message.guild.id, user.level); - message.lineReply(`Ваш уровень Mee6 синхронизирован! Новый уровень - ${user.level}`); - }); - } -}; - -module.exports = ImportMee6; \ No newline at end of file diff --git a/!TO REWRITE/Economy/leaderboard.js b/!TO REWRITE/Economy/leaderboard.js deleted file mode 100644 index 86a4e59c..00000000 --- a/!TO REWRITE/Economy/leaderboard.js +++ /dev/null @@ -1,168 +0,0 @@ -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -class Leaderboard extends Command { - constructor(client) { - super(client, { - name: "leaderboard", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["lb"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - const isOnMobile = (message.member.presence.clientStatus ? JSON.stringify(Object.keys(message.member.presence.clientStatus)) === JSON.stringify(["mobile"]) : false); - - const type = args[0]; - if (!type || !["credits", "level", "rep"].includes(type)) return message.error("economy/leaderboard:MISSING_TYPE"); - - if (type === "credits") { - const members = await this.client.membersData.find({ - guildID: message.guild.id - }).lean(), - membersLeaderboard = members.map((m) => { - return { - id: m.id, - money: m.money + m.bankSold - }; - }).sort((a, b) => b.money - a.money); - if (membersLeaderboard.length > 20) membersLeaderboard.length = 20; - - let userNames = ""; - let money = ""; - for (let i = 0; i < membersLeaderboard.length; i++) { - const data = membersLeaderboard[i]; - const user = (await this.client.users.fetch(data.id)).tag; - - userNames += `**${i + 1}**. ${user}\n`; - money += `${data.money}\n`; - } - - const embed = new Discord.EmbedBuilder() - .setAuthor({ - name: message.translate("economy/leaderboard:TABLE", { - name: message.guild.name - }), - iconURL: message.guild.iconURL() - }) - .setColor(data.config.embed.color) - .addFields({ - name: message.translate("economy/leaderboard:TOP"), - value: userNames, - inline: true - }, { - name: message.translate("common:CREDITS"), - value: money, - inline: true - }); - - message.reply({ - embeds: [embed] - }); - } else if (type === "level") { - const members = await this.client.membersData.find({ - guildID: message.guild.id - }).lean(), - membersLeaderboard = members.map((m) => { - return { - id: m.id, - level: m.level, - xp: m.exp - }; - }).sort((a, b) => b.level - a.level); - if (membersLeaderboard.length > 20) membersLeaderboard.length = 20; - - let userNames = ""; - let level = ""; - let xp = ""; - for (let i = 0; i < membersLeaderboard.length; i++) { - const data = membersLeaderboard[i]; - const user = (await this.client.users.fetch(data.id)).tag; - - userNames += `**${i + 1}**. ${user}\n`; - level += `${data.level}\n`; - xp += `${data.xp} / ${5 * (data.level * data.level) + 80 * data.level + 100}\n`; - } - - const embed = new Discord.EmbedBuilder() - .setAuthor({ - name: message.translate("economy/leaderboard:TABLE", { - name: message.guild.name - }), - iconURL: message.guild.iconURL() - }) - .setColor(data.config.embed.color) - .addFields({ - name: message.translate("economy/leaderboard:TOP"), - value: userNames, - inline: true - }, { - name: message.translate("common:LEVEL"), - value: level, - inline: true - }, { - name: message.translate("common:XP"), - value: xp, - inline: true - }); - - message.reply({ - embeds: [embed] - }); - } else if (type === "rep") { - const users = await this.client.usersData.find({ - rep: { $gt: 0 } - }).lean(), - usersLeaderboard = users.map((u) => { - return { - id: u.id, - rep: u.rep - }; - }).sort((a, b) => b.rep - a.rep); - if (usersLeaderboard.length > 20) usersLeaderboard.length = 20; - - let userNames = ""; - let rep = ""; - for (let i = 0; i < usersLeaderboard.length; i++) { - const data = usersLeaderboard[i]; - const user = (await this.client.users.fetch(data.id)).tag; - - userNames += `**${i + 1}**. ${user}\n`; - rep += `${data.rep}\n`; - } - - const embed = new Discord.EmbedBuilder() - .setAuthor({ - name: message.translate("economy/leaderboard:TABLE", { - name: message.guild.name - }), - iconURL: message.guild.iconURL() - }) - .setColor(data.config.embed.color) - .addFields({ - name: message.translate("economy/leaderboard:TOP"), - value: userNames, - inline: true - }, { - name: message.translate("common:REP"), - value: rep, - inline: true - }); - - message.reply({ - embeds: [embed] - }); - } - - if (isOnMobile) message.sendT("economy/leaderboard:MOBILE"); - } -} - -module.exports = Leaderboard; \ No newline at end of file diff --git a/!TO REWRITE/Economy/marry.js b/!TO REWRITE/Economy/marry.js deleted file mode 100644 index 7b9bf1bd..00000000 --- a/!TO REWRITE/Economy/marry.js +++ /dev/null @@ -1,134 +0,0 @@ -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -const pendings = {}; - -class Marry extends Command { - constructor(client) { - super(client, { - name: "marry", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: [], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - if (data.userData.lover) return message.error("economy/marry:ALREADY_MARRIED", { prefix: data.guildData.prefix }); - - const member = await this.client.resolveMember(args[0], message.guild); - if (!member) return message.error("economy/marry:INVALID_MEMBER"); - - const userData = await this.client.findOrCreateUser({ - id: member.id - }); - - if (userData.lover) return message.error("economy/marry:ALREADY_MARRIED_USER", { username: member.user.tag }); - if (member.user.bot) return message.error("economy/marry:BOT_USER"); - if (member.id === message.author.id) return message.error("economy/marry:YOURSELF"); - - for (const requester in pendings) { - const receiver = pendings[requester]; - // If the member already sent a request to someone - if (requester === message.author.id) { - const user = this.client.users.cache.get(receiver) || await this.client.users.fetch(receiver); - return message.error("economy/marry:REQUEST_AUTHOR_TO_AMEMBER", { - username: user.tag - }); - } else if (receiver === message.author.id) { // If there is a pending request for this member - const user = this.client.users.cache.get(requester) || await this.client.users.fetch(requester); - return message.error("economy/marry:REQUEST_AMEMBER_TO_AUTHOR", { - username: user.tag - }); - } else if (requester === member.id) { // If the asked member has sent pending request - const user = this.client.users.cache.get(receiver) || await this.client.users.fetch(receiver); - return message.error("economy/marry:REQUEST_AMEMBER_TO_MEMBER", { - firstUsername: member.user.tag, - secondUsername: user.tag - }); - } else if (receiver === member.id) { // If there is a pending request for the asked member - const user = this.client.users.cache.get(requester) || await this.client.users.fetch(requester); - return message.error("economy/marry:REQUEST_MEMBER_TO_AMEMBER", { - firstUsername: member.user.tag, - secondUsername: user.tag - }); - } - } - - // Update pending requests - pendings[message.author.id] = member.id; - - message.sendT("economy/marry:REQUEST", { - from: message.author.toString(), - to: member.user.toString() - }); - - const filter = m => m.author.id === member.id; - const collector = new Discord.MessageCollector(message.channel, { - filter, - time: 120000 - }); - - collector.on("collect", (msg) => { - if (msg.content.toLowerCase() === message.translate("common:YES").toLowerCase()) { - return collector.stop(true); - } else if (msg.content.toLowerCase() === message.translate("common:NO").toLowerCase()) { - return collector.stop(false); - } else { - return message.error("misc:INVALID_YES_NO"); - } - }); - - collector.on("end", async (_collected, reason) => { - // Delete pending request - delete pendings[message.author.id]; - if (reason === "time") return message.error("economy/marry:TIMEOUT", { username: member.user.toString() }); - if (reason) { - data.userData.lover = member.id; - await data.userData.save(); - userData.lover = message.author.id; - await userData.save(); - const messageOptions = { - content: `${member.toString()} :heart: ${message.author.toString()}`, - files: [{ - name: "achievement_unlocked3.png", - attachment: "./assets/img/achievements/achievement_unlocked3.png" - }] - }; - let sent = false; - if (!userData.achievements.married.achieved) { - message.channel.send(messageOptions); - sent = true; - userData.achievements.married.achieved = true; - userData.achievements.married.progress.now = 1; - userData.markModified("achievements.married"); - userData.save(); - } - if (!data.userData.achievements.married.achieved) { - if (!sent) message.channel.send(messageOptions); - data.userData.achievements.married.achieved = true; - data.userData.achievements.married.progress.now = 1; - data.userData.markModified("achievements.married"); - data.userData.save(); - } - return message.success("economy/marry:SUCCESS", { - creator: message.author.toString(), - partner: member.user.toString() - }); - } else { - return message.success("economy/marry:DENIED", { - creator: message.author.toString(), - partner: member.user.toString() - }); - } - }); - } -} - -module.exports = Marry; \ No newline at end of file diff --git a/!TO REWRITE/Economy/money.js b/!TO REWRITE/Economy/money.js deleted file mode 100644 index 0b425da9..00000000 --- a/!TO REWRITE/Economy/money.js +++ /dev/null @@ -1,88 +0,0 @@ -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -const asyncForEach = async (collection, callback) => { - const allPromises = collection.map(async key => { - await callback(key); - }); - - return await Promise.all(allPromises); -}; - -class Money extends Command { - constructor(client) { - super(client, { - name: "money", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["balance", "mon"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - let member = await this.client.resolveMember(args[0], message.guild); - if (!member) member = message.member; - const user = member.user; - - if (user.bot) return message.error("misc:BOT_USER"); - - const memberData = (message.author === user) ? data.memberData : await this.client.findOrCreateMember({ - id: user.id, - guildID: message.guild.id - }); - - const commonsGuilds = this.client.guilds.cache.filter((g) => g.members.cache.get(user.id)); - let globalMoney = 0; - await asyncForEach(commonsGuilds, async (guild) => { - const data = await this.client.findOrCreateMember({ - id: user.id, - guildID: guild.id - }); - globalMoney += data.money; - globalMoney += data.bankSold; - }); - - const embed = new Discord.EmbedBuilder() - .setAuthor({ - name: message.translate("economy/money:TITLE", { - username: member.user.username - }), - iconURL: member.user.displayAvatarURL({ - extension: "png", - size: 512 - }) - }) - .addFields([ - { - name: message.translate("economy/profile:CASH"), - value: `**${memberData.money}** ${message.getNoun(memberData.money, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - inline: true - }, - { - name: message.translate("economy/profile:BANK"), - value: `**${memberData.bankSold}** ${message.getNoun(memberData.bankSold, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - inline: true - }, - { - name: message.translate("economy/profile:GLOBAL"), - value: `**${globalMoney}** ${message.getNoun(globalMoney, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - inline: true - } - ]) - .setColor(data.config.embed.color) - .setFooter({ - text: data.config.embed.footer - }); - message.reply({ - embeds: [embed] - }); - } -} - -module.exports = Money; \ No newline at end of file diff --git a/!TO REWRITE/Economy/number.js b/!TO REWRITE/Economy/number.js deleted file mode 100644 index 4a22f0c8..00000000 --- a/!TO REWRITE/Economy/number.js +++ /dev/null @@ -1,97 +0,0 @@ -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -const currentGames = {}; - -class Number extends Command { - constructor(client) { - super(client, { - name: "number", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["num"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - if (currentGames[message.guild.id]) return message.error("economy/number:GAME_RUNNING"); - - const participants = [], - number = this.client.functions.randomNum(1000, 6000); - - await message.sendT("economy/number:GAME_START"); - - // Store the date wich the game has started - const gameCreatedAt = Date.now(); - - const filter = m => !m.author.bot; - const collector = new Discord.MessageCollector(message.channel, { - filter, - time: 480000 // 8 minutes - }); - currentGames[message.guild.id] = true; - - collector.on("collect", async msg => { - if (!participants.includes(msg.author.id)) participants.push(msg.author.id); - if (msg.content === "STOP") return collector.stop("force"); - if (isNaN(msg.content)) return; - - const parsedNumber = parseInt(msg.content, 10); - - if (parsedNumber === number) { - const time = this.client.convertTime(message.guild, Date.now() - gameCreatedAt); - message.sendT("economy/number:GAME_STATS", { - winner: msg.author.toString(), - number, - time, - participantCount: participants.length, - participants: participants.map(p => `<@${p}>`).join(", ") - }); - - if (participants.length > 1 && data.guildData.disabledCategories && !data.guildData.disabledCategories.includes("Economy")) { - const won = 100 * (participants.length * 0.5); - - message.sendT("economy/number:WON", { - winner: msg.author.username, - credits: `**${won}** ${message.getNoun(won, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` - }); - - const memberData = await this.client.findOrCreateMember({ - id: msg.author.id, - guildID: message.guild.id - }); - - const info = { - user: message.translate("economy/transactions:NUMBERS"), - amount: won, - date: Date.now(), - type: "got" - }; - - data.memberData.transactions.push(info); - - memberData.money += won; - memberData.save(); - } - - collector.stop(); - } - if (parseInt(msg.content) < number) message.error("economy/number:BIG", { user: msg.author.toString(), number: parsedNumber }); - if (parseInt(msg.content) > number) message.error("economy/number:SMALL", { user: msg.author.toString(), number: parsedNumber }); - }); - - collector.on("end", (_collected, reason) => { - delete currentGames[message.guild.id]; - if (reason === "time") return message.error("economy/number:DEFEAT", { number }); - else if (reason === "force") return message.error("misc:FORCE_STOP", { user: message.author.toString() }); - }); - } -} - -module.exports = Number; \ No newline at end of file diff --git a/!TO REWRITE/Economy/pay.js b/!TO REWRITE/Economy/pay.js deleted file mode 100644 index 0afd9c9c..00000000 --- a/!TO REWRITE/Economy/pay.js +++ /dev/null @@ -1,59 +0,0 @@ -const Command = require("../../base/Command"); - -class Pay extends Command { - constructor(client) { - super(client, { - name: "pay", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: [], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - const member = await this.client.resolveMember(args[0], message.guild); - if (!member) return message.error("economy/pay:INVALID_MEMBER"); - if (member.user.bot) return message.error("economy/pay:BOT_USER"); - if (member.id === message.author.id) return message.error("economy/pay:YOURSELF"); - - const sentAmount = args[1]; - if (!sentAmount || isNaN(sentAmount) || parseInt(sentAmount, 10) <= 0) return message.error("economy/pay:INVALID_AMOUNT"); - - const amount = Math.ceil(parseInt(sentAmount, 10)); - if (amount > data.memberData.money) return message.error("economy/pay:ENOUGH_MONEY", { - amount: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDITS:1"), message.translate("misc:NOUNS:CREDITS:2"), message.translate("misc:NOUNS:CREDITS:5"))}` - }); - - const memberData = await this.client.findOrCreateMember({ - id: member.id, - guildID: message.guild.id - }); - - const info = { - user: member.user.tag, - amount: parseInt(amount, 10), - date: Date.now(), - type: "send" - }; - - data.memberData.transactions.push(info); - data.memberData.money = data.memberData.money - parseInt(amount, 10); - data.memberData.save(); - - memberData.money = memberData.money + parseInt(amount, 10); - memberData.save(); - - message.success("economy/pay:SUCCESS", { - amount: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - username: member.user.tag - }); - } -} - -module.exports = Pay; \ No newline at end of file diff --git a/!TO REWRITE/Economy/profile.js b/!TO REWRITE/Economy/profile.js deleted file mode 100644 index 7cf3b353..00000000 --- a/!TO REWRITE/Economy/profile.js +++ /dev/null @@ -1,144 +0,0 @@ -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -const asyncForEach = async (collection, callback) => { - const allPromises = collection.map(async key => { - await callback(key); - }); - - return await Promise.all(allPromises); -}; - -class Profile extends Command { - constructor(client) { - super(client, { - name: "profile", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["prof"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const arg = args[0] || message.author; - let member = await this.client.resolveMember(arg, message.guild); - if (!member) member = message.member; - if (member.user.bot) return message.error("economy/profile:BOT_USER"); - - const memberData = (member.id === message.author.id ? data.memberData : await this.client.findOrCreateMember({ - id: member.id, - guildID: message.guild.id - })); - const userData = (member.id === message.author.id ? data.userData : await this.client.findOrCreateUser({ - id: member.id - })); - if (userData.lover && !this.client.users.cache.get(userData.lover)) await this.client.users.fetch(userData.lover, true); - - const commonsGuilds = this.client.guilds.cache.filter((g) => g.members.cache.get(member.id)); - let globalMoney = 0; - await asyncForEach(commonsGuilds, async (guild) => { - const data = await this.client.findOrCreateMember({ - id: member.id, - guildID: guild.id - }); - globalMoney += data.money; - globalMoney += data.bankSold; - }); - - const profileEmbed = new Discord.EmbedBuilder() - .setAuthor({ - name: message.translate("economy/profile:TITLE", { - username: member.user.tag - }), - iconURL: member.user.displayAvatarURL({ - extension: "png", - size: 512 - }) - }) - .setImage("attachment://achievements.png") - .addFields([ - { - name: this.client.customEmojis.link + " " + message.translate("economy/profile:LINK"), - value: `[${message.translate("economy/profile:LINK_TEXT")}](${this.client.config.dashboard.baseURL}/user/${member.user.id}/${message.guild.id})` - }, - { - name: message.translate("economy/profile:BIO"), - value: userData.bio ? userData.bio : message.translate("economy/profile:NO_BIO") - }, - { - name: message.translate("economy/profile:CASH"), - value: `**${memberData.money}** ${message.getNoun(memberData.money, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - inline: true - }, - { - name: message.translate("economy/profile:BANK"), - value: `**${memberData.bankSold}** ${message.getNoun(memberData.bankSold, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - inline: true - }, - { - name: message.translate("economy/profile:GLOBAL"), - value: `**${globalMoney}** ${message.getNoun(globalMoney, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - inline: true - }, - { - name: message.translate("economy/profile:REPUTATION"), - value: `**${userData.rep}** ${message.getNoun(userData.rep, message.translate("misc:NOUNS:POINTS:1"), message.translate("misc:NOUNS:POINTS:2"), message.translate("misc:NOUNS:POINTS:5"))}`, - inline: true - }, - { - name: message.translate("economy/profile:LEVEL"), - value:`**${memberData.level}**`, - inline: true - }, - { - name: message.translate("economy/profile:EXP"), - value: `**${memberData.exp}/${5 * (memberData.level * memberData.level) + 80 * memberData.level + 100}** xp`, - inline: true - }, - { - name: message.translate("economy/profile:REGISTERED"), - value: this.client.printDate(new Date(memberData.registeredAt)), - inline: true - }, - { - name: message.translate("economy/profile:BIRTHDATE"), - value: (!userData.birthdate ? message.translate("economy/profile:NO_BIRTHDATE") : this.client.printDate(new Date(userData.birthdate))), - inline: true - }, - { - name: message.translate("economy/profile:LOVER"), - value: (!userData.lover ? message.translate("economy/profile:NO_LOVER") : this.client.users.cache.get(userData.lover).tag), - inline: true - }, - { - name: message.translate("economy/profile:ACHIEVEMENTS"), - value: message.translate("economy/profile:ACHIEVEMENTS_CONTENT", { - prefix: data.guildData.prefix - }) - } - ]) - .setColor(data.config.embed.color) // Sets the color of the embed - .setFooter({ - text: data.config.embed.footer - }) // Sets the footer of the embed - .setTimestamp(); - - const buffer = await userData.getAchievements(); - - message.reply({ - embeds: [profileEmbed], - files: [{ - name: "achievements.png", - attachment: buffer - }] - }); - } -} - -module.exports = Profile; \ No newline at end of file diff --git a/!TO REWRITE/Economy/rep.js b/!TO REWRITE/Economy/rep.js deleted file mode 100644 index dc4ba37f..00000000 --- a/!TO REWRITE/Economy/rep.js +++ /dev/null @@ -1,71 +0,0 @@ -const Command = require("../../base/Command"); - -class Rep extends Command { - constructor(client) { - super(client, { - name: "rep", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["reputation"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - // if the member is already in the cooldown db - const isInCooldown = (data.userData.cooldowns || { - rep: 0 - }).rep; - if (isInCooldown) { - /*if the timestamp recorded in the database indicating - when the member will be able to execute the order again - is greater than the current date, display an error message */ - if (isInCooldown > Date.now()) return message.error("economy/rep:COOLDOWN", { - time: this.client.convertTime(isInCooldown, "to", true) - }); - } - - const user = await this.client.resolveUser(args[0]); - if (!user) return message.error("economy/rep:INVALID_USER"); - if (user.bot) return message.error("economy/rep:BOT_USER"); - if (user.id === message.author.id) return message.error("economy/rep:YOURSELF"); - - // Records in the database the time when the member will be able to execute the command again (in 12 hours) - const toWait = Date.now() + 21600000; - data.userData.cooldowns = {}; - data.userData.cooldowns.rep = toWait; - data.userData.markModified("cooldowns"); - data.userData.save(); - - const userData = await this.client.findOrCreateUser({ - id: user.id - }); - userData.rep++; - if (!userData.achievements.rep.achieved) { - userData.achievements.rep.progress.now = (userData.rep > userData.achievements.rep.progress.total ? userData.achievements.rep.progress.total : userData.rep); - if (userData.achievements.rep.progress.now >= userData.achievements.rep.progress.total) { - userData.achievements.rep.achieved = true; - message.channel.send({ - content: `${user}`, - files: [{ - name: "achievement_unlocked6.png", - attachment: "./assets/img/achievements/achievement_unlocked6.png" - }] - }); - } - userData.markModified("achievements.rep"); - } - await userData.save(); - - message.success("economy/rep:SUCCESS", { - username: user.username - }); - } -} - -module.exports = Rep; \ No newline at end of file diff --git a/!TO REWRITE/Economy/rob.js b/!TO REWRITE/Economy/rob.js deleted file mode 100644 index ea682ba1..00000000 --- a/!TO REWRITE/Economy/rob.js +++ /dev/null @@ -1,78 +0,0 @@ -const Command = require("../../base/Command"); - -class Rob extends Command { - constructor(client) { - super(client, { - name: "rob", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["steal"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - const member = await this.client.resolveMember(args[0], message.guild); - if (!member) return message.error("economy/rob:MISSING_MEMBER"); - if (member.id === message.author.id) return message.error("economy/rob:YOURSELF"); - - const memberData = await this.client.findOrCreateMember({ - id: member.id, - guildID: message.guild.id - }); - const isInCooldown = memberData.cooldowns.rob || 0; - if (isInCooldown) { - if (isInCooldown > Date.now()) return message.error("economy/rob:COOLDOWN", { user: member.user }); - } - - let amountToRob = args[1]; - if (!amountToRob || isNaN(amountToRob) || parseInt(amountToRob, 10) <= 0) return message.error("economy/rob:MISSING_AMOUNT", { user: member.user }); - - amountToRob = Math.floor(parseInt(amountToRob, 10)); - - if (amountToRob > memberData.money) return message.error("economy/rob:NOT_ENOUGH_MEMBER", { user: member.user }); - - const potentiallyLose = Math.floor(amountToRob * 1.5); - if (potentiallyLose > data.memberData.money) return message.error("economy/rob:NOT_ENOUGH_AUTHOR", { - moneyMin: `${potentiallyLose} ${message.getNoun(potentiallyLose, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - moneyCurrent: `${data.memberData.money} ${message.getNoun(data.memberData.money, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` - }); - - const itsAWon = Math.floor(this.client.functions.randomNum(0, 100) < 25); - - if (itsAWon) { - const toWait = Date.now() + 6 * (60 * 60000); // 6 hours - memberData.cooldowns.rob = toWait; - memberData.markModified("cooldowns"); - await memberData.save(); - const randomNum = this.client.functions.randomNum(1, 2); - message.sendT("economy/rob:ROB_WON_" + randomNum, { - money: `${amountToRob} ${message.getNoun(amountToRob, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - user: member.user - }); - data.memberData.money += amountToRob; - memberData.money -= amountToRob, 10; - memberData.save(); - data.memberData.save(); - } else { - const won = Math.floor(0.9 * amountToRob); - const randomNum = this.client.functions.randomNum(1, 2); - message.sendT("economy/rob:ROB_LOSE_" + randomNum, { - fine: `${potentiallyLose} ${message.getNoun(potentiallyLose, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - offset: `${won} ${message.getNoun(won, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - user: member.user - }); - data.memberData.money -= potentiallyLose; - memberData.money += won; - memberData.save(); - data.memberData.save(); - } - } -} - -module.exports = Rob; \ No newline at end of file diff --git a/!TO REWRITE/Economy/setbio.js b/!TO REWRITE/Economy/setbio.js deleted file mode 100644 index d3e8998e..00000000 --- a/!TO REWRITE/Economy/setbio.js +++ /dev/null @@ -1,30 +0,0 @@ -const Command = require("../../base/Command"); - -class Setbio extends Command { - constructor(client) { - super(client, { - name: "setbio", - dirname: __dirname, - enabled: true, - guildOnly: false, - aliases: ["biography", "setdesc", "sb"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const newBio = args.join(" "); - if (!newBio) return message.error("economy/setbio:MISSING"); - if (newBio.length > 100) return message.error("economy/setbio:MAX_CHARACT"); - - data.userData.bio = newBio; - message.success("economy/setbio:SUCCESS"); - await data.userData.save(); - } -} - -module.exports = Setbio; \ No newline at end of file diff --git a/!TO REWRITE/Economy/tictactoe.js b/!TO REWRITE/Economy/tictactoe.js deleted file mode 100644 index e011cdd9..00000000 --- a/!TO REWRITE/Economy/tictactoe.js +++ /dev/null @@ -1,46 +0,0 @@ -const Command = require("../../base/Command"), - tictactoe = require("../../helpers/tictactoe"); - -class TicTacToe extends Command { - constructor(client) { - super(client, { - name: "tictactoe", - dirname: __dirname, - enabled: true, - guildOnly: false, - aliases: ["ttt"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - tictactoe(message, { - resultBtn: true, - embedColor: data.config.embed.color, - embedFoot: data.config.embed.footer - }).then(async winner => { - const memberData = await this.client.findOrCreateMember({ - id: winner.id, - guildID: message.guild.id - }); - - const info = { - user: message.translate("economy/transactions:TTT"), - amount: 100, - date: Date.now(), - type: "got" - }; - - memberData.transactions.push(info); - - memberData.money += 100; - memberData.save(); - }); - } -} - -module.exports = TicTacToe; \ No newline at end of file diff --git a/!TO REWRITE/Economy/transactions.js b/!TO REWRITE/Economy/transactions.js deleted file mode 100644 index 6f82685c..00000000 --- a/!TO REWRITE/Economy/transactions.js +++ /dev/null @@ -1,67 +0,0 @@ -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -class Transactions extends Command { - constructor(client) { - super(client, { - name: "transactions", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["tr"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - const embed = new Discord.EmbedBuilder() - .setAuthor({ - name: message.translate("economy/transactions:EMBED_TRANSACTIONS"), - iconURL: message.author.displayAvatarURL({ - extension: "png", - size: 512 - }) - }) - .setColor(data.config.embed.color) - .setFooter({ - text: data.config.embed.footer - }); - - const transactions = data.memberData.transactions, - sortedTransactions = [ [], [] ]; - - transactions.slice(-20).forEach((t) => { - const array = t.type === "got" ? sortedTransactions[0] : sortedTransactions[1]; - array.push(`${message.translate("economy/transactions:T_USER_" + t.type.toUpperCase())}: ${t.user}\n${message.translate("economy/transactions:T_AMOUNT")}: ${t.amount}\n${message.translate("economy/transactions:T_DATE")}: ${this.client.printDate(t.date, "Do MMMM YYYY, HH:mm")}\n`); - }); - - if (transactions.length < 1) { - embed.setDescription(message.translate("economy/transactions:NO_TRANSACTIONS")); - } else { - if (sortedTransactions[0].length > 0) embed.addFields([ - { - name: message.translate("economy/transactions:T_GOT"), - value: sortedTransactions[0].join("\n"), - inline: true - } - ]); - if (sortedTransactions[1].length > 0) embed.addFields([ - { - name: message.translate("economy/transactions:T_SEND"), - value: sortedTransactions[1].join("\n"), - inline: true - } - ]); - } - - message.reply({ - embeds: [embed] - }); - } -} - -module.exports = Transactions; \ No newline at end of file diff --git a/!TO REWRITE/Economy/withdraw.js b/!TO REWRITE/Economy/withdraw.js deleted file mode 100644 index f19dc6ad..00000000 --- a/!TO REWRITE/Economy/withdraw.js +++ /dev/null @@ -1,52 +0,0 @@ -const Command = require("../../base/Command"); - -class Withdraw extends Command { - constructor(client) { - super(client, { - name: "withdraw", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["wd"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - let amount = args[0]; - - if (!(parseInt(data.memberData.bankSold, 10) > 0)) return message.error("economy/withdraw:NO_CREDIT"); - - if (args[0] === "all") { - amount = parseInt(data.memberData.bankSold, 10); - } else { - if (isNaN(amount) || parseInt(amount, 10) < 1) return message.error("economy/withdraw:MISSING_AMOUNT"); - amount = parseInt(amount, 10); - } - - if (data.memberData.bankSold < amount) return message.error("economy/withdraw:NOT_ENOUGH", { money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` }); - - const info = { - user: message.translate("economy/transactions:BANK"), - amount: amount, - date: Date.now(), - type: "got" - }; - - data.memberData.transactions.push(info); - - data.memberData.money = data.memberData.money + amount; - data.memberData.bankSold = data.memberData.bankSold - amount; - data.memberData.save(); - - message.success("economy/withdraw:SUCCESS", { - money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` - }); - } -} - -module.exports = Withdraw; \ No newline at end of file diff --git a/!TO REWRITE/Economy/work.js b/!TO REWRITE/Economy/work.js deleted file mode 100644 index 283cbbc1..00000000 --- a/!TO REWRITE/Economy/work.js +++ /dev/null @@ -1,129 +0,0 @@ -const Command = require("../../base/Command"), - { parseEmoji, EmbedBuilder } = require("discord.js"); - -class Work extends Command { - constructor(client) { - super(client, { - name: "work", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["salary", "daily"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - // if the member is already in the cooldown db - const isInCooldown = data.memberData.cooldowns.work; - if (isInCooldown) { - /*if the timestamp recorded in the database indicating - when the member will be able to execute the order again - is greater than the current date, display an error message */ - if (isInCooldown > Date.now()) return message.error("economy/work:COOLDOWN", { - time: this.client.convertTime(isInCooldown, "to", true) - }); - } - - if (Date.now() > data.memberData.cooldowns.work + (24 * 3600000)) data.memberData.workStreak = 0; - - // Records in the database the time when the member will be able to execute the command again (in 12 hours) - const toWait = Date.now() + 43200000; - data.memberData.cooldowns.work = toWait; - data.memberData.markModified("cooldowns"); - - data.memberData.workStreak = (data.memberData.workStreak || 0) + 1; - await data.memberData.save(); - - const embed = new EmbedBuilder() - .setFooter({ - text: message.translate("economy/work:AWARD"), - iconURL: message.author.displayAvatarURL({ - extension: "png", - size: 512 - }) - }) - .setColor(data.config.embed.color); - - const award = [ - this.client.customEmojis.letters.a, - this.client.customEmojis.letters.w, - this.client.customEmojis.letters.a, - this.client.customEmojis.letters.r, - this.client.customEmojis.letters.d - ]; - let won = 200; - - if (data.memberData.workStreak >= 5) { - won += 200; - embed.addFields([ - { - name: message.translate("economy/work:SALARY"), - value: message.translate("economy/work:SALARY_CONTENT", { - won: `${won} ${message.getNoun(won, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` - }) - }, - { - name: message.translate("economy/work:STREAK"), - value: message.translate("economy/work:STREAK_CONTENT") - } - ]); - data.memberData.workStreak = 0; - } else { - for (let i = 0; i < award.length; i++) { - if (data.memberData.workStreak > i) { - const letter = parseEmoji(award[i]).name.split("_")[1]; - award[i] = `:regional_indicator_${letter.toLowerCase()}:`; - } - } - embed.addFields([ - { - name: message.translate("economy/work:SALARY"), - value: message.translate("economy/work:SALARY_CONTENT", { - won: `**${won}** ${message.getNoun(won, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` - }) - }, - { - name: message.translate("economy/work:STREAK"), - value: award.join("") - } - ]); - } - - const info = { - user: message.translate("economy/work:SALARY"), - amount: won, - date: Date.now(), - type: "got" - }; - - data.memberData.transactions.push(info); - data.memberData.money = data.memberData.money + won; - data.memberData.save(); - - const messageOptions = { - embeds: [embed] - }; - if (!data.userData.achievements.work.achieved) { - data.userData.achievements.work.progress.now += 1; - if (data.userData.achievements.work.progress.now === data.userData.achievements.work.progress.total) { - messageOptions.files = [{ - name: "unlocked.png", - attachment: "./assets/img/achievements/achievement_unlocked1.png" - }]; - data.userData.achievements.work.achieved = true; - } - data.userData.markModified("achievements.work"); - data.userData.save(); - } - - // Send the embed in the current channel - message.reply(messageOptions); - } -} - -module.exports = Work; \ No newline at end of file diff --git a/TO REWRITE/leaderboard.js b/TO REWRITE/leaderboard.js new file mode 100644 index 00000000..932efaad --- /dev/null +++ b/TO REWRITE/leaderboard.js @@ -0,0 +1,195 @@ +const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Leaderboard extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("leaderboard") + .setDescription(client.translate("economy/leaderboard:DESCRIPTION")) + .addStringOption(option => option.setName("type") + .setDescription(client.translate("owner/debug:TYPE")) + .setRequired(true) + .addChoices( + { name: client.translate("economy/leaderboard:LEVEL"), value: "level" }, + { name: client.translate("economy/leaderboard:MONEY"), value: "money" }, + { name: client.translate("economy/leaderboard:REP"), value: "rep" } + )), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction) { + await interaction.deferReply(); + const type = interaction.options.getString("type"); + const isOnMobile = JSON.stringify(Object.keys(interaction.member.presence.clientStatus)) === JSON.stringify(["mobile"]); + if (isOnMobile) interaction.followUp({ + content: interaction.translate("economy/leaderboard:MOBILE"), + ephemeral: true + }); + + if (type === "money") { + const members = await client.membersData.find({ + guildID: interaction.guildId + }).lean(), + membersLeaderboard = members.map(m => { + return { + id: m.id, + money: m.money + m.bankSold + }; + }).sort((a, b) => b.money - a.money); + if (membersLeaderboard.length > 20) membersLeaderboard.length = 20; + + let userNames = ""; + let money = ""; + for (let i = 0; i < membersLeaderboard.length; i++) { + const data = membersLeaderboard[i]; + const user = await client.users.fetch(data.id); + + userNames += `**${i + 1}**. ${user}\n`; + money += `${data.money}\n`; + } + + const embed = new EmbedBuilder() + .setAuthor({ + name: interaction.translate("economy/leaderboard:TABLE", { + name: interaction.guild.name + }), + iconURL: interaction.guild.iconURL() + }) + .setColor(client.config.embed.color) + .addFields({ + name: interaction.translate("economy/leaderboard:TOP"), + value: userNames, + inline: true + }, { + name: interaction.translate("common:CREDITS"), + value: money, + inline: true + }); + + interaction.editReply({ + embeds: [embed] + }); + } else if (type === "level") { + const membersLeaderboard = []; + client.membersData.find({ + guildID: interaction.guildId + }).lean().then(async m => { + await membersLeaderboard.push({ + id: m.id, + level: m.level, + xp: m.exp + }); + }); + membersLeaderboard.sort((a, b) => b.level - a.level); + if (membersLeaderboard.length > 20) membersLeaderboard.length = 20; + + const userNames = []; + const level = []; + const xp = []; + for (let i = 0; i < membersLeaderboard.length; i++) { + const data = membersLeaderboard[i]; + const user = await client.users.fetch(data.id); + + userNames.push(`**${i + 1}**. ${user.tag}`); + level.push(`${data.level}`); + xp.push(`${data.xp} / ${5 * (data.level * data.level) + 80 * data.level + 100}`); + } + + const embed = new EmbedBuilder() + .setAuthor({ + name: interaction.translate("economy/leaderboard:TABLE", { + name: interaction.guild.name + }), + iconURL: interaction.guild.iconURL() + }) + .setColor(client.config.embed.color) + .addFields([ + { + name: interaction.translate("economy/leaderboard:TOP"), + value: userNames.join("\n"), + inline: true + }, + { + name: interaction.translate("common:LEVEL"), + value: level.join("\n"), + inline: true + }, + { + name: interaction.translate("common:XP"), + value: xp.join("\n"), + inline: true + } + ]); + + interaction.editReply({ + embeds: [embed] + }); + } else if (type === "rep") { + const users = await client.usersData.find({ + rep: { $gt: 0 } + }).lean(), + usersLeaderboard = users.map(u => { + return { + id: u.id, + rep: u.rep + }; + }).sort((a, b) => b.rep - a.rep); + if (usersLeaderboard.length > 20) usersLeaderboard.length = 20; + + let userNames = ""; + let rep = ""; + for (let i = 0; i < usersLeaderboard.length; i++) { + const data = usersLeaderboard[i]; + const user = await client.users.fetch(data.id); + + userNames += `**${i + 1}**. ${user}\n`; + rep += `${data.rep}\n`; + } + + const embed = new EmbedBuilder() + .setAuthor({ + name: interaction.translate("economy/leaderboard:TABLE", { + name: interaction.guild.name + }), + iconURL: interaction.guild.iconURL() + }) + .setColor(client.config.embed.color) + .addFields({ + name: interaction.translate("economy/leaderboard:TOP"), + value: userNames, + inline: true + }, { + name: interaction.translate("common:REP"), + value: rep, + inline: true + }); + + interaction.editReply({ + embeds: [embed] + }); + } + } +} + +module.exports = Leaderboard; \ No newline at end of file diff --git a/!TO REWRITE/seek.js b/TO REWRITE/seek.js similarity index 98% rename from !TO REWRITE/seek.js rename to TO REWRITE/seek.js index 06e8d390..30289020 100644 --- a/!TO REWRITE/seek.js +++ b/TO REWRITE/seek.js @@ -31,7 +31,7 @@ class Seek extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Administration/automod.js b/commands/Administration/automod.js index a6cea8c3..f65afbf6 100644 --- a/commands/Administration/automod.js +++ b/commands/Administration/automod.js @@ -34,7 +34,7 @@ class Automod extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const state = interaction.options.getBoolean("state"); diff --git a/commands/Administration/autorole.js b/commands/Administration/autorole.js index 4c01ce0c..24b91fdc 100644 --- a/commands/Administration/autorole.js +++ b/commands/Administration/autorole.js @@ -33,13 +33,13 @@ class Autorole extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const state = interaction.options.getBoolean("state"); if (state) { - const role = interaction.options.getRole("role", true); + const role = interaction.options.getRole("role"); if (!role) return interaction.error("administration/autorole:MISSING_ROLE"); data.guildData.plugins.autorole = { @@ -50,13 +50,9 @@ class Autorole extends BaseCommand { await data.guildData.save(); interaction.success("administration/autorole:SUCCESS_ENABLED", { - roleName: role.name + roleName: role.toString() }); } else { - if (!data.guildData.plugins.autorole.enabled) return interaction.success("administration/autorole:ALREADY_DISABLED", { - prefix: data.guildData.prefix - }); - data.guildData.plugins.autorole = { enabled: false, role: null @@ -64,9 +60,7 @@ class Autorole extends BaseCommand { data.guildData.markModified("plugins.autorole"); await data.guildData.save(); - interaction.success("administration/autorole:SUCCESS_DISABLED", { - prefix: data.guildData.prefix - }); + interaction.success("administration/autorole:SUCCESS_DISABLED"); } } } diff --git a/commands/Administration/config.js b/commands/Administration/config.js index 6db447c1..f9d4e03d 100644 --- a/commands/Administration/config.js +++ b/commands/Administration/config.js @@ -28,7 +28,7 @@ class Config extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const guildData = data.guildData; @@ -75,7 +75,7 @@ class Config extends BaseCommand { { name: interaction.translate("administration/config:AUTOMOD_TITLE"), value: guildData.plugins.automod.enabled ? interaction.translate("administration/config:AUTOMOD_CONTENT", { - channels: guildData.plugins.automod.ignored.map(ch => `<#${ch}>`) + channels: guildData.plugins.automod.ignored.map(ch => ` ${ch}`) }) : interaction.translate("common:DISABLED") }, { diff --git a/commands/Administration/deletemod.js b/commands/Administration/deletemod.js index 3eafe0c5..e062ffc2 100644 --- a/commands/Administration/deletemod.js +++ b/commands/Administration/deletemod.js @@ -31,7 +31,7 @@ class Deletemod extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const state = interaction.options.getBoolean("state"); diff --git a/commands/Administration/goodbye.js b/commands/Administration/goodbye.js index fc020145..7c110f6a 100644 --- a/commands/Administration/goodbye.js +++ b/commands/Administration/goodbye.js @@ -43,7 +43,7 @@ class Goodbye extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const command = interaction.options.getSubcommand(); diff --git a/commands/Administration/set.js b/commands/Administration/set.js index ee7f8637..6b60cd6b 100644 --- a/commands/Administration/set.js +++ b/commands/Administration/set.js @@ -19,8 +19,7 @@ class Set extends BaseCommand { { name: client.translate("common:LEVEL"), value: "level" }, { name: client.translate("common:XP"), value: "xp" }, { name: client.translate("common:CREDITS"), value: "credits" }, - { name: client.translate("economy/transactions:BANK"), value: "bank" }, - { name: client.translate("common:REP"), value: "rep" }, + { name: client.translate("economy/transactions:BANK"), value: "bank" } )) .addUserOption(option => option.setName("user") .setDescription(client.translate("common:USER")) @@ -45,56 +44,50 @@ class Set extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ - async execute(client, interaction, data) { + async execute(client, interaction) { const type = interaction.options.getString("type"); const member = interaction.options.getMember("user"); if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); + const memberData = await client.findOrCreateMember({ + id: member.id + }); const int = interaction.options.getInteger("int"); if (int < 0) return interaction.error("administration/set:INVALID_NUMBER", null, { ephemeral: true }); switch (type) { case "level": { - data.memberData.level = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.level = int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "xp": { - data.memberData.exp = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.exp = int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "credits": { - data.memberData.money = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.money = int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "bank": { - data.memberData.bankSold = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.toString(), - amount: int - }, { ephemeral: true }); - } - - case "rep": { - data.memberData.rep = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.bankSold = int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); diff --git a/commands/Administration/setbirthdays.js b/commands/Administration/setbirthdays.js index 5b73e34b..9a6a1cfb 100644 --- a/commands/Administration/setbirthdays.js +++ b/commands/Administration/setbirthdays.js @@ -34,7 +34,7 @@ class Setbirthdays extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const state = interaction.options.getBoolean("state"); diff --git a/commands/Administration/setlang.js b/commands/Administration/setlang.js index 9386de9d..2533ff99 100644 --- a/commands/Administration/setlang.js +++ b/commands/Administration/setlang.js @@ -35,7 +35,7 @@ class Setlang extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const lang = interaction.options.getString("language"); diff --git a/commands/Administration/setmodlogs.js b/commands/Administration/setmodlogs.js index 7d4deabe..0fcc618e 100644 --- a/commands/Administration/setmodlogs.js +++ b/commands/Administration/setmodlogs.js @@ -34,7 +34,7 @@ class Setmodlogs extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const state = interaction.options.getBoolean("state"); diff --git a/commands/Administration/setnews.js b/commands/Administration/setnews.js index 9c6d4110..920f4c8d 100644 --- a/commands/Administration/setnews.js +++ b/commands/Administration/setnews.js @@ -34,7 +34,7 @@ class Setnews extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const state = interaction.options.getBoolean("state"); diff --git a/commands/Administration/setreports.js b/commands/Administration/setreports.js index 9b1b549e..99fbd4da 100644 --- a/commands/Administration/setreports.js +++ b/commands/Administration/setreports.js @@ -34,7 +34,7 @@ class Setreports extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const state = interaction.options.getBoolean("state"); diff --git a/commands/Administration/setsuggests.js b/commands/Administration/setsuggests.js index 1b687abf..1af1f001 100644 --- a/commands/Administration/setsuggests.js +++ b/commands/Administration/setsuggests.js @@ -34,7 +34,7 @@ class Setsuggests extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const state = interaction.options.getBoolean("state"); diff --git a/commands/Administration/stealemoji.js b/commands/Administration/stealemoji.js index 08b96239..82bf1220 100644 --- a/commands/Administration/stealemoji.js +++ b/commands/Administration/stealemoji.js @@ -31,7 +31,7 @@ class Stealemoji extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const parsedEmoji = parseEmoji(interaction.options.getString("emoji")); @@ -46,9 +46,9 @@ class Stealemoji extends BaseCommand { emoji: emoji.name }, { ephemeral: true })) .catch(e => { - console.log(e); interaction.error("administration/stealemoji:ERROR", { - emoji: parsedEmoji.name + emoji: parsedEmoji.name, + e }, { ephemeral: true }); }); } diff --git a/commands/Administration/welcome.js b/commands/Administration/welcome.js index 25411b6f..af320614 100644 --- a/commands/Administration/welcome.js +++ b/commands/Administration/welcome.js @@ -43,7 +43,7 @@ class Welcome extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const command = interaction.options.getSubcommand(); diff --git a/commands/Economy/achievements.js b/commands/Economy/achievements.js new file mode 100644 index 00000000..76403b8c --- /dev/null +++ b/commands/Economy/achievements.js @@ -0,0 +1,116 @@ +const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Achievements extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("achievements") + .setDescription(client.translate("economy/achievements:DESCRIPTION")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER"))), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const member = interaction.options.getMember("user") || interaction.member; + if (member.user.bot) return interaction.error("economy/profile:BOT_USER"); + const userData = (member.id === interaction.member.id ? data.userData : await client.findOrCreateUser({ + id: member.id + })); + + const embed = new EmbedBuilder() + .setAuthor({ + name: interaction.translate("economy/achievements:TITLE") + }) + .setColor(client.config.embed.color) + .setFooter({ + text: client.config.embed.footer + }); + + embed.addFields([ + { + name: interaction.translate("economy/achievements:SEND_CMD"), + value: interaction.translate("economy/achievements:PROGRESS", { + now: userData.achievements.firstCommand.progress.now, + total: userData.achievements.firstCommand.progress.total, + percent: Math.round(100 * (userData.achievements.firstCommand.progress.now / userData.achievements.firstCommand.progress.total)) + }) + }, + { + name: interaction.translate("economy/achievements:CLAIM_SALARY"), + value: interaction.translate("economy/achievements:PROGRESS", { + now: userData.achievements.work.progress.now, + total: userData.achievements.work.progress.total, + percent: Math.round(100 * (userData.achievements.work.progress.now / userData.achievements.work.progress.total)) + }) + }, + { + name: interaction.translate("economy/achievements:MARRY"), + value: interaction.translate("economy/achievements:PROGRESS", { + now: userData.achievements.married.progress.now, + total: userData.achievements.married.progress.total, + percent: Math.round(100 * (userData.achievements.married.progress.now / userData.achievements.married.progress.total)) + }) + }, + { + name: interaction.translate("economy/achievements:SLOTS"), + value: interaction.translate("economy/achievements:PROGRESS", { + now: userData.achievements.slots.progress.now, + total: userData.achievements.slots.progress.total, + percent: Math.round(100 * (userData.achievements.slots.progress.now / userData.achievements.slots.progress.total)) + }) + }, + { + name: interaction.translate("economy/achievements:TIP"), + value: interaction.translate("economy/achievements:PROGRESS", { + now: userData.achievements.tip.progress.now, + total: userData.achievements.tip.progress.total, + percent: Math.round(100 * (userData.achievements.tip.progress.now / userData.achievements.tip.progress.total)) + }) + }, + { + name: interaction.translate("economy/achievements:REP"), + value: interaction.translate("economy/achievements:PROGRESS", { + now: userData.achievements.rep.progress.now, + total: userData.achievements.rep.progress.total, + percent: Math.round(100 * (userData.achievements.rep.progress.now / userData.achievements.rep.progress.total)) + }) + }, + { + name: interaction.translate("economy/achievements:INVITE"), + value: interaction.translate("economy/achievements:PROGRESS", { + now: userData.achievements.invite.progress.now, + total: userData.achievements.invite.progress.total, + percent: Math.round(100 * (userData.achievements.invite.progress.now / userData.achievements.invite.progress.total)) + }) + } + ]); + + interaction.reply({ + embeds: [embed] + }); + } +} + +module.exports = Achievements; \ No newline at end of file diff --git a/commands/Economy/bank.js b/commands/Economy/bank.js new file mode 100644 index 00000000..74739421 --- /dev/null +++ b/commands/Economy/bank.js @@ -0,0 +1,92 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Bank extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("bank") + .setDescription(client.translate("economy/bank:DESCRIPTION")) + .addStringOption(option => option.setName("option") + .setDescription(client.translate("economy/bank:OPTION")) + .setRequired(true) + .addChoices( + { name: client.translate("economy/bank:DEPOSIT"), value: "deposit" }, + { name: client.translate("economy/bank:WITHDRAW"), value: "withdraw" } + )) + .addStringOption(option => option.setName("credits") + .setDescription(client.translate("moderation/clear:OPTION")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const choice = interaction.options.getString("option"); + + if (choice === "deposit") { + const credits = interaction.options.getString("credits") === "all" ? data.memberData.money : interaction.options.getString("credits"); + 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"))}` }); + + 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"))}` + }); + } else { + const credits = interaction.options.getString("credits") === "all" ? data.memberData.bankSold : interaction.options.getString("credits"); + if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL"); + if (data.memberData.bankSold < credits) return interaction.error("economy/bank:NOT_ENOUGH_BANK", { money: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` }); + + const info = { + user: interaction.translate("economy/transactions:BANK"), + amount: credits, + date: Date.now(), + type: "got" + }; + + data.memberData.transactions.push(info); + + data.memberData.money += credits; + data.memberData.bankSold -= credits; + await data.memberData.save(); + + interaction.success("economy/bank:SUCCESS_WD", { + money: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` + }); + } + } +} + +module.exports = Bank; \ No newline at end of file diff --git a/commands/Economy/birthdate.js b/commands/Economy/birthdate.js new file mode 100644 index 00000000..e898f29b --- /dev/null +++ b/commands/Economy/birthdate.js @@ -0,0 +1,57 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Birthdate extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("birthdate") + .setDescription(client.translate("economy/birthdate:DESCRIPTION")) + .addStringOption(option => option.setName("date") + .setDescription(client.translate("economy/birthdate:DATE")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const date = interaction.options.getString("date"); + const match = date.match(/\d+/g); + if (!match) return interaction.error("economy/birthdate:INVALID_DATE"); + const [day, month, year] = date.split("/"); + if (!day || !month || !year) return interaction.error("economy/birthdate:INVALID_DATE"); + + const d = new Date(year, month - 1, day); + if (!(day == d.getDate() && month - 1 == d.getMonth() && year == d.getFullYear())) return interaction.error("economy/birthdate:INVALID_DATE"); + if (d.getTime() > Date.now()) return interaction.error("economy/birthdate:DATE_TOO_HIGH"); + if (d.getTime() < (Date.now() - 2.523e+12)) return interaction.error("economy/birthdate:DATE_TOO_LOW"); + + data.userData.birthdate = d; + await data.userData.save(); + + interaction.success("economy/birthdate:SUCCESS", { + date: client.printDate(d) + }); + } +} + +module.exports = Birthdate; \ No newline at end of file diff --git a/commands/Economy/divorce.js b/commands/Economy/divorce.js new file mode 100644 index 00000000..d6645993 --- /dev/null +++ b/commands/Economy/divorce.js @@ -0,0 +1,58 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Divorce extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("divorce") + .setDescription(client.translate("economy/divorce:DESCRIPTION")), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + if (!data.userData.lover) return interaction.error("economy/divorce:NOT_MARRIED"); + const user = client.users.cache.get(data.userData.lover) || await client.users.fetch(data.userData.lover); + + data.userData.lover = null; + await data.userData.save(); + + const oldLover = await client.findOrCreateUser({ + id: user.id + }); + oldLover.lover = null; + await oldLover.save(); + + interaction.success("economy/divorce:DIVORCED", { + user: user.toString() + }); + + user.send({ + content: interaction.translate("economy/divorce:DIVORCED_U", { + user: interaction.member.toString() + }) + }); + } +} + +module.exports = Divorce; \ No newline at end of file diff --git a/commands/Economy/importmee6.js b/commands/Economy/importmee6.js new file mode 100644 index 00000000..b8998308 --- /dev/null +++ b/commands/Economy/importmee6.js @@ -0,0 +1,47 @@ +const { SlashCommandBuilder } = require("discord.js"), + { getUserXp } = require("mee6-levels-api"); +const BaseCommand = require("../../base/BaseCommand"); + +class ImportMee6 extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("importmee6") + .setDescription(client.translate("economy/importmee6:DESCRIPTION")), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const level = (await getUserXp(interaction.guildId, interaction.member.id)).level; + + data.memberData.level = level; + await data.memberData.save(); + + interaction.success("owner/debug:SUCCESS_LEVEL", { + username: interaction.member.toString(), + amount: level + }); + } +} + +module.exports = ImportMee6; \ No newline at end of file diff --git a/commands/Economy/marry.js b/commands/Economy/marry.js new file mode 100644 index 00000000..09d4a697 --- /dev/null +++ b/commands/Economy/marry.js @@ -0,0 +1,156 @@ +const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"), + pendings = {}; + +class Marry extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("marry") + .setDescription(client.translate("economy/marry:DESCRIPTION")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + if (data.userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED"); + const member = interaction.options.getMember("user"); + if (member.user.bot) return interaction.error("economy/marry:BOT_USER"); + if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF"); + const userData = await client.findOrCreateUser({ + id: member.id + }); + if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() }); + + for (const requester in pendings) { + const receiver = pendings[requester]; + + if (requester === interaction.author.id) { + const user = client.users.cache.get(receiver) || await client.users.fetch(receiver); + return interaction.error("economy/marry:REQUEST_AUTHOR_TO_AMEMBER", { + user: user.toString + }); + } else if (receiver === interaction.member.id) { + const user = client.users.cache.get(requester) || await client.users.fetch(requester); + return interaction.error("economy/marry:REQUEST_AMEMBER_TO_AUTHOR", { + user: user.toString() + }); + } else if (requester === member.id) { + const user = client.users.cache.get(receiver) || await client.users.fetch(receiver); + return interaction.error("economy/marry:REQUEST_AMEMBER_TO_MEMBER", { + firstUser: member.toString(), + secondUser: user.toString() + }); + } else if (receiver === member.id) { + const user = client.users.cache.get(requester) || await client.users.fetch(requester); + return interaction.error("economy/marry:REQUEST_MEMBER_TO_AMEMBER", { + firstUser: member.toString(), + secondUser: user.toString() + }); + } + } + + pendings[interaction.member.id] = member.id; + + const row = new ActionRowBuilder() + .addComponents( + new ButtonBuilder() + .setCustomId("marry_confirm_yes") + .setLabel(interaction.translate("common:ACCEPT")) + .setStyle(ButtonStyle.Danger), + new ButtonBuilder() + .setCustomId("marry_confirm_no") + .setLabel(interaction.translate("common:CANCEL")) + .setStyle(ButtonStyle.Secondary), + ); + + + await interaction.reply({ + content: interaction.translate("economy/marry:REQUEST", { + to: member.toString(), + from: interaction.member.toString() + }), + components: [row] + }); + + const filter = i => i.user.id === member.id; + const collector = interaction.channel.createMessageComponentCollector({ filter, time: 120000 }); + + collector.on("collect", async i => { + if (i.isButton()) { + if (i.customId === "marry_confirm_yes") return collector.stop(true); + else if (i.customId === "marry_confirm_no") return collector.stop(false); + } + }); + + collector.on("end", async (_, reason) => { + delete pendings[interaction.member.id]; + if (reason === "time") return interaction.error("economy/marry:TIMEOUT"); + if (reason) { + data.userData.lover = member.id; + await data.userData.save(); + userData.lover = interaction.member.id; + await userData.save(); + + const messageOptions = { + content: `${member.toString()} :heart: ${interaction.member.toString()}`, + files: [{ + name: "achievement_unlocked3.png", + attachment: "./assets/img/achievements/achievement_unlocked3.png" + }] + }; + + let sent = false; + if (!userData.achievements.married.achieved) { + interaction.followUp(messageOptions); + sent = true; + userData.achievements.married.achieved = true; + userData.achievements.married.progress.now = 1; + userData.markModified("achievements.married"); + await userData.save(); + } + if (!data.userData.achievements.married.achieved) { + if (!sent) interaction.followUp(messageOptions); + data.userData.achievements.married.achieved = true; + data.userData.achievements.married.progress.now = 1; + data.userData.markModified("achievements.married"); + await data.userData.save(); + } + + return interaction.success("economy/marry:SUCCESS", { + creator: interaction.member.toString(), + partner: member.toString() + }); + } else { + return interaction.success("economy/marry:DENIED", { + creator: interaction.member.toString(), + partner: member.toString() + }); + } + }); + } +} + +module.exports = Marry; \ No newline at end of file diff --git a/commands/Economy/money.js b/commands/Economy/money.js new file mode 100644 index 00000000..728ec1bd --- /dev/null +++ b/commands/Economy/money.js @@ -0,0 +1,96 @@ +const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); +const asyncForEach = async (collection, callback) => { + const allPromises = collection.map(async key => { + await callback(key); + }); + + return await Promise.all(allPromises); +}; + +class Money extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("money") + .setDescription(client.translate("economy/money:DESCRIPTION")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER"))), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + await interaction.deferReply(); + const member = interaction.options.getMember("user") || interaction.member; + if (member.user.bot) return interaction.error("economy/money:BOT_USER"); + + const memberData = (member.id === interaction.user.id) ? data.memberData : await client.findOrCreateMember({ + id: member.id, + guildID: interaction.guildId + }); + + const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id)); + let globalMoney = 0; + await asyncForEach(guilds, async guild => { + const data = await client.findOrCreateMember({ + id: member.id, + guildID: guild.id + }); + globalMoney += data.money + data.bankSold; + }); + + const embed = new EmbedBuilder() + .setAuthor({ + name: interaction.translate("economy/money:TITLE", { + username: member.user.tag + }), + iconURL: member.user.displayAvatarURL() + }) + .addFields([ + { + name: interaction.translate("economy/profile:CASH"), + value: `**${memberData.money}** ${client.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + inline: true + }, + { + name: interaction.translate("economy/profile:BANK"), + value: `**${memberData.bankSold}** ${client.getNoun(memberData.bankSold, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + inline: true + }, + { + name: interaction.translate("economy/profile:GLOBAL"), + value: `**${globalMoney}** ${client.getNoun(globalMoney, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + inline: true + } + ]) + .setColor(client.config.embed.color) + .setFooter({ + text: client.config.embed.footer + }); + interaction.editReply({ + embeds: [embed] + }); + } +} + +module.exports = Money; \ No newline at end of file diff --git a/commands/Economy/number.js b/commands/Economy/number.js new file mode 100644 index 00000000..a88d2397 --- /dev/null +++ b/commands/Economy/number.js @@ -0,0 +1,116 @@ +const { SlashCommandBuilder, MessageCollector } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"), + currentGames = {}; + +class Number extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("number") + .setDescription(client.translate("economy/number:DESCRIPTION")), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + if (currentGames[interaction.guildId]) return interaction.error("economy/number:GAME_RUNNING"); + + const participants = [], + number = client.functions.randomNum(1000, 5000); + + await interaction.replyT("economy/number:GAME_START"); + + const gameCreatedAt = Date.now(); + + const filter = m => !m.author.bot; + const collector = new MessageCollector(interaction.channel, { + filter, + time: (5 * 60 * 1000) + }); + currentGames[interaction.guildId] = true; + + collector.on("collect", async msg => { + if (!participants.includes(msg.author.id)) participants.push(msg.author.id); + if (msg.content === "STOP") return collector.stop("force"); + if (isNaN(msg.content)) return; + + const parsedNumber = parseInt(msg.content, 10); + + if (parsedNumber === number) { + const time = client.convertTime(gameCreatedAt, false, false, data.guildData.language); + interaction.channel.send({ + content: interaction.translate("economy/number:GAME_STATS", { + winner: msg.author.toString(), + number, + time, + participantCount: participants.length, + participants: participants.map(p => `<@${p}>`).join(", ") + }) + }); + + if (participants.length > 1) { + const won = 100 * (participants.length * 0.5); + + interaction.channel.send({ + content: interaction.translate("economy/number:WON", { + winner: msg.author.username, + credits: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` + }) + }); + + const memberData = await client.findOrCreateMember({ + id: msg.author.id, + guildID: interaction.guildId + }); + + 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(); + } + + if (parseInt(msg.content) < number) msg.reply({ + content: interaction.translate("economy/number:TOO_BIG", { user: msg.author.toString(), number: parsedNumber }) + }); + if (parseInt(msg.content) > number) msg.reply({ + content: interaction.translate("economy/number:TOO_SMALL", { user: msg.author.toString(), number: parsedNumber }) + }); + }); + + collector.on("end", (_collected, reason) => { + delete currentGames[interaction.guildId]; + if (reason === "time") return interaction.editReply({ content: interaction.translate("economy/number:DEFEAT", { number }) }); + else if (reason === "force") return interaction.editReply({ content: interaction.translate("misc:FORCE_STOP", { user: interaction.member.toString() }) }); + }); + } +} + +module.exports = Number; \ No newline at end of file diff --git a/commands/Economy/pay.js b/commands/Economy/pay.js new file mode 100644 index 00000000..a718d4e9 --- /dev/null +++ b/commands/Economy/pay.js @@ -0,0 +1,77 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Pay extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("pay") + .setDescription(client.translate("economy/pay:DESCRIPTION")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER")) + .setRequired(true)) + .addIntegerOption(option => option.setName("amount") + .setDescription(client.translate("common:INT")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const member = interaction.options.getMember("user"); + if (member.user.bot) return interaction.error("economy/pay:BOT_USER"); + if (member.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF"); + const amount = interaction.options.getInteger("amount"); + if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO"); + + + if (amount > data.memberData.money) return interaction.error("economy/pay:ENOUGH_MONEY", { + amount: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}` + }); + + const memberData = await client.findOrCreateMember({ + id: member.id, + 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(); + + 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"))}` + }); + } +} + +module.exports = Pay; \ No newline at end of file diff --git a/commands/Economy/profile.js b/commands/Economy/profile.js new file mode 100644 index 00000000..49d863de --- /dev/null +++ b/commands/Economy/profile.js @@ -0,0 +1,151 @@ +const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); +const asyncForEach = async (collection, callback) => { + const allPromises = collection.map(async key => { + await callback(key); + }); + + return await Promise.all(allPromises); +}; + +class Profile extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("profile") + .setDescription(client.translate("economy/profile:DESCRIPTION")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER"))), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + await interaction.deferReply(); + const member = interaction.options.getMember("user") || interaction.member; + if (member.user.bot) return interaction.error("economy/profile:BOT_USER"); + + const memberData = (member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({ + id: member.id, + guildID: interaction.guildId + })); + const userData = (member.id === interaction.user.id ? data.userData : await client.findOrCreateUser({ + id: member.id + })); + if (userData.lover && !client.users.cache.find(u => u.id === userData.lover)) await client.users.fetch(userData.lover, true); + + const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id)); + let globalMoney = 0; + await asyncForEach(guilds, async guild => { + const data = await client.findOrCreateMember({ + id: member.id, + guildID: guild.id + }); + globalMoney += data.money + data.bankSold; + }); + + const profileEmbed = new EmbedBuilder() + .setAuthor({ + name: interaction.translate("economy/profile:TITLE", { + username: member.user.tag + }), + iconURL: member.displayAvatarURL() + }) + .setImage("attachment://achievements.png") + .addFields([ + { + name: client.customEmojis.link + " " + interaction.translate("economy/profile:LINK"), + value: `[${interaction.translate("economy/profile:LINK_TEXT")}](${client.config.dashboard.baseURL}/user/${member.user.id}/${interaction.guild.id})` + }, + { + name: interaction.translate("economy/profile:BIO"), + value: userData.bio ? userData.bio : interaction.translate("common:UNKNOWN") + }, + { + name: interaction.translate("economy/profile:CASH"), + value: `**${memberData.money}** ${client.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + inline: true + }, + { + name: interaction.translate("economy/profile:BANK"), + value: `**${memberData.bankSold}** ${client.getNoun(memberData.bankSold, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + inline: true + }, + { + name: interaction.translate("economy/profile:GLOBAL"), + value: `**${globalMoney}** ${client.getNoun(globalMoney, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + inline: true + }, + { + name: interaction.translate("economy/profile:REPUTATION"), + value: `**${userData.rep}** ${client.getNoun(userData.rep, interaction.translate("misc:NOUNS:POINTS:1"), interaction.translate("misc:NOUNS:POINTS:2"), interaction.translate("misc:NOUNS:POINTS:5"))}`, + inline: true + }, + { + name: interaction.translate("economy/profile:LEVEL"), + value:`**${memberData.level}**`, + inline: true + }, + { + name: interaction.translate("economy/profile:XP"), + value: `**${memberData.exp}/${5 * (memberData.level * memberData.level) + 80 * memberData.level + 100}** xp`, + inline: true + }, + { + name: interaction.translate("economy/profile:REGISTERED"), + value: client.printDate(new Date(memberData.registeredAt)), + inline: true + }, + { + name: interaction.translate("economy/profile:BIRTHDATE"), + value: (!userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.printDate(new Date(userData.birthdate))), + inline: true + }, + { + name: interaction.translate("economy/profile:LOVER"), + value: (!userData.lover ? interaction.translate("common:NOT_DEFINED") : client.users.cache.get(userData.lover).tag), + inline: true + }, + { + name: interaction.translate("economy/profile:ACHIEVEMENTS"), + value: interaction.translate("economy/profile:ACHIEVEMENTS_CONTENT") + } + ]) + .setColor(client.config.embed.color) + .setFooter({ + text: client.config.embed.footer + }) + .setTimestamp(); + + const buffer = await userData.getAchievements(); + + interaction.editReply({ + embeds: [profileEmbed], + files: [{ + name: "achievements.png", + attachment: buffer + }] + }); + } +} + +module.exports = Profile; \ No newline at end of file diff --git a/commands/Economy/rep.js b/commands/Economy/rep.js new file mode 100644 index 00000000..202946b1 --- /dev/null +++ b/commands/Economy/rep.js @@ -0,0 +1,81 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Rep extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("rep") + .setDescription(client.translate("economy/rep:DESCRIPTION")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const isInCooldown = data.userData.cooldowns?.rep; + if (isInCooldown) { + if (isInCooldown > Date.now()) return interaction.error("economy/rep:COOLDOWN", { + time: client.convertTime(isInCooldown, true, true) + }); + } + + const user = interaction.options.getUser("user"); + if (user.bot) return interaction.error("economy/rep:BOT_USER"); + if (user.id === interaction.user.id) return interaction.error("economy/rep:YOURSELF"); + + const toWait = Date.now() + 21600000; // 12 hours + if (!data.userData.cooldowns) data.userData.cooldowns = {}; + data.userData.cooldowns.rep = toWait; + data.userData.markModified("cooldowns"); + await data.userData.save(); + + const userData = await client.findOrCreateUser({ + id: user.id + }); + userData.rep++; + + if (!userData.achievements.rep.achieved) { + userData.achievements.rep.progress.now = (userData.rep > userData.achievements.rep.progress.total ? userData.achievements.rep.progress.total : userData.rep); + if (userData.achievements.rep.progress.now >= userData.achievements.rep.progress.total) { + userData.achievements.rep.achieved = true; + interaction.followUp({ + content: `${user}`, + files: [{ + name: "achievement_unlocked6.png", + attachment: "./assets/img/achievements/achievement_unlocked6.png" + }] + }); + } + userData.markModified("achievements.rep"); + } + await userData.save(); + + interaction.success("economy/rep:SUCCESS", { + user: user.toString() + }); + } +} + +module.exports = Rep; \ No newline at end of file diff --git a/commands/Economy/rob.js b/commands/Economy/rob.js new file mode 100644 index 00000000..2548cddf --- /dev/null +++ b/commands/Economy/rob.js @@ -0,0 +1,94 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Rob extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("rob") + .setDescription(client.translate("economy/rob:DESCRIPTION")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER")) + .setRequired(true)) + .addIntegerOption(option => option.setName("amount") + .setDescription(client.translate("common:INT")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const member = interaction.options.getMember("user"); + if (member.user.bot) return interaction.error("economy/pay:BOT_USER"); + if (member.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF"); + const amount = interaction.options.getInteger("amount"); + if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO"); + + const memberData = await client.findOrCreateMember({ + id: member.id, + 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() }); + } + + const potentiallyLose = Math.floor(amount * 1.5); + if (potentiallyLose > data.memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_AUTHOR", { + moneyMin: `**${potentiallyLose}** ${client.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + moneyCurrent: `**${data.memberData.money}** ${client.getNoun(data.memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` + }); + + const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25); + + if (itsAWon) { + const toWait = Date.now() + (6 * 60 * 60 * 1000); + memberData.cooldowns.rob = toWait; + memberData.markModified("cooldowns"); + await memberData.save(); + const randomNum = client.functions.randomNum(1, 2); + interaction.replyT("economy/rob:ROB_WON_" + randomNum, { + money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + user: member.toString() + }); + data.memberData.money += amount; + memberData.money -= amount; + await memberData.save(); + await data.memberData.save(); + } else { + const won = Math.floor(amount * 0.9); + const randomNum = client.functions.randomNum(1, 2); + interaction.replyT("economy/rob:ROB_LOSE_" + randomNum, { + fine: `**${potentiallyLose}** ${client.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + offset: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + user: member.toString() + }); + data.memberData.money -= potentiallyLose; + memberData.money += won; + await memberData.save(); + await data.memberData.save(); + } + } +} + +module.exports = Rob; \ No newline at end of file diff --git a/commands/Economy/setbio.js b/commands/Economy/setbio.js new file mode 100644 index 00000000..ec3246e2 --- /dev/null +++ b/commands/Economy/setbio.js @@ -0,0 +1,46 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Setbio extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("setbio") + .setDescription(client.translate("economy/setbio:DESCRIPTION")) + .addStringOption(option => option.setName("text") + .setDescription(client.translate("economy/profile:BIO")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const newBio = interaction.options.getString("text"); + if (newBio.length > 150) return interaction.error("economy/setbio:MAX_CHARACTERS"); + + data.userData.bio = newBio; + await data.userData.save(); + interaction.success("economy/setbio:SUCCESS"); + } +} + +module.exports = Setbio; \ No newline at end of file diff --git a/!TO REWRITE/Economy/slots.js b/commands/Economy/slots.js similarity index 55% rename from !TO REWRITE/Economy/slots.js rename to commands/Economy/slots.js index 31fe1e4c..2b7ad7e7 100644 --- a/!TO REWRITE/Economy/slots.js +++ b/commands/Economy/slots.js @@ -1,42 +1,55 @@ -const Command = require("../../base/Command"); +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); -class Slots extends Command { +class Slots extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ constructor(client) { - super(client, { - name: "slots", + super({ + command: new SlashCommandBuilder() + .setName("slots") + .setDescription(client.translate("economy/slots:DESCRIPTION")) + .addIntegerOption(option => option.setName("amount") + .setDescription(client.translate("common:INT")) + .setRequired(true)), + aliases: [], dirname: __dirname, - enabled: true, guildOnly: true, - aliases: ["casino", "slot"], - memberPermissions: [], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 + ownerOnly: false }); } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + await interaction.deferReply(); + const amount = interaction.options.getInteger("amount"); + if (amount > data.memberData.money) return interaction.error("economy/slots:NOT_ENOUGH", { money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` }); - async run(message, args, data) { const fruits = ["🍎", "🍐", "🍌", "🍇", "🍉", "🍒", "🍓"]; let i1 = 0, j1 = 0, k1 = 0, i2 = 1, j2 = 1, k2 = 1, i3 = 2, j3 = 2, k3 = 2; - // Gets three random fruits array const colonnes = [ - this.client.functions.shuffle(fruits), - this.client.functions.shuffle(fruits), - this.client.functions.shuffle(fruits) + client.functions.shuffle(fruits), + client.functions.shuffle(fruits), + client.functions.shuffle(fruits) ]; - // Gets the amount provided - let amount = args[0]; - if (!amount || isNaN(amount) || amount < 1) amount = 50; - if (amount > data.memberData.money) return message.error("economy/slots:NOT_ENOUGH", { money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}` }); - - amount = Math.round(amount); - function getCredits(number, isJackpot) { if (!isJackpot) number = number * 1.5; else if (isJackpot) number = number * 5; @@ -44,16 +57,13 @@ class Slots extends Command { return Math.round(number); } - const tmsg = await message.sendT("misc:PLEASE_WAIT", null, { - prefixEmoji: "loading" - }); editMsg(); const interval = setInterval(editMsg, 1000); setTimeout(() => { clearInterval(interval); - end(tmsg); + end(); }, 4000); async function end() { @@ -74,34 +84,36 @@ class Slots extends Command { msg += colonnes[0][i3] + " : " + colonnes[1][j3] + " : " + colonnes[2][k3] + "\n------------------\n"; if ((colonnes[0][i2] == colonnes[1][j2]) && (colonnes[1][j2] == colonnes[2][k2])) { - msg += "| : : : **" + (message.translate("common:VICTORY").toUpperCase()) + "** : : : |"; - tmsg.edit(msg); + msg += "| : : : **" + (interaction.translate("common:VICTORY").toUpperCase()) + "** : : : |"; + await interaction.editReply({ + content: msg + }); + const credits = getCredits(amount, true); - message.channel.send({ - content: "**!! ДЖЕКПОТ !!**\n" + message.translate("economy/slots:VICTORY", { - money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - won: `**${credits}** ${message.getNoun(credits, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - username: message.author.username + interaction.followUp({ + content: "**!! ДЖЕКПОТ !!**\n" + interaction.translate("economy/slots:VICTORY", { + money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + won: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + user: interaction.member.toString() }) }); const toAdd = credits - amount; const info = { - user: message.translate("economy/slots:DESCRIPTION"), + user: interaction.translate("economy/slots:DESCRIPTION"), amount: toAdd, date: Date.now(), type: "got" }; - data.memberData.transactions.push(info); + data.memberData.money += toAdd; - data.memberData.money = data.memberData.money + toAdd; if (!data.userData.achievements.slots.achieved) { data.userData.achievements.slots.progress.now += 1; if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) { data.userData.achievements.slots.achieved = true; - message.reply({ + interaction.followUp({ files: [{ name: "achievement_unlocked4.png", attachment: "./assets/img/achievements/achievement_unlocked4.png" @@ -116,33 +128,35 @@ class Slots extends Command { } if (colonnes[0][i2] == colonnes[1][j2] || colonnes[1][j2] == colonnes[2][k2] || colonnes[0][i2] == colonnes[2][k2]) { - msg += "| : : : **" + (message.translate("common:VICTORY").toUpperCase()) + "** : : : |"; - tmsg.edit(msg); + msg += "| : : : **" + (interaction.translate("common:VICTORY").toUpperCase()) + "** : : : |"; + await interaction.editReply({ + content: msg + }); + const credits = getCredits(amount, false); - message.channel.send({ - content: message.translate("economy/slots:VICTORY", { - money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - won: `**${credits}** ${message.getNoun(credits, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - username: message.author.username + interaction.followUp({ + content: interaction.translate("economy/slots:VICTORY", { + money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + won: `**${credits}** ${client.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + user: interaction.member.toString() }) }); const toAdd = credits - amount; const info = { - user: message.translate("economy/slots:DESCRIPTION"), + user: interaction.translate("economy/slots:DESCRIPTION"), amount: toAdd, date: Date.now(), type: "got" }; - data.memberData.transactions.push(info); + data.memberData.money += toAdd; - data.memberData.money = data.memberData.money + toAdd; if (!data.userData.achievements.slots.achieved) { data.userData.achievements.slots.progress.now += 1; if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) { data.userData.achievements.slots.achieved = true; - message.reply({ + interaction.followUp({ files: [{ name: "achievement_unlocked4.png", attachment: "./assets/img/achievements/achievement_unlocked4.png" @@ -156,24 +170,23 @@ class Slots extends Command { return; } - msg += "| : : : **" + (message.translate("common:DEFEAT").toUpperCase()) + "** : : : |"; - message.channel.send({ - content: message.translate("economy/slots:DEFEAT", { - money: `**${amount}** ${message.getNoun(amount, message.translate("misc:NOUNS:CREDIT:1"), message.translate("misc:NOUNS:CREDIT:2"), message.translate("misc:NOUNS:CREDIT:5"))}`, - username: message.author.username + msg += "| : : : **" + (interaction.translate("common:DEFEAT").toUpperCase()) + "** : : : |"; + interaction.followUp({ + content: interaction.translate("economy/slots:DEFEAT", { + money: `**${amount}** ${client.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, + user: interaction.member.toString() }) }); const info = { - user: message.translate("economy/slots:DESCRIPTION"), + user: interaction.translate("economy/slots:DESCRIPTION"), amount: amount, date: Date.now(), type: "send" }; - data.memberData.transactions.push(info); + data.memberData.money -= amount; - data.memberData.money = data.memberData.money - amount; if (!data.userData.achievements.slots.achieved) { data.userData.achievements.slots.progress.now = 0; data.userData.markModified("achievements.slots"); @@ -183,7 +196,7 @@ class Slots extends Command { return; } - function editMsg() { + async function editMsg() { let msg = "[ :slot_machine: | **СЛОТЫ** ]\n------------------\n"; i1 = (i1 < fruits.length - 1) ? i1 + 1 : 0; @@ -200,7 +213,9 @@ class Slots extends Command { msg += colonnes[0][i2] + " : " + colonnes[1][j2] + " : " + colonnes[2][k2] + " **<**\n"; msg += colonnes[0][i3] + " : " + colonnes[1][j3] + " : " + colonnes[2][k3] + "\n"; - tmsg.edit(msg); + await interaction.editReply({ + content: msg + }); } } } diff --git a/commands/Economy/tictactoe.js b/commands/Economy/tictactoe.js new file mode 100644 index 00000000..06c9cc52 --- /dev/null +++ b/commands/Economy/tictactoe.js @@ -0,0 +1,62 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"), + tictactoe = require("../../helpers/tictactoe"); + +class TicTacToe extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("tictactoe") + .setDescription(client.translate("economy/tictactoe:DESCRIPTION")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction) { + tictactoe(interaction, { + resultBtn: true, + embedColor: client.config.embed.color, + embedFoot: client.config.embed.footer + }).then(async winner => { + const memberData = await client.findOrCreateMember({ + id: winner.id, + guildID: interaction.guildId + }); + + const info = { + user: interaction.translate("economy/transactions:TTT"), + amount: 100, + date: Date.now(), + type: "got" + }; + memberData.transactions.push(info); + + memberData.money += 100; + await memberData.save(); + }); + } +} + +module.exports = TicTacToe; \ No newline at end of file diff --git a/commands/Economy/transactions.js b/commands/Economy/transactions.js new file mode 100644 index 00000000..bdc3c713 --- /dev/null +++ b/commands/Economy/transactions.js @@ -0,0 +1,77 @@ +const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Transactions extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("transactions") + .setDescription(client.translate("economy/transactions:DESCRIPTION")), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const embed = new EmbedBuilder() + .setAuthor({ + name: interaction.translate("economy/transactions:EMBED_TRANSACTIONS"), + iconURL: interaction.member.displayAvatarURL() + }) + .setColor(client.config.embed.color) + .setFooter({ + text: client.config.embed.footer + }); + + const transactions = data.memberData.transactions, + sortedTransactions = [ [], [] ]; + + transactions.slice(-20).forEach(t => { + const array = t.type === "got" ? sortedTransactions[0] : sortedTransactions[1]; + array.push(`${interaction.translate("economy/transactions:T_USER_" + t.type.toUpperCase())}: ${t.user}\n${interaction.translate("economy/transactions:T_AMOUNT")}: ${t.amount}\n${interaction.translate("economy/transactions:T_DATE")}: ${client.printDate(t.date, "Do MMMM YYYY, HH:mm", data.guildData.language)}\n`); + }); + + if (transactions.length < 1) { + embed.setDescription(interaction.translate("economy/transactions:NO_TRANSACTIONS")); + } else { + if (sortedTransactions[0].length > 0) embed.addFields([ + { + name: interaction.translate("economy/transactions:T_GOT"), + value: sortedTransactions[0].join("\n"), + inline: true + } + ]); + if (sortedTransactions[1].length > 0) embed.addFields([ + { + name: interaction.translate("economy/transactions:T_SEND"), + value: sortedTransactions[1].join("\n"), + inline: true + } + ]); + } + + interaction.reply({ + embeds: [embed] + }); + } +} + +module.exports = Transactions; \ No newline at end of file diff --git a/commands/Economy/work.js b/commands/Economy/work.js new file mode 100644 index 00000000..2a1d475a --- /dev/null +++ b/commands/Economy/work.js @@ -0,0 +1,132 @@ +const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Work extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("work") + .setDescription(client.translate("economy/work:DESCRIPTION")), + aliases: [], + dirname: __dirname, + guildOnly: true, + ownerOnly: false + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Object} data + */ + async execute(client, interaction, data) { + const isInCooldown = data.memberData.cooldowns?.work; + if (isInCooldown) { + if (isInCooldown > Date.now()) return interaction.error("economy/work:COOLDOWN", { + time: client.convertTime(isInCooldown, true, true) + }); + } + if (Date.now() > data.memberData.cooldowns.work + (24 * 3600000)) data.memberData.workStreak = 0; + + const toWait = Date.now() + 43200000; // 24 hours + data.memberData.cooldowns.work = toWait; + data.memberData.markModified("cooldowns"); + + data.memberData.workStreak = (data.memberData.workStreak || 0) + 1; + await data.memberData.save(); + + const embed = new EmbedBuilder() + .setFooter({ + text: interaction.translate("economy/work:AWARD"), + iconURL: interaction.member.displayAvatarURL() + }) + .setColor(client.config.embed.color); + + const award = [ + client.customEmojis.letters.a, + client.customEmojis.letters.w, + client.customEmojis.letters.a, + client.customEmojis.letters.r, + client.customEmojis.letters.d + ]; + let won = 200; + + if (data.memberData.workStreak >= 5) { + won += 200; + embed.addFields([ + { + name: interaction.translate("economy/work:SALARY"), + value: interaction.translate("economy/work:SALARY_CONTENT", { + won: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` + }) + }, + { + name: interaction.translate("economy/work:STREAK"), + value: interaction.translate("economy/work:STREAK_CONTENT") + } + ]); + data.memberData.workStreak = 0; + } else { + for (let i = 0; i < award.length; i++) { + if (data.memberData.workStreak > i) { + const letter = parseEmoji(award[i]).name.split("_")[1]; + award[i] = `:regional_indicator_${letter.toLowerCase()}:`; + } + } + embed.addFields([ + { + name: interaction.translate("economy/work:SALARY"), + value: interaction.translate("economy/work:SALARY_CONTENT", { + won: `**${won}** ${client.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` + }) + }, + { + name: interaction.translate("economy/work:STREAK"), + value: award.join("") + } + ]); + } + + 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] + }; + if (!data.userData.achievements.work.achieved) { + data.userData.achievements.work.progress.now += 1; + if (data.userData.achievements.work.progress.now === data.userData.achievements.work.progress.total) { + messageOptions.files = [{ + name: "unlocked.png", + attachment: "./assets/img/achievements/achievement_unlocked1.png" + }]; + data.userData.achievements.work.achieved = true; + } + data.userData.markModified("achievements.work"); + await data.userData.save(); + } + + interaction.reply(messageOptions); + } +} + +module.exports = Work; \ No newline at end of file diff --git a/commands/Fun/8ball.js b/commands/Fun/8ball.js index db98900c..771170c8 100644 --- a/commands/Fun/8ball.js +++ b/commands/Fun/8ball.js @@ -32,7 +32,7 @@ class Eightball extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Fun/lmgtfy.js b/commands/Fun/lmgtfy.js index 7a17b6d4..c84edeaa 100644 --- a/commands/Fun/lmgtfy.js +++ b/commands/Fun/lmgtfy.js @@ -32,7 +32,7 @@ class LMGTFY extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const question = interaction.options.getString("question").replace(/[' '_]/g, "+"); diff --git a/commands/Fun/lovecalc.js b/commands/Fun/lovecalc.js index b01566f7..a5d41144 100644 --- a/commands/Fun/lovecalc.js +++ b/commands/Fun/lovecalc.js @@ -36,7 +36,7 @@ class Lovecalc extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const firstMember = interaction.options.getMember("first_member"); diff --git a/commands/Fun/memes.js b/commands/Fun/memes.js index c274a754..603c5ec7 100644 --- a/commands/Fun/memes.js +++ b/commands/Fun/memes.js @@ -29,7 +29,7 @@ class Memes extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const tags = ["memes", "dankmemes", "me_irl", "wholesomememes"].map(tag => diff --git a/commands/General/activity.js b/commands/General/activity.js index 49c5a865..5fa09154 100644 --- a/commands/General/activity.js +++ b/commands/General/activity.js @@ -29,7 +29,7 @@ class Activity extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; @@ -74,7 +74,7 @@ class Activity extends BaseCommand { const embed = new EmbedBuilder() .setTitle(activity) .setColor(client.config.embed.color) - .setDescription(`**[${interaction.translate("misc:CLICK_HERE", { activity: defaultApplications.find(a => a.id === activity).name, channel: voice.name })}](${invite.code})**`) + .setDescription(`**[${interaction.translate("general/activity:CLICK_HERE", { activity: defaultApplications.find(a => a.id === activity).name, channel: voice.name })}](${invite.code})**`) .setFooter({ text: client.config.embed.footer }) diff --git a/commands/General/afk.js b/commands/General/afk.js index 017fb03b..9a762d3f 100644 --- a/commands/General/afk.js +++ b/commands/General/afk.js @@ -31,7 +31,7 @@ class Afk extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const reason = interaction.options.getString("message"); diff --git a/commands/General/avatar.js b/commands/General/avatar.js index 8f86ccb1..63f7ca6d 100644 --- a/commands/General/avatar.js +++ b/commands/General/avatar.js @@ -30,7 +30,7 @@ class Avatar extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const user = interaction.options.getUser("user") || interaction.user; diff --git a/commands/General/emoji.js b/commands/General/emoji.js index 0743f068..7cb6b314 100644 --- a/commands/General/emoji.js +++ b/commands/General/emoji.js @@ -31,7 +31,7 @@ class Emoji extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const rawEmoji = interaction.options.getString("emoji"); @@ -49,7 +49,7 @@ class Emoji extends BaseCommand { }) .addFields([ { - name: interaction.translate("general/emoji:NAME"), + name: interaction.translate("common:NAME"), value: parsedEmoji.name }, { diff --git a/commands/General/help.js b/commands/General/help.js index f4417603..7c5e394c 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -31,7 +31,7 @@ class Help extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()]; diff --git a/commands/General/minecraft.js b/commands/General/minecraft.js index 95666476..5994278b 100644 --- a/commands/General/minecraft.js +++ b/commands/General/minecraft.js @@ -32,7 +32,7 @@ class Minecraft extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/General/ping.js b/commands/General/ping.js index 8884393d..32adcf23 100644 --- a/commands/General/ping.js +++ b/commands/General/ping.js @@ -28,7 +28,7 @@ class Ping extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { interaction.replyT("general/ping:CONTENT", { diff --git a/commands/General/remindme.js b/commands/General/remindme.js index 10ef342a..d2ca5451 100644 --- a/commands/General/remindme.js +++ b/commands/General/remindme.js @@ -35,7 +35,7 @@ class Remindme extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const time = interaction.options.getString("time"); diff --git a/commands/General/report.js b/commands/General/report.js index fb5d81f2..1fde346f 100644 --- a/commands/General/report.js +++ b/commands/General/report.js @@ -34,7 +34,7 @@ class Report extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const repChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.reports); diff --git a/commands/General/serverinfo.js b/commands/General/serverinfo.js index 5c78e96e..7a39b8c5 100644 --- a/commands/General/serverinfo.js +++ b/commands/General/serverinfo.js @@ -28,7 +28,7 @@ class Serverinfo extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const guild = interaction.guild; diff --git a/commands/General/shorturl.js b/commands/General/shorturl.js index f27110a4..3dd724b5 100644 --- a/commands/General/shorturl.js +++ b/commands/General/shorturl.js @@ -32,7 +32,7 @@ class Shorturl extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const url = interaction.options.getString("url"); diff --git a/commands/General/staff.js b/commands/General/staff.js index 1429ec11..a9947193 100644 --- a/commands/General/staff.js +++ b/commands/General/staff.js @@ -28,7 +28,7 @@ class Staff extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { await interaction.guild.members.fetch(); diff --git a/commands/General/stats.js b/commands/General/stats.js index 9aaab6a8..f8095a07 100644 --- a/commands/General/stats.js +++ b/commands/General/stats.js @@ -29,7 +29,7 @@ class Stats extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const hiddenGuild = await client.guilds.fetch("568120814776614924"); diff --git a/commands/General/suggest.js b/commands/General/suggest.js index 88593755..77ec155c 100644 --- a/commands/General/suggest.js +++ b/commands/General/suggest.js @@ -31,7 +31,7 @@ class Suggest extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const suggChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.suggestions); @@ -43,9 +43,7 @@ class Suggest extends BaseCommand { name: interaction.translate("general/suggest:TITLE", { user: interaction.user.tag }), - iconURL: interaction.member.displayAvatarURL({ - size: 512 - }) + iconURL: interaction.member.displayAvatarURL() }) .addFields([ { diff --git a/commands/General/userinfo.js b/commands/General/userinfo.js index b75c9ca0..112fbe1e 100644 --- a/commands/General/userinfo.js +++ b/commands/General/userinfo.js @@ -30,16 +30,14 @@ class Userinfo extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const member = interaction.options.getMember("user") || interaction.member; const embed = new EmbedBuilder() .setAuthor({ name: `${member.user.tag} (${member.id})`, - iconURL: member.displayAvatarURL({ - size: 512 - }) + iconURL: member.displayAvatarURL() }) .setThumbnail(member.displayAvatarURL({ size: 512 @@ -71,7 +69,7 @@ class Userinfo extends BaseCommand { inline: true }, { - name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOIN"), + name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOINED"), value: client.printDate(member.joinedAt), inline: true }, diff --git a/commands/General/whois.js b/commands/General/whois.js index 21a7fe52..db9f9740 100644 --- a/commands/General/whois.js +++ b/commands/General/whois.js @@ -32,7 +32,7 @@ class Whois extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Moderation/clear.js b/commands/Moderation/clear.js index f7057833..10ab0895 100644 --- a/commands/Moderation/clear.js +++ b/commands/Moderation/clear.js @@ -33,7 +33,7 @@ class Clear extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const option = interaction.options.getString("option"); @@ -84,7 +84,7 @@ class Clear extends BaseCommand { } }); } else { - if (isNaN(option) || parseInt(option) < 1) return interaction.error("moderation/clear:OPTION_NAN", null, { ephemeral: true }); + if (isNaN(option) || parseInt(option) < 1) return interaction.error("misc:OPTION_NAN_ALL", null, { ephemeral: true }); let messages = await interaction.channel.messages.fetch({ limit: option }); @@ -95,12 +95,12 @@ class Clear extends BaseCommand { if (member) { interaction.replyT("moderation/clear:CLEARED_MEMBER", { - amount: `${option} ${client.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`, + amount: `**${option}** ${client.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`, username: member.user.tag }, { ephemeral: true }); } else { interaction.replyT("moderation/clear:CLEARED", { - amount: `${option} ${client.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}` + amount: `**${option}** ${client.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}` }, { ephemeral: true }); } } diff --git a/commands/Moderation/clearwarns.js b/commands/Moderation/clearwarns.js index 358d3d42..bdde63e3 100644 --- a/commands/Moderation/clearwarns.js +++ b/commands/Moderation/clearwarns.js @@ -31,7 +31,7 @@ class Clearwarns extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const member = interaction.options.getMember("user"); diff --git a/commands/Moderation/giveaway.js b/commands/Moderation/giveaway.js index c70d5de9..5537d678 100644 --- a/commands/Moderation/giveaway.js +++ b/commands/Moderation/giveaway.js @@ -39,7 +39,7 @@ class Giveaway extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const options = ["create", "reroll", "delete", "end"].map(tag => diff --git a/commands/Moderation/poll.js b/commands/Moderation/poll.js index 84743d46..6a131c2e 100644 --- a/commands/Moderation/poll.js +++ b/commands/Moderation/poll.js @@ -31,7 +31,7 @@ class Poll extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const question = interaction.options.getString("question"); @@ -40,11 +40,11 @@ class Poll extends BaseCommand { .addComponents( new ButtonBuilder() .setCustomId("poll_everyone") - .setLabel(interaction.translate("moderation/poll:EVERYONE")) + .setLabel("@everyone") .setStyle(ButtonStyle.Primary), new ButtonBuilder() .setCustomId("poll_here") - .setLabel(interaction.translate("moderation/poll:HERE")) + .setLabel("@here") .setStyle(ButtonStyle.Primary), new ButtonBuilder() .setCustomId("poll_nothing") @@ -70,13 +70,13 @@ class Poll extends BaseCommand { collector.on("collect", async i => { if (i.isButton()) { if (i.customId === "poll_everyone") { - mention = "@everyone"; + mention = "||@everyone||"; i.update({ content: interaction.translate("moderation/poll:POLL_SENDED"), components: [] }); } else if (i.customId === "poll_here") { - mention = "@here"; + mention = "||@here||"; i.update({ content: interaction.translate("moderation/poll:POLL_SENDED"), components: [] diff --git a/commands/Moderation/unban.js b/commands/Moderation/unban.js index 9f640c96..11d7b9b4 100644 --- a/commands/Moderation/unban.js +++ b/commands/Moderation/unban.js @@ -31,7 +31,7 @@ class Unban extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const id = interaction.options.getString("user_id"); diff --git a/commands/Moderation/warn.js b/commands/Moderation/warn.js index c8cf6145..67501e13 100644 --- a/commands/Moderation/warn.js +++ b/commands/Moderation/warn.js @@ -28,7 +28,7 @@ class Warn extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").UserContextMenuCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction, data) { const member = interaction.targetMember; @@ -164,7 +164,7 @@ class Warn extends BaseCommand { submitted.reply({ content: interaction.translate("moderation/warn:WARNED", { - username: member.user.tag, + user: member.toString(), reason }) }); diff --git a/commands/Moderation/warns.js b/commands/Moderation/warns.js index 7e0425c0..19124397 100644 --- a/commands/Moderation/warns.js +++ b/commands/Moderation/warns.js @@ -31,7 +31,7 @@ class Warns extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const member = interaction.options.getMember("user"); diff --git a/commands/Music/back.js b/commands/Music/back.js index 2e2ee271..d62c1b75 100644 --- a/commands/Music/back.js +++ b/commands/Music/back.js @@ -28,7 +28,7 @@ class Back extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/clips.js b/commands/Music/clips.js index 98072106..0be17635 100644 --- a/commands/Music/clips.js +++ b/commands/Music/clips.js @@ -30,7 +30,7 @@ class Clips extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { fs.readdir("./clips", async function (err, files) { diff --git a/commands/Music/loop.js b/commands/Music/loop.js index bbc27c2e..ce7e7ab5 100644 --- a/commands/Music/loop.js +++ b/commands/Music/loop.js @@ -29,7 +29,7 @@ class Loop extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/nowplaying.js b/commands/Music/nowplaying.js index 455eb0c8..ba0eec37 100644 --- a/commands/Music/nowplaying.js +++ b/commands/Music/nowplaying.js @@ -29,7 +29,7 @@ class Nowplaying extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Music/play.js b/commands/Music/play.js index 8640b8e3..8f64216e 100644 --- a/commands/Music/play.js +++ b/commands/Music/play.js @@ -32,7 +32,7 @@ class Play extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply(); diff --git a/commands/Music/queue.js b/commands/Music/queue.js index 10bf8454..ac8535f5 100644 --- a/commands/Music/queue.js +++ b/commands/Music/queue.js @@ -28,7 +28,7 @@ class Queue extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const queue = client.player.getQueue(interaction.guildId); diff --git a/commands/Music/skip.js b/commands/Music/skip.js index 8b18b2fb..2a671739 100644 --- a/commands/Music/skip.js +++ b/commands/Music/skip.js @@ -28,7 +28,7 @@ class Skip extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/skipto.js b/commands/Music/skipto.js index 8ea9450f..96bcea7d 100644 --- a/commands/Music/skipto.js +++ b/commands/Music/skipto.js @@ -31,7 +31,7 @@ class Skipto extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/Music/stop.js b/commands/Music/stop.js index f3b2dafa..96e670d5 100644 --- a/commands/Music/stop.js +++ b/commands/Music/stop.js @@ -28,7 +28,7 @@ class Stop extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const voice = interaction.member.voice.channel; diff --git a/commands/NSFW/nsfw.js b/commands/NSFW/nsfw.js index 92e6dde5..523e5735 100644 --- a/commands/NSFW/nsfw.js +++ b/commands/NSFW/nsfw.js @@ -29,7 +29,7 @@ class NSFW extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { if (!interaction.channel.nsfw) return interaction.replyT("misc:NSFW_COMMAND", null, { ephemeral: true }); diff --git a/commands/Owner/announcement.js b/commands/Owner/announcement.js index e41c3579..f4bf9bc9 100644 --- a/commands/Owner/announcement.js +++ b/commands/Owner/announcement.js @@ -13,6 +13,9 @@ class Announcement extends BaseCommand { .setDescription(client.translate("owner/announcement:DESCRIPTION")) .addStringOption(option => option.setName("message") .setDescription(client.translate("common:MESSAGE")) + .setRequired(true)) + .addBooleanOption(option => option.setName("tag") + .setDescription(client.translate("owner/announcement:TAG")) .setRequired(true)), aliases: [], dirname: __dirname, @@ -31,7 +34,7 @@ class Announcement extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); @@ -53,7 +56,7 @@ class Announcement extends BaseCommand { if (guild.id === "568120814776614924") return; const channel = guild.channels.cache.get(guild?.data.plugins.news); await channel.send({ - content: "||@everyone|| ВАЖНОЕ ОБЪЯВЛЕНИЕ!", + content: `${interaction.options.getBoolean("tag") ? "||@everyone|| " : ""}ВАЖНОЕ ОБЪЯВЛЕНИЕ!`, embeds: [embed] }); }); diff --git a/commands/Owner/debug.js b/commands/Owner/debug.js index b5c11f04..20c6e6ab 100644 --- a/commands/Owner/debug.js +++ b/commands/Owner/debug.js @@ -21,7 +21,7 @@ class Debug extends BaseCommand { { name: client.translate("common:XP"), value: "xp" }, { name: client.translate("common:CREDITS"), value: "credits" }, { name: client.translate("economy/transactions:BANK"), value: "bank" }, - { name: client.translate("common:REP"), value: "rep" }, + { name: client.translate("common:REP"), value: "rep" } )) .addUserOption(option => option.setName("user") .setDescription(client.translate("common:USER")) @@ -40,7 +40,7 @@ class Debug extends BaseCommand { { name: client.translate("common:XP"), value: "xp" }, { name: client.translate("common:CREDITS"), value: "credits" }, { name: client.translate("economy/transactions:BANK"), value: "bank" }, - { name: client.translate("common:REP"), value: "rep" }, + { name: client.translate("common:REP"), value: "rep" } )) .addUserOption(option => option.setName("user") .setDescription(client.translate("common:USER")) @@ -68,56 +68,62 @@ class Debug extends BaseCommand { * @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {Array} data */ - async execute(client, interaction, data) { + async execute(client, interaction,) { const command = interaction.options.getSubcommand(); if (command === "set") { const type = interaction.options.getString("type"); const member = interaction.options.getMember("user"); if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); + const userData = await client.findOrCreateUser({ + id: member.id + }); + const memberData = await client.findOrCreateMember({ + id: member.id + }); const int = interaction.options.getInteger("int"); switch (type) { case "level": { - data.memberData.level = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.level = int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "xp": { - data.memberData.exp = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.exp = int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "credits": { - data.memberData.money = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.money = int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "bank": { - data.memberData.bankSold = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.bankSold = int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "rep": { - data.memberData.rep = int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + userData.rep = int; + await userData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); @@ -127,49 +133,55 @@ class Debug extends BaseCommand { const type = interaction.options.getString("type"); const member = interaction.options.getMember("target"); if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); + const userData = await client.findOrCreateUser({ + id: member.id + }); + const memberData = await client.findOrCreateMember({ + id: member.id + }); const int = interaction.options.getInteger("int"); switch (type) { case "level": { - data.memberData.level += int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.level += int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "xp": { - data.memberData.exp += int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.exp += int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "credits": { - data.memberData.money += int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.money += int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "bank": { - data.memberData.bankSold += int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + memberData.bankSold += int; + await memberData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); } case "rep": { - data.memberData.rep += int; - await data.memberData.save(); - return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { + userData.rep += int; + await userData.save(); + return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { username: member.toString(), amount: int }, { ephemeral: true }); diff --git a/commands/Owner/eval.js b/commands/Owner/eval.js index 505c187e..f5113a6c 100644 --- a/commands/Owner/eval.js +++ b/commands/Owner/eval.js @@ -31,14 +31,14 @@ class Eval extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ // eslint-disable-next-line no-unused-vars async execute(client, interaction, data) { const code = interaction.options.getString("code"); - const result = new Promise((resolve) => resolve(eval(code))); + const result = new Promise(resolve => resolve(eval(code))); - return result.then((output) => { + return result.then(output => { if (typeof output != "string") output = require("util").inspect(output, { depth: 0 }); if (output.includes(client.token)) output = output.replace(client.token, "T0K3N"); @@ -46,7 +46,7 @@ class Eval extends BaseCommand { content: "```js\n" + output + "```", ephemeral: true }); - }).catch((err) => { + }).catch(err => { console.error(err); err = err.toString(); diff --git a/commands/Owner/reload.js b/commands/Owner/reload.js index 2f1fa425..7eb020f4 100644 --- a/commands/Owner/reload.js +++ b/commands/Owner/reload.js @@ -33,12 +33,12 @@ class Reload extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { const command = interaction.options.getString("command"); const cmd = client.commands.get(command); - if (!cmd) return interaction.error("general/help:NOT_FOUND", { search: command }, { ephemeral: true }); + if (!cmd) return interaction.error("owner/reload:NOT_FOUND", { search: command }, { ephemeral: true }); await client.unloadCommand(`../commands/${cmd.category}`, cmd.command.name); await client.loadCommand(`../commands/${cmd.category}`, cmd.command.name); diff --git a/commands/Owner/say.js b/commands/Owner/say.js index 68ce38e5..41df8370 100644 --- a/commands/Owner/say.js +++ b/commands/Owner/say.js @@ -33,7 +33,7 @@ class Say extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { await interaction.deferReply({ ephemeral: true }); diff --git a/commands/Owner/servers.js b/commands/Owner/servers.js index cc2d34dc..53e46b8f 100644 --- a/commands/Owner/servers.js +++ b/commands/Owner/servers.js @@ -28,7 +28,7 @@ class Servers extends BaseCommand { * * @param {import("../../base/JaBa")} client * @param {import("discord.js").ChatInputCommandInteraction} interaction - * @param {Array} data + * @param {Object} data */ async execute(client, interaction) { let i0 = 0, diff --git a/dashboard/public/docs/updates.md b/dashboard/public/docs/updates.md index 42c2c568..bb52c927 100644 --- a/dashboard/public/docs/updates.md +++ b/dashboard/public/docs/updates.md @@ -1,3 +1,16 @@ +### JaBa v4.0 +* Добавлено + * Перенесены все категории. + * Команда *setnews* - настроить канал для новостей бота (только самые важные). + * Настройка канала новостей бота в панели управления. + +* Изменения + * Команды *deposit* и *withdraw* заменены командой *bank*. + +* Исправления + * Поправлены все фразы в стандартной локализации. + * Правка локализации в панели управления. + ### JaBa v4.0pre5 * Добавлено * Перенесена категория *Administration*. diff --git a/dashboard/views/manager/guild.ejs b/dashboard/views/manager/guild.ejs index e3a9b467..e5f0f14a 100644 --- a/dashboard/views/manager/guild.ejs +++ b/dashboard/views/manager/guild.ejs @@ -18,7 +18,7 @@
-

<%= translate("common:CONFIGURATION") %> Dashboard v1.1

+

<%= translate("common:SETTINGS") %> Dashboard v1.1