From b258fbf6e6d247dca595b9e0a480ec9b63aae832 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Mon, 8 Aug 2022 18:19:56 +0500 Subject: [PATCH] v4.0pre5 --- .../Economy/achievements.js | 0 .../Economy/birthdate.js | 0 .../Economy/deposit.js | 0 .../Economy/divorce.js | 0 .../Economy/horserace.js | 0 .../Economy/importmee6.js | 0 .../Economy/leaderboard.js | 0 {TO REWRITE => !TO REWRITE}/Economy/marry.js | 2 +- {TO REWRITE => !TO REWRITE}/Economy/money.js | 0 {TO REWRITE => !TO REWRITE}/Economy/number.js | 2 +- {TO REWRITE => !TO REWRITE}/Economy/pay.js | 0 .../Economy/profile.js | 2 +- {TO REWRITE => !TO REWRITE}/Economy/rep.js | 0 {TO REWRITE => !TO REWRITE}/Economy/rob.js | 0 {TO REWRITE => !TO REWRITE}/Economy/setbio.js | 0 {TO REWRITE => !TO REWRITE}/Economy/slots.js | 0 .../Economy/tictactoe.js | 0 .../Economy/transactions.js | 0 .../Economy/withdraw.js | 0 {TO REWRITE => !TO REWRITE}/Economy/work.js | 0 {TO REWRITE => !TO REWRITE}/seek.js | 0 .gitignore | 13 +- TO REWRITE/Administration/addemoji.js | 38 ------ TO REWRITE/Administration/automod.js | 55 --------- TO REWRITE/Administration/autorole.js | 59 --------- TO REWRITE/Administration/configuration.js | 103 ---------------- TO REWRITE/Administration/deletemod.js | 35 ------ TO REWRITE/Administration/goodbye.js | 107 ---------------- TO REWRITE/Administration/set.js | 57 --------- TO REWRITE/Administration/setbirthdays.js | 44 ------- TO REWRITE/Administration/setlang.js | 33 ----- TO REWRITE/Administration/setmodlogs.js | 44 ------- TO REWRITE/Administration/setnews.js | 44 ------- TO REWRITE/Administration/setreports.js | 44 ------- TO REWRITE/Administration/setsuggests.js | 44 ------- TO REWRITE/Administration/welcome.js | 110 ----------------- commands/Administration/automod.js | 72 +++++++++++ commands/Administration/autorole.js | 74 +++++++++++ commands/Administration/config.js | 115 ++++++++++++++++++ commands/Administration/deletemod.js | 45 +++++++ commands/Administration/goodbye.js | 90 ++++++++++++++ commands/Administration/set.js | 106 ++++++++++++++++ commands/Administration/setbirthdays.js | 61 ++++++++++ commands/Administration/setlang.js | 53 ++++++++ commands/Administration/setmodlogs.js | 61 ++++++++++ commands/Administration/setnews.js | 61 ++++++++++ commands/Administration/setreports.js | 61 ++++++++++ commands/Administration/setsuggests.js | 61 ++++++++++ commands/Administration/welcome.js | 90 ++++++++++++++ commands/Fun/memes.js | 2 +- commands/General/help.js | 2 +- commands/General/serverinfo.js | 8 +- commands/Moderation/giveaway.js | 2 +- commands/Moderation/warn.js | 8 +- commands/Music/loop.js | 9 +- commands/Music/nowplaying.js | 5 +- commands/Music/skipto.js | 4 +- commands/NSFW/nsfw.js | 2 +- commands/Owner/debug.js | 32 ++--- dashboard/public/docs/updates.md | 9 ++ dashboard/routes/guild-manager.js | 27 ++-- dashboard/views/manager/guild.ejs | 70 +++++++---- events/Guild/guildMemberAdd.js | 3 +- events/Guild/guildMemberRemove.js | 3 +- events/MessageHandler.js | 4 +- helpers/functions.js | 4 +- helpers/tictactoe.js | 22 ++-- languages/ru-RU/administration/addemoji.json | 10 -- languages/ru-RU/administration/autorole.json | 11 +- .../{configuration.json => config.json} | 25 ++-- languages/ru-RU/administration/deletemod.json | 3 +- languages/ru-RU/administration/goodbye.json | 16 ++- languages/ru-RU/administration/set.json | 11 +- .../ru-RU/administration/setbirthdays.json | 6 +- languages/ru-RU/administration/setnews.json | 4 +- languages/ru-RU/administration/welcome.json | 16 +-- languages/ru-RU/common.json | 13 +- languages/ru-RU/dashboard.json | 6 + languages/ru-RU/economy/tictactoe.json | 2 - languages/ru-RU/moderation/warn.json | 2 +- languages/ru-RU/music/nowplaying.json | 4 +- languages/uk-UA/administration/autorole.json | 2 +- languages/uk-UA/administration/goodbye.json | 2 +- languages/uk-UA/administration/welcome.json | 2 +- package-lock.json | 4 +- package.json | 2 +- 86 files changed, 1137 insertions(+), 1006 deletions(-) rename {TO REWRITE => !TO REWRITE}/Economy/achievements.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/birthdate.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/deposit.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/divorce.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/horserace.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/importmee6.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/leaderboard.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/marry.js (98%) rename {TO REWRITE => !TO REWRITE}/Economy/money.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/number.js (95%) rename {TO REWRITE => !TO REWRITE}/Economy/pay.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/profile.js (99%) rename {TO REWRITE => !TO REWRITE}/Economy/rep.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/rob.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/setbio.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/slots.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/tictactoe.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/transactions.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/withdraw.js (100%) rename {TO REWRITE => !TO REWRITE}/Economy/work.js (100%) rename {TO REWRITE => !TO REWRITE}/seek.js (100%) delete mode 100644 TO REWRITE/Administration/addemoji.js delete mode 100644 TO REWRITE/Administration/automod.js delete mode 100644 TO REWRITE/Administration/autorole.js delete mode 100644 TO REWRITE/Administration/configuration.js delete mode 100644 TO REWRITE/Administration/deletemod.js delete mode 100644 TO REWRITE/Administration/goodbye.js delete mode 100644 TO REWRITE/Administration/set.js delete mode 100644 TO REWRITE/Administration/setbirthdays.js delete mode 100644 TO REWRITE/Administration/setlang.js delete mode 100644 TO REWRITE/Administration/setmodlogs.js delete mode 100644 TO REWRITE/Administration/setnews.js delete mode 100644 TO REWRITE/Administration/setreports.js delete mode 100644 TO REWRITE/Administration/setsuggests.js delete mode 100644 TO REWRITE/Administration/welcome.js create mode 100644 commands/Administration/automod.js create mode 100644 commands/Administration/autorole.js create mode 100644 commands/Administration/config.js create mode 100644 commands/Administration/deletemod.js create mode 100644 commands/Administration/goodbye.js create mode 100644 commands/Administration/set.js create mode 100644 commands/Administration/setbirthdays.js create mode 100644 commands/Administration/setlang.js create mode 100644 commands/Administration/setmodlogs.js create mode 100644 commands/Administration/setnews.js create mode 100644 commands/Administration/setreports.js create mode 100644 commands/Administration/setsuggests.js create mode 100644 commands/Administration/welcome.js delete mode 100644 languages/ru-RU/administration/addemoji.json rename languages/ru-RU/administration/{configuration.json => config.json} (68%) diff --git a/TO REWRITE/Economy/achievements.js b/!TO REWRITE/Economy/achievements.js similarity index 100% rename from TO REWRITE/Economy/achievements.js rename to !TO REWRITE/Economy/achievements.js diff --git a/TO REWRITE/Economy/birthdate.js b/!TO REWRITE/Economy/birthdate.js similarity index 100% rename from TO REWRITE/Economy/birthdate.js rename to !TO REWRITE/Economy/birthdate.js diff --git a/TO REWRITE/Economy/deposit.js b/!TO REWRITE/Economy/deposit.js similarity index 100% rename from TO REWRITE/Economy/deposit.js rename to !TO REWRITE/Economy/deposit.js diff --git a/TO REWRITE/Economy/divorce.js b/!TO REWRITE/Economy/divorce.js similarity index 100% rename from TO REWRITE/Economy/divorce.js rename to !TO REWRITE/Economy/divorce.js diff --git a/TO REWRITE/Economy/horserace.js b/!TO REWRITE/Economy/horserace.js similarity index 100% rename from TO REWRITE/Economy/horserace.js rename to !TO REWRITE/Economy/horserace.js diff --git a/TO REWRITE/Economy/importmee6.js b/!TO REWRITE/Economy/importmee6.js similarity index 100% rename from TO REWRITE/Economy/importmee6.js rename to !TO REWRITE/Economy/importmee6.js diff --git a/TO REWRITE/Economy/leaderboard.js b/!TO REWRITE/Economy/leaderboard.js similarity index 100% rename from TO REWRITE/Economy/leaderboard.js rename to !TO REWRITE/Economy/leaderboard.js diff --git a/TO REWRITE/Economy/marry.js b/!TO REWRITE/Economy/marry.js similarity index 98% rename from TO REWRITE/Economy/marry.js rename to !TO REWRITE/Economy/marry.js index 2ad02c54..7b9bf1bd 100644 --- a/TO REWRITE/Economy/marry.js +++ b/!TO REWRITE/Economy/marry.js @@ -20,7 +20,7 @@ class Marry extends Command { } async run(message, args, data) { - if (data.userData.lover) return message.error("economy/marry:ALREADY_MARRIED", { prefix: data.guild.prefix }); + 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"); diff --git a/TO REWRITE/Economy/money.js b/!TO REWRITE/Economy/money.js similarity index 100% rename from TO REWRITE/Economy/money.js rename to !TO REWRITE/Economy/money.js diff --git a/TO REWRITE/Economy/number.js b/!TO REWRITE/Economy/number.js similarity index 95% rename from TO REWRITE/Economy/number.js rename to !TO REWRITE/Economy/number.js index 333b35af..4a22f0c8 100644 --- a/TO REWRITE/Economy/number.js +++ b/!TO REWRITE/Economy/number.js @@ -54,7 +54,7 @@ class Number extends Command { participants: participants.map(p => `<@${p}>`).join(", ") }); - if (participants.length > 1 && data.guild.disabledCategories && !data.guild.disabledCategories.includes("Economy")) { + if (participants.length > 1 && data.guildData.disabledCategories && !data.guildData.disabledCategories.includes("Economy")) { const won = 100 * (participants.length * 0.5); message.sendT("economy/number:WON", { diff --git a/TO REWRITE/Economy/pay.js b/!TO REWRITE/Economy/pay.js similarity index 100% rename from TO REWRITE/Economy/pay.js rename to !TO REWRITE/Economy/pay.js diff --git a/TO REWRITE/Economy/profile.js b/!TO REWRITE/Economy/profile.js similarity index 99% rename from TO REWRITE/Economy/profile.js rename to !TO REWRITE/Economy/profile.js index 93c3db44..7cf3b353 100644 --- a/TO REWRITE/Economy/profile.js +++ b/!TO REWRITE/Economy/profile.js @@ -119,7 +119,7 @@ class Profile extends Command { { name: message.translate("economy/profile:ACHIEVEMENTS"), value: message.translate("economy/profile:ACHIEVEMENTS_CONTENT", { - prefix: data.guild.prefix + prefix: data.guildData.prefix }) } ]) diff --git a/TO REWRITE/Economy/rep.js b/!TO REWRITE/Economy/rep.js similarity index 100% rename from TO REWRITE/Economy/rep.js rename to !TO REWRITE/Economy/rep.js diff --git a/TO REWRITE/Economy/rob.js b/!TO REWRITE/Economy/rob.js similarity index 100% rename from TO REWRITE/Economy/rob.js rename to !TO REWRITE/Economy/rob.js diff --git a/TO REWRITE/Economy/setbio.js b/!TO REWRITE/Economy/setbio.js similarity index 100% rename from TO REWRITE/Economy/setbio.js rename to !TO REWRITE/Economy/setbio.js diff --git a/TO REWRITE/Economy/slots.js b/!TO REWRITE/Economy/slots.js similarity index 100% rename from TO REWRITE/Economy/slots.js rename to !TO REWRITE/Economy/slots.js diff --git a/TO REWRITE/Economy/tictactoe.js b/!TO REWRITE/Economy/tictactoe.js similarity index 100% rename from TO REWRITE/Economy/tictactoe.js rename to !TO REWRITE/Economy/tictactoe.js diff --git a/TO REWRITE/Economy/transactions.js b/!TO REWRITE/Economy/transactions.js similarity index 100% rename from TO REWRITE/Economy/transactions.js rename to !TO REWRITE/Economy/transactions.js diff --git a/TO REWRITE/Economy/withdraw.js b/!TO REWRITE/Economy/withdraw.js similarity index 100% rename from TO REWRITE/Economy/withdraw.js rename to !TO REWRITE/Economy/withdraw.js diff --git a/TO REWRITE/Economy/work.js b/!TO REWRITE/Economy/work.js similarity index 100% rename from TO REWRITE/Economy/work.js rename to !TO REWRITE/Economy/work.js diff --git a/TO REWRITE/seek.js b/!TO REWRITE/seek.js similarity index 100% rename from TO REWRITE/seek.js rename to !TO REWRITE/seek.js diff --git a/.gitignore b/.gitignore index 3c363b0d..5c041d8b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,25 +1,18 @@ # Bot Configuration -config.js +/config.js # DB -giveaways.json - -# Backups -backups +/giveaways.json # commands.md **/commands.md # Clips -clips +/clips # Mac OS files .DS_Store -# PM2 -report*.json -!languages/**/general/report.json - # IDE .vscode diff --git a/TO REWRITE/Administration/addemoji.js b/TO REWRITE/Administration/addemoji.js deleted file mode 100644 index e16706a7..00000000 --- a/TO REWRITE/Administration/addemoji.js +++ /dev/null @@ -1,38 +0,0 @@ -const Command = require("../../base/Command"); - -class Addemoji extends Command { - constructor(client) { - super(client, { - name: "addemoji", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["adde"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args) { - const url = args[0]; - if (!url) return message.error("administration/addemoji:MISSING_URL"); - - const name = args[1] ? args[1].replace(/[^a-z0-9]/gi, "") : null; - if (!name) return message.error("administration/addemoji:MISSING_NAME"); - if (name.length < 2 || name.length > 32) return message.error("administration/addemoji:INVALID_NAME"); - - message.guild.emojis - .create(url, name) - .then(emoji => message.success("administration/addemoji:SUCCESS", { - emoji: emoji.name - })) - .catch(() => message.error("administration/addemoji:ERROR", { - emoji: name - })); - } -} - -module.exports = Addemoji; \ No newline at end of file diff --git a/TO REWRITE/Administration/automod.js b/TO REWRITE/Administration/automod.js deleted file mode 100644 index c19365bd..00000000 --- a/TO REWRITE/Administration/automod.js +++ /dev/null @@ -1,55 +0,0 @@ -const Command = require("../../base/Command"); - -class Automod extends Command { - constructor(client) { - super(client, { - name: "automod", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["autom"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const status = args[0]; - if (!status || (status !== "on" && status !== "off")) return message.error("administration/automod:MISSING_STATUS"); - - if (status === "on") { - data.guild.plugins.automod = { - enabled: true, - ignored: [] - }; - data.guild.markModified("plugins.automod"); - data.guild.save(); - message.success("administration/automod:ENABLED", { - prefix: data.guild.prefix - }); - } else if (status === "off") { - if (message.mentions.channels.filter((ch) => ch.type === "GUILD_TEXT" && ch.guild.id === message.guild.id).first()) { - const channel = message.mentions.channels.first(); - data.guild.plugins.automod.ignored.push(channel); - data.guild.markModified("plugins.automod"); - data.guild.save(); - message.success("administration/automod:DISABLED_CHANNEL", { - channel: channel.toString() - }); - } else { - data.guild.plugins.automod = { - enabled: false, - ignored: [] - }; - data.guild.markModified("plugins.automod"); - data.guild.save(); - message.success("administration/automod:DISABLED"); - } - } - } -} - -module.exports = Automod; \ No newline at end of file diff --git a/TO REWRITE/Administration/autorole.js b/TO REWRITE/Administration/autorole.js deleted file mode 100644 index 2945f2bb..00000000 --- a/TO REWRITE/Administration/autorole.js +++ /dev/null @@ -1,59 +0,0 @@ -const Command = require("../../base/Command"); - -class Autorole extends Command { - constructor(client) { - super(client, { - name: "autorole", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["autor"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const status = args[0]; - if (status !== "on" && status !== "off") return message.error("administration/autorole:MISSING_STATUS"); - - if (status === "on") { - const role = await Resolvers.resolveRole({ - message, - search: args.slice(1).join(" ") - }); - if (!role) return message.error("administration/autorole:MISSING_ROLE"); - - data.guild.plugins.autorole = { - enabled: true, - role: role.id - }; - data.guild.markModified("plugins.autorole"); - await data.guild.save(); - - message.success("administration/autorole:SUCCESS_ENABLED", { - roleName: role.name - }); - } else if (status === "off") { - if (!data.guild.plugins.autorole.enabled) return message.success("administration/autorole:ALREADY_DISABLED", { - prefix: data.guild.prefix - }); - - data.guild.plugins.autorole = { - enabled: false, - role: null - }; - data.guild.markModified("plugins.autorole"); - await data.guild.save(); - - message.success("administration/autorole:SUCCESS_DISABLED", { - prefix: data.guild.prefix - }); - } - } -} - -module.exports = Autorole; \ No newline at end of file diff --git a/TO REWRITE/Administration/configuration.js b/TO REWRITE/Administration/configuration.js deleted file mode 100644 index 4fa10126..00000000 --- a/TO REWRITE/Administration/configuration.js +++ /dev/null @@ -1,103 +0,0 @@ -const Command = require("../../base/Command"), - Discord = require("discord.js"); - -class Configuration extends Command { - constructor(client) { - super(client, { - name: "configuration", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["conf", "config"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args, data) { - const guildData = data.guild; - - const embed = new Discord.EmbedBuilder() - .setAuthor({ - name: message.guild.name, - iconURL: message.guild.iconURL() - }) - .setColor(data.config.embed.color) - .setFooter({ - text: data.config.embed.footer - }); - - embed.addFields([ - { // Ignored channels - name: message.translate("administration/configuration:IGNORED_CHANNELS_TITLE"), - value: guildData.ignoredChannels.length > 0 ? guildData.ignoredChannels.map((ch) => `<#${ch}>`).join(", ") : message.translate("administration/configuration:NO_IGNORED_CHANNELS") - }, - { // Autorole plugin - name: message.translate("administration/configuration:AUTOROLE_TITLE"), - value: guildData.plugins.autorole.enabled ? message.translate("administration/configuration:AUTOROLE_CONTENT", { - roleName: `<@&${guildData.plugins.autorole.role}>` - }) : message.translate("administration/configuration:AUTOROLE_DISABLED") - }, - { // Welcome plugin - name: message.translate("administration/configuration:WELCOME_TITLE"), - value: guildData.plugins.welcome.enabled ? message.translate("administration/configuration:WELCOME_CONTENT", { - channel: `<#${guildData.plugins.welcome.channel}>`, - withImage: guildData.plugins.welcome.withImage ? message.translate("common:YES") : message.translate("common:NO") - }) : message.translate("administration/configuration:WELCOME_DISABLED") - }, - { // Goodbye plugin - name: message.translate("administration/configuration:GOODBYE_TITLE"), - value: guildData.plugins.goodbye.enabled ? message.translate("administration/configuration:GOODBYE_CONTENT", { - channel: `<#${guildData.plugins.goodbye.channel}>`, - withImage: guildData.plugins.goodbye.withImage ? message.translate("common:YES") : message.translate("common:NO") - }) : message.translate("administration/configuration:GOODBYE_DISABLED") - }, - { // Special channels - name: message.translate("administration/configuration:SPECIAL_CHANNELS"), - value: message.translate("administration/configuration:SUGGESTIONS", { - channel: guildData.plugins.suggestions ? `<#${guildData.plugins.suggestions}>` : message.translate("common:NOT_DEFINED") - }) + "\n" + - message.translate("administration/configuration:REPORTS", { - channel: guildData.plugins.reports ? `<#${guildData.plugins.reports}>` : message.translate("common:NOT_DEFINED") - }) + "\n" + - message.translate("administration/configuration:MODLOGS", { - channel: guildData.plugins.modlogs ? `<#${guildData.plugins.modlogs}>` : message.translate("common:NOT_DEFINED") - }) + "\n" + - message.translate("administration/configuration:BIRTHDAYS", { - channel: guildData.plugins.birthdays ? `<#${guildData.plugins.birthdays}>` : message.translate("common:NOT_DEFINED") - }) - }, - { // Auto sanctions - name: message.translate("administration/configuration:AUTO_SANCTIONS"), - value: (guildData.plugins.warnsSanctions.kick ? message.translate("administration/configuration:KICK_CONTENT", { - count: guildData.plugins.warnsSanctions.kick - }) : message.translate("administration/configuration:KICK_NOT_DEFINED")) + "\n" + (guildData.plugins.warnsSanctions.ban ? message.translate("administration/configuration:BAN_CONTENT", { - count: guildData.plugins.warnsSanctions.ban - }) : message.translate("administration/configuration:BAN_NOT_DEFINED")) - }, - { // Automod plugin - name: message.translate("administration/configuration:AUTOMOD_TITLE"), - value: guildData.plugins.automod.enabled ? message.translate("administration/configuration:AUTOMOD_CONTENT", { - channels: guildData.plugins.automod.ignored.map((ch) => `<#${ch}>`) - }) : message.translate("administration/configuration:AUTOMOD_DISABLED") - }, - { // Auto-delete mod commands - name: message.translate("administration/configuration:AUTODELETEMOD"), - value: guildData.autoDeleteModCommands ? message.translate("administration/configuration:AUTODELETEMOD_ENABLED") : message.translate("administration/configuration:AUTODELETEMOD_DISABLED") - }, - { // Dashboard link - name: message.translate("administration/configuration:DASHBOARD_TITLE"), - value: `[${message.translate("administration/configuration:DASHBOARD_CONTENT")}](${data.config.dashboard.baseURL})` - } - ]); - - message.reply({ - embeds: [embed] - }); - } -} - -module.exports = Configuration; \ No newline at end of file diff --git a/TO REWRITE/Administration/deletemod.js b/TO REWRITE/Administration/deletemod.js deleted file mode 100644 index ce4c9500..00000000 --- a/TO REWRITE/Administration/deletemod.js +++ /dev/null @@ -1,35 +0,0 @@ -const Command = require("../../base/Command"); - -class Deletemod extends Command { - constructor(client) { - super(client, { - name: "deletemod", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["delm"], - memberPermissions: ["MANAGE_MESSAGES"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const status = args[0]; - if (!status || status !== "on" && status !== "off") return message.error("administration/deletemod:MISSING_STATUS"); - - if (status === "on") { - data.guild.autoDeleteModCommands = true; - data.guild.save(); - message.success("administration/deletemod:ENABLED"); - } else { - data.guild.autoDeleteModCommands = false; - data.guild.save(); - message.success("administration/deletemod:DISABLED"); - } - } -} - -module.exports = Deletemod; \ No newline at end of file diff --git a/TO REWRITE/Administration/goodbye.js b/TO REWRITE/Administration/goodbye.js deleted file mode 100644 index 75530c8f..00000000 --- a/TO REWRITE/Administration/goodbye.js +++ /dev/null @@ -1,107 +0,0 @@ -const Command = require("../../base/Command"); - -class Goodbye extends Command { - constructor(client) { - super(client, { - name: "goodbye", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["gb"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - if (args[0] === "test" && data.guild.plugins.goodbye.enabled) { - this.client.emit("guildMemberRemove", message.member); - return message.success("administration/goodbye:TEST_SUCCESS"); - } - - if ((!args[0] || !["edit", "off"].includes(args[0])) && data.guild.plugins.goodbye.enabled) return message.error("administration/goodbye:MISSING_STATUS"); - - if (args[0] === "off") { - data.guild.plugins.goodbye = { - enabled: false, - message: null, - channelID: null, - withImage: null - }; - data.guild.markModified("plugins.goodbye"); - data.guild.save(); - return message.error("administration/goodbye:DISABLED", { - prefix: data.guild.prefix - }); - } else { - const goodbye = { - enabled: true, - channel: null, - message: null, - withImage: null, - }; - - message.sendT("administration/goodbye:FORM_1", { - author: message.author.toString() - }); - - const filter = m => m.author.id === message.author.id; - const collector = message.channel.createMessageCollector({ - filter, - time: 120000 // 2 minutes - }); - - collector.on("collect", async msg => { - // If the message is filled, it means the user sent yes or no for the image - if (goodbye.message) { - if (msg.content.toLowerCase() === message.translate("common:YES").toLowerCase()) goodbye.withImage = true; - else if (msg.content.toLowerCase() === message.translate("common:NO").toLowerCase()) goodbye.withImage = false; - else return message.error("misc:INVALID_YES_NO"); - - data.guild.plugins.goodbye = goodbye; - data.guild.markModified("plugins.goodbye"); - await data.guild.save(); - message.sendT("administration/goodbye:FORM_SUCCESS", { - prefix: data.guild.prefix, - channel: `<#${goodbye.channel}>` - }); - return collector.stop(); - } - - // If the channel is filled and the message is not, it means the user sent the message - if (goodbye.channel && !goodbye.message) { - if (msg.content.length < 1800) { - goodbye.message = msg.content; - return message.sendT("administration/goodbye:FORM_3"); - } - return message.error("administration/goodbye:MAX_CHARACT"); - } - - // If the channel is not filled, it means the user sent it - if (!goodbye.channel) { - const channel = await Resolvers.resolveChannel({ - message: msg, - channelType: "GUILD_TEXT" - }); - if (!channel) return message.error("misc:INVALID_CHANNEL"); - - goodbye.channel = channel.id; - return message.sendT("administration/goodbye:FORM_2", { - channel: channel.toString(), - author: msg.author.tag, - memberCount: msg.guild.memberCount - }); - } - }); - - collector.on("end", (_, reason) => { - if (reason === "time") return message.error("misc:TIMES_UP"); - }); - } - } -} - -module.exports = Goodbye; \ No newline at end of file diff --git a/TO REWRITE/Administration/set.js b/TO REWRITE/Administration/set.js deleted file mode 100644 index 013784b5..00000000 --- a/TO REWRITE/Administration/set.js +++ /dev/null @@ -1,57 +0,0 @@ -const Command = require("../../base/Command"); - -class Set extends Command { - constructor(client) { - super(client, { - name: "set", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: [], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES"], - nsfw: false, - ownerOnly: false, - cooldown: 2000 - }); - } - - async run(message, args) { - const status = args[0]; - if (!status || !["level", "xp", "credits", "bank"].includes(status)) return message.error("administration/set:NO_STATUS"); - - const member = await this.client.resolveMember(args[1], message.guild); - if (!member) return message.error("administration/set:INVALID_MEMBER"); - if (member.user.bot) return message.error("administration/set:BOT_USER"); - - const number = args[2]; - if (!number || isNaN(number) || parseInt(number, 10) < 0) return message.error("administration/set:INVALID_AMOUNT"); - const amount = Math.ceil(parseInt(number, 10)); - - const memberData = await this.client.findOrCreateMember({ - id: member.id, - guildID: message.guild.id - }); - - if (status === "level") { - memberData.level = parseInt(amount, 10); - memberData.save(); - } else if (status === "xp") { - memberData.exp = parseInt(amount, 10); - memberData.save(); - } else if (status === "credits") { - memberData.money = parseInt(amount, 10); - memberData.save(); - } else if (status === "bank") { - memberData.bankSold = parseInt(amount, 10); - memberData.save(); - } - - message.success("administration/set:SUCCESS_" + status.toUpperCase(), { - username: member.user.tag, - amount - }); - } -} - -module.exports = Set; \ No newline at end of file diff --git a/TO REWRITE/Administration/setbirthdays.js b/TO REWRITE/Administration/setbirthdays.js deleted file mode 100644 index f5ace784..00000000 --- a/TO REWRITE/Administration/setbirthdays.js +++ /dev/null @@ -1,44 +0,0 @@ -const Command = require("../../base/Command"); - -class Setbirthdays extends Command { - constructor(client) { - super(client, { - name: "setbirthdays", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["setb"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const areBirthdaysEnabled = Boolean(data.guild.plugins.birthdays); - const sentChannel = await Resolvers.resolveChannel({ - message, - search: args.join(" "), - channelType: "GUILD_TEXT" - }); - - if (!sentChannel && areBirthdaysEnabled) { - data.guild.plugins.birthdays = null; - data.guild.markModified("plugins.birthdays"); - await data.guild.save(); - return message.success("administration/setbirthdays:DISABLED"); - } else { - const channel = sentChannel || message.channel; - data.guild.plugins.birthdays = channel.id; - data.guild.markModified("plugins.birthdays"); - await data.guild.save(); - return message.success("administration/setbirthdays:ENABLED", { - channel: channel.toString() - }); - } - } -} - -module.exports = Setbirthdays; \ No newline at end of file diff --git a/TO REWRITE/Administration/setlang.js b/TO REWRITE/Administration/setlang.js deleted file mode 100644 index 9c092c77..00000000 --- a/TO REWRITE/Administration/setlang.js +++ /dev/null @@ -1,33 +0,0 @@ -const Command = require("../../base/Command"); - -class Setlang extends Command { - constructor(client) { - super(client, { - name: "setlang", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["setl"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const language = this.client.languages.find((l) => l.name === args[0] || l.aliases.includes(args[0])); - - if (!args[0] || !language) return message.error("administration/setlang:MISSING_LANG", { list: this.client.languages.map((l) => `\`${l.name} (${l.aliases.slice(0, 2).join(", ")})\``).join(", ") }); - - data.guild.language = language.name; - await data.guild.save(); - - return message.sendT("administration/setlang:SUCCESS", { - lang: language.nativeName - }); - } -} - -module.exports = Setlang; \ No newline at end of file diff --git a/TO REWRITE/Administration/setmodlogs.js b/TO REWRITE/Administration/setmodlogs.js deleted file mode 100644 index 2fb8b3d6..00000000 --- a/TO REWRITE/Administration/setmodlogs.js +++ /dev/null @@ -1,44 +0,0 @@ -const Command = require("../../base/Command"); - -class Setmodlogs extends Command { - constructor(client) { - super(client, { - name: "setmodlogs", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["setm"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const areModLogsEnabled = Boolean(data.guild.plugins.modlogs); - const sentChannel = await Resolvers.resolveChannel({ - message, - search: args.join(" "), - channelType: "GUILD_TEXT" - }); - - if (!sentChannel && areModLogsEnabled) { - data.guild.plugins.modlogs = null; - data.guild.markModified("plugins.modlogs"); - await data.guild.save(); - return message.success("administration/setmodlogs:DISABLED"); - } else { - const channel = sentChannel || message.channel; - data.guild.plugins.modlogs = channel.id; - data.guild.markModified("plugins.modlogs"); - await data.guild.save(); - return message.success("administration/setmodlogs:ENABLED", { - channel: channel.toString() - }); - } - } -} - -module.exports = Setmodlogs; \ No newline at end of file diff --git a/TO REWRITE/Administration/setnews.js b/TO REWRITE/Administration/setnews.js deleted file mode 100644 index dbd5d062..00000000 --- a/TO REWRITE/Administration/setnews.js +++ /dev/null @@ -1,44 +0,0 @@ -const Command = require("../../base/Command"); - -class Setnews extends Command { - constructor(client) { - super(client, { - name: "setnews", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: [], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const areNewsEnabled = Boolean(data.guild.plugins.news); - const sentChannel = await Resolvers.resolveChannel({ - message, - search: args.join(" "), - channelType: "GUILD_TEXT" - }); - - if (areNewsEnabled && !sentChannel) { - data.guild.plugins.news = null; - data.guild.markModified("plugins.news"); - await data.guild.save(); - return message.success("administration/setnews:DISABLED"); - } else { - const channel = sentChannel || message.channel; - data.guild.plugins.news = channel.id; - data.guild.markModified("plugins.news"); - await data.guild.save(); - return message.success("administration/setnews:ENABLED", { - channel: channel.toString() - }); - } - } -} - -module.exports = Setnews; \ No newline at end of file diff --git a/TO REWRITE/Administration/setreports.js b/TO REWRITE/Administration/setreports.js deleted file mode 100644 index da955d95..00000000 --- a/TO REWRITE/Administration/setreports.js +++ /dev/null @@ -1,44 +0,0 @@ -const Command = require("../../base/Command"); - -class Setreports extends Command { - constructor(client) { - super(client, { - name: "setreports", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["setr"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const areReportsEnabled = Boolean(data.guild.plugins.reports); - const sentChannel = await Resolvers.resolveChannel({ - message, - search: args.join(" "), - channelType: "GUILD_TEXT" - }); - - if (!sentChannel && areReportsEnabled) { - data.guild.plugins.reports = null; - data.guild.markModified("plugins.reports"); - await data.guild.save(); - return message.success("administration/setreports:DISABLED"); - } else { - const channel = sentChannel || message.channel; - data.guild.plugins.reports = channel.id; - data.guild.markModified("plugins.reports"); - await data.guild.save(); - return message.success("administration/setreports:ENABLED", { - channel: channel.toString() - }); - } - } -} - -module.exports = Setreports; \ No newline at end of file diff --git a/TO REWRITE/Administration/setsuggests.js b/TO REWRITE/Administration/setsuggests.js deleted file mode 100644 index 969b0af8..00000000 --- a/TO REWRITE/Administration/setsuggests.js +++ /dev/null @@ -1,44 +0,0 @@ -const Command = require("../../base/Command"); - -class Setsuggests extends Command { - constructor(client) { - super(client, { - name: "setsuggests", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["setsu"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - const areSuggestsEnabled = Boolean(data.guild.plugins.suggestions); - const sentChannel = await Resolvers.resolveChannel({ - message, - search: args.join(" "), - channelType: "GUILD_TEXT" - }); - - if (!sentChannel && areSuggestsEnabled) { - data.guild.plugins.suggestions = null; - data.guild.markModified("plugins.suggestions"); - await data.guild.save(); - return message.success("administration/setsuggests:DISABLED"); - } else { - const channel = sentChannel || message.channel; - data.guild.plugins.suggestions = channel.id; - data.guild.markModified("plugins.suggestions"); - await data.guild.save(); - return message.success("administration/setsuggests:ENABLED", { - channel: channel.toString() - }); - } - } -} - -module.exports = Setsuggests; \ No newline at end of file diff --git a/TO REWRITE/Administration/welcome.js b/TO REWRITE/Administration/welcome.js deleted file mode 100644 index dde95048..00000000 --- a/TO REWRITE/Administration/welcome.js +++ /dev/null @@ -1,110 +0,0 @@ -const Command = require("../../base/Command"); - -class Welcome extends Command { - constructor(client) { - super(client, { - name: "welcome", - dirname: __dirname, - enabled: true, - guildOnly: true, - aliases: ["welc"], - memberPermissions: ["MANAGE_GUILD"], - botPermissions: ["SEND_MESSAGES", "EMBED_LINKS"], - nsfw: false, - ownerOnly: false, - cooldown: 1000 - }); - } - - async run(message, args, data) { - if (args[0] === "test" && data.guild.plugins.welcome.enabled) { - this.client.emit("guildMemberAdd", message.member); - return message.success("administration/welcome:TEST_SUCCESS"); - } - - if ((!args[0] || !["edit", "off"].includes(args[0])) && data.guild.plugins.welcome.enabled) return message.error("administration/welcome:MISSING_STATUS"); - - if (args[0] === "off") { - data.guild.plugins.welcome = { - enabled: false, - message: null, - channelID: null, - withImage: null - }; - data.guild.markModified("plugins.welcome"); - data.guild.save(); - return message.error("administration/welcome:DISABLED", { - prefix: data.guild.prefix - }); - } else { - const welcome = { - enabled: true, - channel: null, - message: null, - withImage: null, - }; - - message.sendT("administration/welcome:FORM_1", { - author: message.author.toString() - }); - - const filter = m => m.author.id === message.author.id; - const collector = message.channel.createMessageCollector({ - filter, - time: 120000 // 2 minutes - }); - - collector.on("collect", async msg => { - // If the message is filled, it means the user sent yes or no for the image - if (welcome.message) { - if (msg.content.toLowerCase() === message.translate("common:YES").toLowerCase()) { - welcome.withImage = true; - } else if (msg.content.toLowerCase() === message.translate("common:NO").toLowerCase()) { - welcome.withImage = false; - } else { - return message.error("misc:INVALID_YES_NO"); - } - data.guild.plugins.welcome = welcome; - data.guild.markModified("plugins.welcome"); - await data.guild.save(); - message.sendT("administration/welcome:FORM_SUCCESS", { - prefix: data.guild.prefix, - channel: `<#${welcome.channel}>` - }); - return collector.stop(); - } - - // If the channel is filled and the message is not, it means the user sent the message - if (welcome.channel && !welcome.message) { - if (msg.content.length < 1800) { - welcome.message = msg.content; - return message.sendT("administration/welcome:FORM_3"); - } - return message.error("administration/goodbye:MAX_CHARACT"); - } - - // If the channel is not filled, it means the user sent it - if (!welcome.channel) { - const channel = await Resolvers.resolveChannel({ - message: msg, - channelType: "GUILD_TEXT" - }); - if (!channel) return message.error("misc:INVALID_CHANNEL"); - - welcome.channel = channel.id; - return message.sendT("administration/welcome:FORM_2", { - guildName: message.guild.name, - author: msg.author.tag, - memberCount: msg.guild.memberCount - }); - } - }); - - collector.on("end", (_, reason) => { - if (reason === "time") return message.error("misc:TIMES_UP"); - }); - } - } -} - -module.exports = Welcome; \ No newline at end of file diff --git a/commands/Administration/automod.js b/commands/Administration/automod.js new file mode 100644 index 00000000..a6cea8c3 --- /dev/null +++ b/commands/Administration/automod.js @@ -0,0 +1,72 @@ +const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Automod extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("automod") + .setDescription(client.translate("administration/automod:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addChannelOption(option => option.setName("channel") + .setDescription(client.translate("common:CHANNEL")) + .addChannelTypes(ChannelType.GuildText)), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const state = interaction.options.getBoolean("state"); + const channel = interaction.options.getChannel("channel"); + + if (state) { + data.guildData.plugins.automod = { + enabled: true, + ignored: [] + }; + data.guildData.markModified("plugins.automod"); + await data.guildData.save(); + return interaction.success("administration/automod:ENABLED"); + } else { + if (channel) { + data.guildData.plugins.automod.ignored.push(channel); + data.guildData.markModified("plugins.automod"); + await data.guildData.save(); + interaction.success("administration/automod:DISABLED_CHANNEL", { + channel: channel.toString() + }); + } else { + data.guildData.plugins.automod = { + enabled: false, + ignored: [] + }; + data.guildData.markModified("plugins.automod"); + await data.guildData.save(); + interaction.success("administration/automod:DISABLED"); + } + } + } +} + +module.exports = Automod; \ No newline at end of file diff --git a/commands/Administration/autorole.js b/commands/Administration/autorole.js new file mode 100644 index 00000000..4c01ce0c --- /dev/null +++ b/commands/Administration/autorole.js @@ -0,0 +1,74 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Autorole extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("autorole") + .setDescription(client.translate("administration/autorole:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addRoleOption(option => option.setName("role") + .setDescription(client.translate("common:ROLE"))), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const state = interaction.options.getBoolean("state"); + + if (state) { + const role = interaction.options.getRole("role", true); + if (!role) return interaction.error("administration/autorole:MISSING_ROLE"); + + data.guildData.plugins.autorole = { + enabled: true, + role: role.id + }; + data.guildData.markModified("plugins.autorole"); + await data.guildData.save(); + + interaction.success("administration/autorole:SUCCESS_ENABLED", { + roleName: role.name + }); + } 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 + }; + data.guildData.markModified("plugins.autorole"); + await data.guildData.save(); + + interaction.success("administration/autorole:SUCCESS_DISABLED", { + prefix: data.guildData.prefix + }); + } + } +} + +module.exports = Autorole; \ No newline at end of file diff --git a/commands/Administration/config.js b/commands/Administration/config.js new file mode 100644 index 00000000..6db447c1 --- /dev/null +++ b/commands/Administration/config.js @@ -0,0 +1,115 @@ +const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Config extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("config") + .setDescription(client.translate("administration/config:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const guildData = data.guildData; + + const embed = new EmbedBuilder() + .setAuthor({ + name: interaction.guild.name, + iconURL: interaction.guild.iconURL() + }) + .setColor(client.config.embed.color) + .setFooter({ + text: client.config.embed.footer + }) + .addFields([ + { + name: interaction.translate("administration/config:WELCOME_TITLE"), + value: guildData.plugins.welcome.enabled ? interaction.translate("administration/config:WELCOME_CONTENT", { + channel: `<#${guildData.plugins.welcome.channel}>`, + withImage: guildData.plugins.welcome.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO") + }) : interaction.translate("common:DISABLED"), + inline: true + }, + { + name: interaction.translate("administration/config:GOODBYE_TITLE"), + value: guildData.plugins.goodbye.enabled ? interaction.translate("administration/config:GOODBYE_CONTENT", { + channel: `<#${guildData.plugins.goodbye.channel}>`, + withImage: guildData.plugins.goodbye.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO") + }) : interaction.translate("common:DISABLED"), + inline: true + }, + { + name: interaction.translate("administration/config:AUTOROLE_TITLE"), + value: guildData.plugins.autorole.enabled ? `<@&${guildData.plugins.autorole.role}>` + : interaction.translate("common:DISABLED") + }, + { + name: interaction.translate("administration/config:AUTO_SANCTIONS"), + value: (guildData.plugins.warnsSanctions.kick ? interaction.translate("administration/config:KICK_CONTENT", { + count: guildData.plugins.warnsSanctions.kick + }) : interaction.translate("administration/config:KICK_NOT_DEFINED")) + "\n" + (guildData.plugins.warnsSanctions.ban ? interaction.translate("administration/config:BAN_CONTENT", { + count: guildData.plugins.warnsSanctions.ban + }) : interaction.translate("administration/config:BAN_NOT_DEFINED")) + }, + { + 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}>`) + }) : interaction.translate("common:DISABLED") + }, + { + name: interaction.translate("administration/config:AUTODELETEMOD"), + value: guildData.autoDeleteModCommands ? interaction.translate("administration/config:AUTODELETEMOD_ENABLED") : interaction.translate("administration/config:AUTODELETEMOD_DISABLED") + }, + { + name: interaction.translate("administration/config:SPECIAL_CHANNELS"), + value: interaction.translate("administration/config:NEWS", { + channel: guildData.plugins.news ? `<#${guildData.plugins.news}>` : `*${interaction.translate("common:NOT_DEFINED")}*` + }) + "\n" + + interaction.translate("administration/config:SUGGESTIONS", { + channel: guildData.plugins.suggestions ? `<#${guildData.plugins.suggestions}>` : `*${interaction.translate("common:NOT_DEFINED")}*` + }) + "\n" + + interaction.translate("administration/config:REPORTS", { + channel: guildData.plugins.reports ? `<#${guildData.plugins.reports}>` : `*${interaction.translate("common:NOT_DEFINED")}*` + }) + "\n" + + interaction.translate("administration/config:MODLOGS", { + channel: guildData.plugins.modlogs ? `<#${guildData.plugins.modlogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*` + }) + "\n" + + interaction.translate("administration/config:BIRTHDAYS", { + channel: guildData.plugins.birthdays ? `<#${guildData.plugins.birthdays}>` : `*${interaction.translate("common:NOT_DEFINED")}*` + }) + }, + { + name: interaction.translate("administration/config:DASHBOARD_TITLE"), + value: `[${interaction.translate("administration/config:DASHBOARD_CONTENT")}](${client.config.dashboard.baseURL})` + } + ]); + + interaction.reply({ + embeds: [embed] + }); + } +} + +module.exports = Config; \ No newline at end of file diff --git a/commands/Administration/deletemod.js b/commands/Administration/deletemod.js new file mode 100644 index 00000000..3eafe0c5 --- /dev/null +++ b/commands/Administration/deletemod.js @@ -0,0 +1,45 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Deletemod extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("deletemod") + .setDescription(client.translate("administration/deletemod:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const state = interaction.options.getBoolean("state"); + + data.guildData.autoDeleteModCommands = state; + await data.guildData.save(); + interaction.success(`administration/deletemod:${state ? "ENABLED" : "DISABLED"}`); + } +} + +module.exports = Deletemod; \ No newline at end of file diff --git a/commands/Administration/goodbye.js b/commands/Administration/goodbye.js new file mode 100644 index 00000000..fc020145 --- /dev/null +++ b/commands/Administration/goodbye.js @@ -0,0 +1,90 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Goodbye extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("goodbye") + .setDescription(client.translate("administration/goodbye:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addSubcommand(subcommand => subcommand.setName("test") + .setDescription(client.translate("administration/goodbye:TEST")) + ) + .addSubcommand(subcommand => subcommand.setName("config") + .setDescription(client.translate("administration/goodbye:CONFIG")) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addChannelOption(option => option.setName("channel") + .setDescription(client.translate("common:CHANNEL"))) + .addStringOption(option => option.setName("message") + .setDescription(client.translate("common:MESSAGE"))) + .addBooleanOption(option => option.setName("image") + .setDescription(client.translate("administration/goodbye:IMAGE"))) + ), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const command = interaction.options.getSubcommand(); + + if (command === "test") { + client.emit("guildMemberRemove", interaction.member); + return interaction.success("administration/goodbye:TEST_SUCCESS"); + } else { + const state = interaction.options.getBoolean("state"); + + if (!state) { + data.guildData.plugins.goodbye = { + enabled: false, + message: null, + channelID: null, + withImage: null + }; + data.guildData.markModified("plugins.goodbye"); + await data.guildData.save(); + + interaction.success("administration/goodbye:DISABLED"); + } else { + const channel = interaction.options.getChannel("channel"); + const message = interaction.options.getString("message"); + const image = interaction.options.getBoolean("image"); + + data.guildData.plugins.goodbye = { + enabled: true, + channel: channel.id, + message: message, + withImage: image, + }; + data.guildData.markModified("plugins.goodbye"); + await data.guildData.save(); + + interaction.success("administration/goodbye:ENABLED", { + channel: `<#${data.guildData.plugins.goodbye.channel}>` + }); + } + } + } +} + +module.exports = Goodbye; \ No newline at end of file diff --git a/commands/Administration/set.js b/commands/Administration/set.js new file mode 100644 index 00000000..ee7f8637 --- /dev/null +++ b/commands/Administration/set.js @@ -0,0 +1,106 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Set extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("set") + .setDescription(client.translate("administration/set:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addStringOption(option => option.setName("type") + .setDescription(client.translate("owner/debug:TYPE")) + .setRequired(true) + .addChoices( + { 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" }, + )) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER")) + .setRequired(true)) + .addIntegerOption(option => option.setName("int") + .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 {Array} data + */ + async execute(client, interaction, data) { + 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 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(), { + 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(), { + 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(), { + 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(), { + username: member.toString(), + amount: int + }, { ephemeral: true }); + } + } + } +} + +module.exports = Set; \ No newline at end of file diff --git a/commands/Administration/setbirthdays.js b/commands/Administration/setbirthdays.js new file mode 100644 index 00000000..5b73e34b --- /dev/null +++ b/commands/Administration/setbirthdays.js @@ -0,0 +1,61 @@ +const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Setbirthdays extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("setbirthdays") + .setDescription(client.translate("administration/setbirthdays:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addChannelOption(option => option.setName("channel") + .setDescription(client.translate("common:CHANNEL")) + .addChannelTypes(ChannelType.GuildText)), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const state = interaction.options.getBoolean("state"); + const channel = interaction.options.getChannel("channel"); + + if (!state) { + data.guildData.plugins.birthdays = null; + data.guildData.markModified("plugins.birthdays"); + await data.guildData.save(); + return interaction.success("administration/setbirthdays:DISABLED"); + } else { + if (channel) { + data.guildData.plugins.birthdays = channel.id; + data.guildData.markModified("plugins.birthdays"); + await data.guildData.save(); + interaction.success("administration/setbirthdays:ENABLED", { + channel: channel.toString() + }); + } else return interaction.replyT(`administration/setbirthdays:${data.guildData.plugins.birthdays ? "ENABLED" : "DISABLED"}`, data.guildData.plugins.birthdays ? { channel: interaction.guild.channels.cache.get(data.guildData.plugins.birthdays).toString() } : null); + } + } +} + +module.exports = Setbirthdays; \ No newline at end of file diff --git a/commands/Administration/setlang.js b/commands/Administration/setlang.js new file mode 100644 index 00000000..9386de9d --- /dev/null +++ b/commands/Administration/setlang.js @@ -0,0 +1,53 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Setlang extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("setlang") + .setDescription(client.translate("administration/setlang:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addStringOption(option => option.setName("language") + .setDescription(client.translate("common:LANGUAGE")) + .setRequired(true) + .addChoices( + { name: "Русский", value: "ru-RU" }, + { name: "Українська", value: "uk-UA" } + )), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const lang = interaction.options.getString("language"); + const language = client.languages.find(l => l.name === lang); + + data.guildData.language = language.name; + await data.guildData.save(); + + return interaction.success("administration/setlang:SUCCESS", { + lang: language.nativeName + }); + } +} + +module.exports = Setlang; \ No newline at end of file diff --git a/commands/Administration/setmodlogs.js b/commands/Administration/setmodlogs.js new file mode 100644 index 00000000..7d4deabe --- /dev/null +++ b/commands/Administration/setmodlogs.js @@ -0,0 +1,61 @@ +const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Setmodlogs extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("setmodlogs") + .setDescription(client.translate("administration/setmodlogs:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addChannelOption(option => option.setName("channel") + .setDescription(client.translate("common:CHANNEL")) + .addChannelTypes(ChannelType.GuildText)), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const state = interaction.options.getBoolean("state"); + const channel = interaction.options.getChannel("channel"); + + if (!state) { + data.guildData.plugins.modlogs = null; + data.guildData.markModified("plugins.modlogs"); + await data.guildData.save(); + return interaction.success("administration/setmodlogs:DISABLED"); + } else { + if (channel) { + data.guildData.plugins.modlogs = channel.id; + data.guildData.markModified("plugins.modlogs"); + await data.guildData.save(); + interaction.success("administration/setmodlogs:ENABLED", { + channel: channel.toString() + }); + } else return interaction.replyT(`administration/setmodlogs:${data.guildData.plugins.modlogs ? "ENABLED" : "DISABLED"}`, data.guildData.plugins.modlogs ? { channel: interaction.guild.channels.cache.get(data.guildData.plugins.modlogs).toString() } : null); + } + } +} + +module.exports = Setmodlogs; \ No newline at end of file diff --git a/commands/Administration/setnews.js b/commands/Administration/setnews.js new file mode 100644 index 00000000..9c6d4110 --- /dev/null +++ b/commands/Administration/setnews.js @@ -0,0 +1,61 @@ +const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Setnews extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("setnews") + .setDescription(client.translate("administration/setnews:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addChannelOption(option => option.setName("channel") + .setDescription(client.translate("common:CHANNEL")) + .addChannelTypes(ChannelType.GuildText)), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const state = interaction.options.getBoolean("state"); + const channel = interaction.options.getChannel("channel"); + + if (!state) { + data.guildData.plugins.news = null; + data.guildData.markModified("plugins.news"); + await data.guildData.save(); + return interaction.success("administration/setnews:DISABLED"); + } else { + if (channel) { + data.guildData.plugins.news = channel.id; + data.guildData.markModified("plugins.news"); + await data.guildData.save(); + interaction.success("administration/setnews:ENABLED", { + channel: channel.toString() + }); + } else return interaction.replyT(`administration/setnews:${data.guildData.plugins.news ? "ENABLED" : "DISABLED"}`, data.guildData.plugins.news ? { channel: interaction.guild.channels.cache.get(data.guildData.plugins.news).toString() } : null); + } + } +} + +module.exports = Setnews; \ No newline at end of file diff --git a/commands/Administration/setreports.js b/commands/Administration/setreports.js new file mode 100644 index 00000000..9b1b549e --- /dev/null +++ b/commands/Administration/setreports.js @@ -0,0 +1,61 @@ +const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Setreports extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("setreports") + .setDescription(client.translate("administration/setreports:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addChannelOption(option => option.setName("channel") + .setDescription(client.translate("common:CHANNEL")) + .addChannelTypes(ChannelType.GuildText)), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const state = interaction.options.getBoolean("state"); + const channel = interaction.options.getChannel("channel"); + + if (!state) { + data.guildData.plugins.reports = null; + data.guildData.markModified("plugins.reports"); + await data.guildData.save(); + return interaction.success("administration/setreports:DISABLED"); + } else { + if (channel) { + data.guildData.plugins.reports = channel.id; + data.guildData.markModified("plugins.reports"); + await data.guildData.save(); + interaction.success("administration/setreports:ENABLED", { + channel: channel.toString() + }); + } else return interaction.replyT(`administration/setreports:${data.guildData.plugins.reports ? "ENABLED" : "DISABLED"}`, data.guildData.plugins.reports ? { channel: interaction.guild.channels.cache.get(data.guildData.plugins.reports).toString() } : null); + } + } +} + +module.exports = Setreports; \ No newline at end of file diff --git a/commands/Administration/setsuggests.js b/commands/Administration/setsuggests.js new file mode 100644 index 00000000..1b687abf --- /dev/null +++ b/commands/Administration/setsuggests.js @@ -0,0 +1,61 @@ +const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Setsuggests extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("setsuggests") + .setDescription(client.translate("administration/setsuggests:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addChannelOption(option => option.setName("channel") + .setDescription(client.translate("common:CHANNEL")) + .addChannelTypes(ChannelType.GuildText)), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const state = interaction.options.getBoolean("state"); + const channel = interaction.options.getChannel("channel"); + + if (!state) { + data.guildData.plugins.suggestions = null; + data.guildData.markModified("plugins.suggestions"); + await data.guildData.save(); + return interaction.success("administration/setsuggests:DISABLED"); + } else { + if (channel) { + data.guildData.plugins.suggestions = channel.id; + data.guildData.markModified("plugins.suggestions"); + await data.guildData.save(); + interaction.success("administration/setsuggests:ENABLED", { + channel: channel.toString() + }); + } else return interaction.replyT(`administration/setsuggests:${data.guildData.plugins.suggestions ? "ENABLED" : "DISABLED"}`, data.guildData.plugins.suggestions ? { channel: interaction.guild.channels.cache.get(data.guildData.plugins.suggestions).toString() } : null); + } + } +} + +module.exports = Setsuggests; \ No newline at end of file diff --git a/commands/Administration/welcome.js b/commands/Administration/welcome.js new file mode 100644 index 00000000..25411b6f --- /dev/null +++ b/commands/Administration/welcome.js @@ -0,0 +1,90 @@ +const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"); + +class Welcome extends BaseCommand { + /** + * + * @param {import("../../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("welcome") + .setDescription(client.translate("administration/welcome:DESCRIPTION")) + .setDefaultMemberPermissions(PermissionFlagsBits.ManageGuild) + .addSubcommand(subcommand => subcommand.setName("test") + .setDescription(client.translate("administration/goodbye:TEST")) + ) + .addSubcommand(subcommand => subcommand.setName("config") + .setDescription(client.translate("administration/goodbye:CONFIG")) + .addBooleanOption(option => option.setName("state") + .setDescription(client.translate("common:STATE")) + .setRequired(true)) + .addChannelOption(option => option.setName("channel") + .setDescription(client.translate("common:CHANNEL"))) + .addStringOption(option => option.setName("message") + .setDescription(client.translate("common:MESSAGE"))) + .addBooleanOption(option => option.setName("image") + .setDescription(client.translate("administration/goodbye:IMAGE"))) + ), + aliases: [], + dirname: __dirname, + guildOnly: true + }); + } + /** + * + * @param {import("../../base/JaBa")} client + */ + async onLoad() { + //... + } + /** + * + * @param {import("../../base/JaBa")} client + * @param {import("discord.js").ChatInputCommandInteraction} interaction + * @param {Array} data + */ + async execute(client, interaction, data) { + const command = interaction.options.getSubcommand(); + + if (command === "test") { + client.emit("guildMemberAdd", interaction.member); + return interaction.success("administration/goodbye:TEST_SUCCESS"); + } else { + const state = interaction.options.getBoolean("state"); + + if (!state) { + data.guildData.plugins.welcome = { + enabled: false, + message: null, + channelID: null, + withImage: null + }; + data.guildData.markModified("plugins.welcome"); + await data.guildData.save(); + + interaction.success("administration/welcome:DISABLED"); + } else { + const channel = interaction.options.getChannel("channel"); + const message = interaction.options.getString("message"); + const image = interaction.options.getBoolean("image"); + + data.guildData.plugins.welcome = { + enabled: true, + channel: channel.id, + message: message, + withImage: image, + }; + data.guildData.markModified("plugins.welcome"); + await data.guildData.save(); + + interaction.success("administration/welcome:ENABLED", { + channel: `<#${data.guildData.plugins.welcome.channel}>` + }); + } + } + } +} + +module.exports = Welcome; \ No newline at end of file diff --git a/commands/Fun/memes.js b/commands/Fun/memes.js index 35e0e3a5..c274a754 100644 --- a/commands/Fun/memes.js +++ b/commands/Fun/memes.js @@ -48,7 +48,7 @@ class Memes extends BaseCommand { ); const msg = await interaction.reply({ - content: interaction.translate("common:AVAILABLE_CATEGORIES"), + content: interaction.translate("common:AVAILABLE_OPTIONS"), components: [row], fetchReply: true }); diff --git a/commands/General/help.js b/commands/General/help.js index 65797bb6..f4417603 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -69,7 +69,7 @@ class Help extends BaseCommand { ); const msg = await interaction.reply({ - content: interaction.translate("common:AVAILABLE_CATEGORIES"), + content: interaction.translate("common:AVAILABLE_OPTIONS"), components: [row], fetchReply: true }); diff --git a/commands/General/serverinfo.js b/commands/General/serverinfo.js index 0997f62f..5c78e96e 100644 --- a/commands/General/serverinfo.js +++ b/commands/General/serverinfo.js @@ -1,4 +1,4 @@ -const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"); +const { SlashCommandBuilder, EmbedBuilder, ChannelType } = require("discord.js"); const BaseCommand = require("../../base/BaseCommand"); class Serverinfo extends BaseCommand { @@ -85,9 +85,9 @@ class Serverinfo extends BaseCommand { }, { name: client.customEmojis.channels + interaction.translate("common:CHANNELS"), - value: `${guild.channels.cache.filter(c => c.type === "GUILD_TEXT").size} ${client.getNoun(guild.channels.cache.filter(c => c.type === "GUILD_TEXT").size, interaction.translate("misc:NOUNS:TEXT:1"), interaction.translate("misc:NOUNS:TEXT:2"), interaction.translate("misc:NOUNS:TEXT:5"))}` + - "\n" + `${guild.channels.cache.filter(c => c.type === "GUILD_VOICE").size} ${client.getNoun(guild.channels.cache.filter(c => c.type === "GUILD_VOICE").size, interaction.translate("misc:NOUNS:VOICE:1"), interaction.translate("misc:NOUNS:VOICE:2"), interaction.translate("misc:NOUNS:VOICE:5"))}` + - "\n" + `${guild.channels.cache.filter(c => c.type === "GUILD_CATEGORY").size} ${client.getNoun(guild.channels.cache.filter(c => c.type === "GUILD_CATEGORY").size, interaction.translate("misc:NOUNS:CATEGORY:1"), interaction.translate("misc:NOUNS:CATEGORY:2"), interaction.translate("misc:NOUNS:CATEGORY:5"))}`, + value: `${guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size} ${client.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size, interaction.translate("misc:NOUNS:TEXT:1"), interaction.translate("misc:NOUNS:TEXT:2"), interaction.translate("misc:NOUNS:TEXT:5"))}` + + "\n" + `${guild.channels.cache.filter(c => c.type === ChannelType.GuildVoice).size} ${client.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildVoice).size, interaction.translate("misc:NOUNS:VOICE:1"), interaction.translate("misc:NOUNS:VOICE:2"), interaction.translate("misc:NOUNS:VOICE:5"))}` + + "\n" + `${guild.channels.cache.filter(c => c.type === ChannelType.GuildCategory).size} ${client.getNoun(guild.channels.cache.filter(c => c.type === ChannelType.GuildCategory).size, interaction.translate("misc:NOUNS:CATEGORY:1"), interaction.translate("misc:NOUNS:CATEGORY:2"), interaction.translate("misc:NOUNS:CATEGORY:5"))}`, inline: true } ]) diff --git a/commands/Moderation/giveaway.js b/commands/Moderation/giveaway.js index 8f0339db..c70d5de9 100644 --- a/commands/Moderation/giveaway.js +++ b/commands/Moderation/giveaway.js @@ -58,7 +58,7 @@ class Giveaway extends BaseCommand { ); const msg = await interaction.reply({ - content: interaction.translate("common:AVAILABLE_CATEGORIES"), + content: interaction.translate("common:AVAILABLE_OPTIONS"), components: [row], ephemeral: true, fetchReply: true diff --git a/commands/Moderation/warn.js b/commands/Moderation/warn.js index 6db6a35c..c8cf6145 100644 --- a/commands/Moderation/warn.js +++ b/commands/Moderation/warn.js @@ -1,4 +1,4 @@ -const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionFlagsBits, TextInputStyle, ModalBuilder, EmbedBuilder, ActionRowBuilder, TextInputBuilder } = require("discord.js"); +const { ContextMenuCommandBuilder, ModalBuilder, EmbedBuilder, ActionRowBuilder, TextInputBuilder, ApplicationCommandType, PermissionFlagsBits, TextInputStyle } = require("discord.js"); const BaseCommand = require("../../base/BaseCommand"); class Warn extends BaseCommand { @@ -49,7 +49,7 @@ class Warn extends BaseCommand { const reasonInput = new TextInputBuilder() .setCustomId("warn_reason") - .setLabel(interaction.translate("moderation/warn:REASON")) + .setLabel(interaction.translate("moderation/warn:MODAL_REASON")) .setStyle(TextInputStyle.Short); modal.addComponents(new ActionRowBuilder().addComponents(reasonInput)); @@ -58,10 +58,10 @@ class Warn extends BaseCommand { const submitted = await interaction.awaitModalSubmit({ time: 120000, - filter: i => i.user.id === interaction.member.id, + filter: i => i.user.id === interaction.member.id && i.customId === "warn_modal", }); - if (submitted && submitted.customId === "warn_modal") { + if (submitted) { const reason = submitted.fields.getTextInputValue("warn_reason"); const sanctions = memberData.sanctions.filter((s) => s.type === "warn").length; diff --git a/commands/Music/loop.js b/commands/Music/loop.js index 6ccc3b82..bbc27c2e 100644 --- a/commands/Music/loop.js +++ b/commands/Music/loop.js @@ -63,7 +63,7 @@ class Loop extends BaseCommand { ); const msg = await interaction.reply({ - content: interaction.translate("common:AVAILABLE_CATEGORIES"), + content: interaction.translate("common:AVAILABLE_OPTIONS"), components: [row], fetchReply: true }); @@ -82,8 +82,11 @@ class Loop extends BaseCommand { queue.setRepeatMode(mode); return i.update({ - content: interaction.translate(`music/loop:${type === "3" ? "AUTOPLAY_ENABLED" : - type === "2" ? "QUEUE_ENABLED" : type === "1" ? "TRACK_ENABLED" : "LOOP_DISABLED"}`), + content: interaction.translate(`music/loop:${ + type === "3" ? "AUTOPLAY_ENABLED" : + type === "2" ? "QUEUE_ENABLED" : + type === "1" ? "TRACK_ENABLED" : "LOOP_DISABLED" + }`), components: [] }); }); diff --git a/commands/Music/nowplaying.js b/commands/Music/nowplaying.js index c75da68e..455eb0c8 100644 --- a/commands/Music/nowplaying.js +++ b/commands/Music/nowplaying.js @@ -59,8 +59,9 @@ class Nowplaying extends BaseCommand { { name: "\u200b", value: `${interaction.translate("music/nowplaying:REPEAT")}: \`${ - queue.repeatMode === QueueRepeatMode.AUTOPLAY ? interaction.translate("music/nowplaying:AUTOPLAY") : queue.repeatMode === QueueRepeatMode.QUEUE ? interaction.translate("music/nowplaying:QUEUE") : queue.repeatMode === QueueRepeatMode.TRACK ? interaction.translate("music/nowplaying:TRACK") - : interaction.translate("music/nowplaying:DISABLED") + queue.repeatMode === QueueRepeatMode.AUTOPLAY ? interaction.translate("music/nowplaying:AUTOPLAY") : + queue.repeatMode === QueueRepeatMode.QUEUE ? interaction.translate("music/nowplaying:QUEUE") : + queue.repeatMode === QueueRepeatMode.TRACK ? interaction.translate("music/nowplaying:TRACK") : interaction.translate("common:DISABLED") }\`` } ]) diff --git a/commands/Music/skipto.js b/commands/Music/skipto.js index 4184fa6f..8ea9450f 100644 --- a/commands/Music/skipto.js +++ b/commands/Music/skipto.js @@ -46,9 +46,9 @@ class Skipto extends BaseCommand { queue.skipTo(queue.tracks[position - 1]); interaction.success("music/skipto:SUCCESS", { - position: position - 1 + position: position }); - } else return interaction.error("music/skipto:ERROR", { position: position - 1 }); + } else return interaction.error("music/skipto:ERROR", { position: position }); } } diff --git a/commands/NSFW/nsfw.js b/commands/NSFW/nsfw.js index 254aa5b3..92e6dde5 100644 --- a/commands/NSFW/nsfw.js +++ b/commands/NSFW/nsfw.js @@ -50,7 +50,7 @@ class NSFW extends BaseCommand { ); const msg = await interaction.reply({ - content: interaction.translate("common:AVAILABLE_CATEGORIES"), + content: interaction.translate("common:AVAILABLE_OPTIONS"), ephemeral: true, components: [row], fetchReply: true diff --git a/commands/Owner/debug.js b/commands/Owner/debug.js index 09c2d5ae..b5c11f04 100644 --- a/commands/Owner/debug.js +++ b/commands/Owner/debug.js @@ -23,8 +23,8 @@ class Debug extends BaseCommand { { name: client.translate("economy/transactions:BANK"), value: "bank" }, { name: client.translate("common:REP"), value: "rep" }, )) - .addUserOption(option => option.setName("target") - .setDescription(client.translate("owner/debug:TARGET")) + .addUserOption(option => option.setName("user") + .setDescription(client.translate("common:USER")) .setRequired(true)) .addIntegerOption(option => option.setName("int") .setDescription(client.translate("common:INT")) @@ -69,20 +69,20 @@ class Debug extends BaseCommand { * @param {Array} data */ async execute(client, interaction, data) { - const action = interaction.options.getSubcommand(); + const command = interaction.options.getSubcommand(); - if (action === "set") { + 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 int = interaction.options.getInteger("int"); - if (member.user.bot) return interaction.error("misc:BOT_USER"); switch (type) { case "level": { data.memberData.level = int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -91,7 +91,7 @@ class Debug extends BaseCommand { data.memberData.exp = int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -100,7 +100,7 @@ class Debug extends BaseCommand { data.memberData.money = int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -109,7 +109,7 @@ class Debug extends BaseCommand { data.memberData.bankSold = int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -118,7 +118,7 @@ class Debug extends BaseCommand { data.memberData.rep = int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -126,15 +126,15 @@ class Debug extends BaseCommand { } else { 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 int = interaction.options.getInteger("int"); - if (member.user.bot) return interaction.error("owner/debug:BOT", { ephemeral: true }); switch (type) { case "level": { data.memberData.level += int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -143,7 +143,7 @@ class Debug extends BaseCommand { data.memberData.exp += int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -152,7 +152,7 @@ class Debug extends BaseCommand { data.memberData.money += int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -161,7 +161,7 @@ class Debug extends BaseCommand { data.memberData.bankSold += int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } @@ -170,7 +170,7 @@ class Debug extends BaseCommand { data.memberData.rep += int; await data.memberData.save(); return interaction.success("owner/debug:SUCCESS_" + type.toUpperCase(), { - username: member.user.tag, + username: member.toString(), amount: int }, { ephemeral: true }); } diff --git a/dashboard/public/docs/updates.md b/dashboard/public/docs/updates.md index 92144ad4..42c2c568 100644 --- a/dashboard/public/docs/updates.md +++ b/dashboard/public/docs/updates.md @@ -1,3 +1,12 @@ +### JaBa v4.0pre5 +* Добавлено + * Перенесена категория *Administration*. + +* Исправления + * Изменён способ получения музыки. На данный момент не работает Spotify, в будущих обновлениях постораюсь вернуть, но это не точно. + * Панель управления снова работает. + * Множество мелких правок. + ### JaBa v4.0pre4 * Добавлено * Перенесена категория *Moderation*. diff --git a/dashboard/routes/guild-manager.js b/dashboard/routes/guild-manager.js index daad2ea9..f8656c1c 100644 --- a/dashboard/routes/guild-manager.js +++ b/dashboard/routes/guild-manager.js @@ -1,3 +1,4 @@ +const { ChannelType } = require("discord.js"); const express = require("express"), utils = require("../utils"), CheckAuth = require("../auth/CheckAuth"), @@ -23,6 +24,7 @@ router.get("/:serverID", CheckAuth, async(req, res) => { user: req.userInfos, memberData: memberData, translate: req.translate, + ChannelType, bot: req.client, currentURL: `${req.client.config.dashboard.baseURL}${req.originalUrl}` }); @@ -54,7 +56,7 @@ router.post("/:serverID", CheckAuth, async(req, res) => { const welcome = { enabled: true, message: data.message, - channel: guild.channels.cache.find((ch) => "#" + ch.name === data.channel).id, + channel: guild.channels.cache.find(ch => "#" + ch.name === data.channel).id, withImage: data.withImage === "on" }; guildData.plugins.welcome = welcome; @@ -78,7 +80,7 @@ router.post("/:serverID", CheckAuth, async(req, res) => { const goodbye = { enabled: true, message: data.message, - channel: guild.channels.cache.find((ch) => "#" + ch.name === data.channel).id, + channel: guild.channels.cache.find(ch => "#" + ch.name === data.channel).id, withImage: data.withImage === "on" }; guildData.plugins.goodbye = goodbye; @@ -101,7 +103,7 @@ router.post("/:serverID", CheckAuth, async(req, res) => { if (Object.prototype.hasOwnProperty.call(data, "autoroleEnable") || Object.prototype.hasOwnProperty.call(data, "autoroleUpdate")) { const autorole = { enabled: true, - role: guild.roles.cache.find((r) => "@" + r.name === data.role).id + role: guild.roles.cache.find(r => "@" + r.name === data.role).id }; guildData.plugins.autorole = autorole; guildData.markModified("plugins.autorole"); @@ -119,17 +121,20 @@ router.post("/:serverID", CheckAuth, async(req, res) => { } if (Object.prototype.hasOwnProperty.call(data, "suggestions")) { - if (data.suggestions === req.translate("common:NO_CHANNEL")) guildData.plugins.suggestions = false; - else guildData.plugins.suggestions = guild.channels.cache.find((ch) => "#" + ch.name === data.suggestions).id; + if (data.suggestions === req.translate("dashboard:NO_CHANNEL")) guildData.plugins.suggestions = false; + else guildData.plugins.suggestions = guild.channels.cache.find(ch => "#" + ch.name === data.suggestions).id; - if (data.modlogs === req.translate("common:NO_CHANNEL")) guildData.plugins.modlogs = false; - else guildData.plugins.modlogs = guild.channels.cache.find((ch) => "#" + ch.name === data.modlogs).id; + if (data.modlogs === req.translate("dashboard:NO_CHANNEL")) guildData.plugins.modlogs = false; + else guildData.plugins.modlogs = guild.channels.cache.find(ch => "#" + ch.name === data.modlogs).id; - if (data.reports === req.translate("common:NO_CHANNEL")) guildData.plugins.reports = false; - else guildData.plugins.reports = guild.channels.cache.find((ch) => "#" + ch.name === data.reports).id; + if (data.reports === req.translate("dashboard:NO_CHANNEL")) guildData.plugins.reports = false; + else guildData.plugins.reports = guild.channels.cache.find(ch => "#" + ch.name === data.reports).id; - if (data.birthdays === req.translate("common:NO_CHANNEL")) guildData.plugins.birthdays = false; - else guildData.plugins.birthdays = guild.channels.cache.find((ch) => "#" + ch.name === data.birthdays).id; + if (data.birthdays === req.translate("dashboard:NO_CHANNEL")) guildData.plugins.birthdays = false; + else guildData.plugins.birthdays = guild.channels.cache.find(ch => "#" + ch.name === data.birthdays).id; + + if (data.news === req.translate("dashboard:NO_CHANNEL")) guildData.plugins.news = false; + else guildData.plugins.news = guild.channels.cache.find(ch => "#" + ch.name === data.news).id; guildData.markModified("plugins"); } diff --git a/dashboard/views/manager/guild.ejs b/dashboard/views/manager/guild.ejs index ed222210..e3a9b467 100644 --- a/dashboard/views/manager/guild.ejs +++ b/dashboard/views/manager/guild.ejs @@ -130,72 +130,90 @@
- + + +
+
+
- +
- +
- +