From d137003f78f8359a5ab9ae40dd2f995f67e945d6 Mon Sep 17 00:00:00 2001 From: JonnyBro Date: Wed, 7 Dec 2022 18:43:20 +0500 Subject: [PATCH] v4.1.17 - https://github.com/JonnyBro/JaBa-logs --- .gitignore | 3 ++ commands/Fun/cat.js | 45 +++++++++++++++++++++ commands/Fun/dog.js | 45 +++++++++++++++++++++ commands/General/help.js | 66 +++++++++++++------------------ commands/Moderation/warn.js | 16 ++++---- commands/Owner/reload.js | 2 +- dashboard/public/docs/updates.md | 10 +++++ languages/ru-RU/common.json | 2 + languages/ru-RU/fun/cat.json | 5 +++ languages/ru-RU/fun/dog.json | 5 +++ languages/ru-RU/general/help.json | 4 +- languages/ru-RU/owner/reload.json | 1 - languages/uk-UA/common.json | 6 ++- languages/uk-UA/fun/cat.json | 5 +++ languages/uk-UA/fun/dog.json | 5 +++ languages/uk-UA/general/help.json | 2 +- languages/uk-UA/owner/reload.json | 1 - package-lock.json | 4 +- package.json | 2 +- 19 files changed, 172 insertions(+), 57 deletions(-) create mode 100644 commands/Fun/cat.js create mode 100644 commands/Fun/dog.js create mode 100644 languages/ru-RU/fun/cat.json create mode 100644 languages/ru-RU/fun/dog.json create mode 100644 languages/uk-UA/fun/cat.json create mode 100644 languages/uk-UA/fun/dog.json diff --git a/.gitignore b/.gitignore index 702e9e9a..5b1e7f14 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ # Node modules node_modules yarn.lock + +# Backups +/.backup \ No newline at end of file diff --git a/commands/Fun/cat.js b/commands/Fun/cat.js new file mode 100644 index 00000000..c48a94ef --- /dev/null +++ b/commands/Fun/cat.js @@ -0,0 +1,45 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"), + fetch = require("node-fetch"); + +class Cat extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("cat") + .setDescription(client.translate("fun/cat:DESCRIPTION")) + .setDMPermission(true), + aliases: [], + dirname: __dirname, + 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 res = await fetch("https://and-here-is-my-code.glitch.me/img/cat").then(response => response.json()); + + interaction.editReply({ + content: res.Link + }); + } +} + +module.exports = Cat; \ No newline at end of file diff --git a/commands/Fun/dog.js b/commands/Fun/dog.js new file mode 100644 index 00000000..0106eafc --- /dev/null +++ b/commands/Fun/dog.js @@ -0,0 +1,45 @@ +const { SlashCommandBuilder } = require("discord.js"); +const BaseCommand = require("../../base/BaseCommand"), + fetch = require("node-fetch"); + +class Dog extends BaseCommand { + /** + * + * @param {import("../base/JaBa")} client + */ + constructor(client) { + super({ + command: new SlashCommandBuilder() + .setName("dog") + .setDescription(client.translate("fun/dog:DESCRIPTION")) + .setDMPermission(true), + aliases: [], + dirname: __dirname, + 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 res = await fetch("https://and-here-is-my-code.glitch.me/img/dog").then(response => response.json()); + + interaction.editReply({ + content: res.Link + }); + } +} + +module.exports = Dog; \ No newline at end of file diff --git a/commands/General/help.js b/commands/General/help.js index d55d2409..44cd5acd 100644 --- a/commands/General/help.js +++ b/commands/General/help.js @@ -14,7 +14,7 @@ class Help extends BaseCommand { .setDMPermission(true) .addStringOption(option => option.setName("command") - .setDescription(client.translate("owner/reload:COMMAND"))), + .setDescription(client.translate("common:COMMAND"))), aliases: [], dirname: __dirname, ownerOnly: false @@ -40,13 +40,7 @@ class Help extends BaseCommand { const categories = []; const command = interaction.options.getString("command"); - if (command) { - const embed = generateCommandHelp(interaction, command); - - return interaction.editReply({ - embeds: [embed] - }); - } + if (command) return interaction.editReply({ embeds: [ generateCommandHelp(interaction, command) ] }); commands.forEach(c => { if (!categories.includes(c.category)) { @@ -80,41 +74,37 @@ class Help extends BaseCommand { const collector = msg.createMessageComponentCollector({ filter, idle: (15 * 1000) }); collector.on("collect", async i => { - if (i.isSelectMenu() && (i.customId === "help_category_select" || i.customId === "help_commands_select")) { + if (i.isSelectMenu() && i.customId === "help_category_select") { i.deferUpdate(); const arg = i?.values[0]; + const categoryCommands = commands.filter(cmd => cmd.category === arg).map(c => { + return { + name: `**${c.command.name}**`, + value: interaction.translate(`${arg.toLowerCase()}/${c.command.name}:DESCRIPTION`) + }; + }); - if (categories.includes(arg)) { - const categoryCommands = commands.filter(cmd => cmd.category === arg).map(c => { - return { - label: c.command.name, - value: c.command.name - }; - }); + const embed = new EmbedBuilder() + .setColor(client.config.embed.color) + .setFooter({ + text: client.config.embed.footer + }) + .setAuthor({ + name: interaction.translate("general/help:COMMANDS_IN", { category: arg }) + }) + .addFields(categoryCommands) + .addFields([ + { + name: "\u200B", + value: interaction.translate("general/help:INFO") + } + ]); - const commandsRow = new ActionRowBuilder() - .addComponents( - new SelectMenuBuilder() - .setCustomId("help_commands_select") - .setPlaceholder(client.translate("common:NOTHING_SELECTED")) - .addOptions(categoryCommands) - ); - - return await interaction.editReply({ - content: interaction.translate("general/help:COMMANDS_IN", { - category: arg - }), - components: [commandsRow] - }); - } else { - const embed = generateCommandHelp(interaction, arg); - return interaction.editReply({ - content: null, - components: [], - embeds: [embed] - }); - } + return interaction.editReply({ + content: null, + embeds: [embed] + }); } }); diff --git a/commands/Moderation/warn.js b/commands/Moderation/warn.js index 9760ab0e..90c1733f 100644 --- a/commands/Moderation/warn.js +++ b/commands/Moderation/warn.js @@ -35,9 +35,9 @@ class Warn extends BaseCommand { const member = interaction.targetMember; const memberPosition = member.roles.highest.position; const moderationPosition = interaction.member.roles.highest.position; - if (member.user.bot) return; - if (member.id === interaction.member.id) return interaction.error("moderation/warn:YOURSELF"); - if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition)) return interaction.error("moderation/ban:SUPERIOR"); + if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); + if (member.id === interaction.member.id) return interaction.error("moderation/warn:YOURSELF", null, { ephemeral: true }); + if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition)) return interaction.error("moderation/ban:SUPERIOR", null, { ephemeral: true }); const memberData = await client.findOrCreateMember({ id: member.id, @@ -46,9 +46,7 @@ class Warn extends BaseCommand { const modal = new ModalBuilder() .setCustomId("warn_modal") - .setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { - nickname: member.user.tag - })); + .setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { nickname: member.user.tag }).normalize("NFKD")); const reasonInput = new TextInputBuilder() .setCustomId("warn_reason") @@ -115,7 +113,7 @@ class Warn extends BaseCommand { count: data.guildData.casesCount }) }) - .setColor("#e02316"); + .setColor(client.config.embed.color); interaction.guild.members.ban(member); interaction.success("moderation/setwarns:AUTO_BAN", { username: member.user.tag, @@ -140,7 +138,7 @@ class Warn extends BaseCommand { count: data.guildData.casesCount }) }) - .setColor("#e88709"); + .setColor(client.config.embed.color); member.kick().catch(() => {}); interaction.success("moderation/setwarns:AUTO_KICK", { username: member.user.tag, @@ -163,7 +161,7 @@ class Warn extends BaseCommand { name: interaction.translate("moderation/warn:CASE", { caseNumber: data.guildData.casesCount }) - }).setColor("#8c14e2"); + }).setColor(client.config.embed.color); submitted.reply({ content: interaction.translate("moderation/warn:WARNED", { diff --git a/commands/Owner/reload.js b/commands/Owner/reload.js index d1d096b5..5eed9d2b 100644 --- a/commands/Owner/reload.js +++ b/commands/Owner/reload.js @@ -15,7 +15,7 @@ class Reload extends BaseCommand { .setDescription(client.translate("owner/reload:DESCRIPTION")) .setDMPermission(true) .addStringOption(option => option.setName("command") - .setDescription(client.translate("owner/reload:COMMAND")) + .setDescription(client.translate("common:COMMAND")) .setRequired(true)), aliases: [], dirname: __dirname, diff --git a/dashboard/public/docs/updates.md b/dashboard/public/docs/updates.md index f4a2155f..4856fc45 100644 --- a/dashboard/public/docs/updates.md +++ b/dashboard/public/docs/updates.md @@ -1,3 +1,13 @@ +### JaBa v4.1.17 +* Добавлено + * Команды *cat* и *dog*. + +* Изменения + * Переписана команда *help*. + +* Исправления + * Ошибка команды *warn* если имя пользователя содержит нестандартные символы. + ### JaBa v4.1.16 * Добавлено * Наконец-то возвращена и починена команда *seek*. diff --git a/languages/ru-RU/common.json b/languages/ru-RU/common.json index 7e5af8d1..ab1c4877 100644 --- a/languages/ru-RU/common.json +++ b/languages/ru-RU/common.json @@ -4,11 +4,13 @@ "APPLY": "Применить", "AUTHOR": "Автор", "AVAILABLE_OPTIONS": "Доступные параметры:", + "CATEGORY": "Категория", "CANCEL": "Отменить", "CHANNEL": "Канал", "CHANNELS": "Каналы", "COLOR": "Цвет", "CONTENT": "Содержимое", + "COMMAND": "Команда", "CREATION": "Создан", "CREDITS": "Кредиты", "DATE": "Дата", diff --git a/languages/ru-RU/fun/cat.json b/languages/ru-RU/fun/cat.json new file mode 100644 index 00000000..40cbea4d --- /dev/null +++ b/languages/ru-RU/fun/cat.json @@ -0,0 +1,5 @@ +{ + "DESCRIPTION": "Всё как с крабом, только котик", + "USAGE": "", + "EXAMPLES": "cat" +} \ No newline at end of file diff --git a/languages/ru-RU/fun/dog.json b/languages/ru-RU/fun/dog.json new file mode 100644 index 00000000..bd9550e7 --- /dev/null +++ b/languages/ru-RU/fun/dog.json @@ -0,0 +1,5 @@ +{ + "DESCRIPTION": "Вы не поверите... изображение собачки!", + "USAGE": "", + "EXAMPLES": "dog" +} \ No newline at end of file diff --git a/languages/ru-RU/general/help.json b/languages/ru-RU/general/help.json index f6b2155a..581e542c 100644 --- a/languages/ru-RU/general/help.json +++ b/languages/ru-RU/general/help.json @@ -3,14 +3,14 @@ "USAGE": "(command)", "EXAMPLES": "help\nhelp command:ping", "NOT_FOUND": "Команда {{command}} не найдена", - "COMMANDS_IN": "Доступные команды в категории `{{category}}`:", + "COMMANDS_IN": "Доступные команды в категории \"{{category}}\":", "FIELD_USAGE": "Использование", "FIELD_DESCRIPTION": "Описание", "FIELD_ALIASES": "Сокращения", "FIELD_EXAMPLES": "Примеры", "NO_ALIAS": "Нет сокращений", "CMD_TITLE": "Помощь по {{cmd}}", - "INFO": "● Чтобы получить помощь по определённой команде используйте `help [команда]`", + "INFO": "● Чтобы получить помощь по определённой команде используйте `/help [command:command_name]`", "FIELD_PERMISSIONS": "Необходимые права", "NO_REQUIRED_PERMISSION": "Никаких особых прав не нужно", "TITLE": "{{name}} | Команды", diff --git a/languages/ru-RU/owner/reload.json b/languages/ru-RU/owner/reload.json index db62687d..9cf98c4d 100644 --- a/languages/ru-RU/owner/reload.json +++ b/languages/ru-RU/owner/reload.json @@ -2,7 +2,6 @@ "DESCRIPTION": "Перезагрузить команду", "USAGE": "[command]", "EXAMPLES": "reload command:help", - "COMMAND": "Команда", "NOT_FOUND": "Команда `{{command}}` не найдена!", "SUCCESS": "Команда `{{command}}` успешно перезагружена!" } \ No newline at end of file diff --git a/languages/uk-UA/common.json b/languages/uk-UA/common.json index 363c1432..b40a57bf 100644 --- a/languages/uk-UA/common.json +++ b/languages/uk-UA/common.json @@ -4,11 +4,13 @@ "APPLY": "Застосувати", "AUTHOR": "Автор", "AVAILABLE_OPTIONS": "Доступні параметри:", + "CATEGORY": "Категорія", "CANCEL": "Скасувати", "CHANNEL": "Канал", "CHANNELS": "Канали", "COLOR": "Колір", "CONTENT": "Вміст", + "COMMAND": "Команда", "CREATION": "Створено", "CREDITS": "Кредити", "DATE": "Дата", @@ -20,7 +22,9 @@ "EMOJI": "Емодзі", "ENABLE": "Увімкнути", "ENABLED": "Увімкнено", - "ID": "ID сервера", + "SERVER_ID": "ID сервера", + "MESSAGE_ID": "ID повідомлення", + "USER_ID": "ID користувача", "INT": "Ціле число", "IP": "IP-адреса", "JOINED": "Приєднався", diff --git a/languages/uk-UA/fun/cat.json b/languages/uk-UA/fun/cat.json new file mode 100644 index 00000000..40cbea4d --- /dev/null +++ b/languages/uk-UA/fun/cat.json @@ -0,0 +1,5 @@ +{ + "DESCRIPTION": "Всё как с крабом, только котик", + "USAGE": "", + "EXAMPLES": "cat" +} \ No newline at end of file diff --git a/languages/uk-UA/fun/dog.json b/languages/uk-UA/fun/dog.json new file mode 100644 index 00000000..bd9550e7 --- /dev/null +++ b/languages/uk-UA/fun/dog.json @@ -0,0 +1,5 @@ +{ + "DESCRIPTION": "Вы не поверите... изображение собачки!", + "USAGE": "", + "EXAMPLES": "dog" +} \ No newline at end of file diff --git a/languages/uk-UA/general/help.json b/languages/uk-UA/general/help.json index 3248244d..c04d268f 100644 --- a/languages/uk-UA/general/help.json +++ b/languages/uk-UA/general/help.json @@ -10,7 +10,7 @@ "FIELD_EXAMPLES": "Приклади", "NO_ALIAS": "Немає скорочень", "CMD_TITLE": "Допомога з {{cmd}}", - "INFO": "● Щоб отримати допомогу по певній команді, використовуйте `help [команда]`", + "INFO": "● Щоб отримати допомогу по певній команді, використовуйте `/help [command:command_name]`", "FIELD_PERMISSIONS": "Необхідні права", "NO_REQUIRED_PERMISSION": "Жодних особливих прав не потрібно", "TITLE": "{{name}} | Команди", diff --git a/languages/uk-UA/owner/reload.json b/languages/uk-UA/owner/reload.json index 6b4d8340..b15caa70 100644 --- a/languages/uk-UA/owner/reload.json +++ b/languages/uk-UA/owner/reload.json @@ -2,7 +2,6 @@ "DESCRIPTION": "Перезавантажити команду", "USAGE": "[command]", "EXAMPLES": "reload command:help", - "COMMAND": "Команда", "NOT_FOUND": "Команда `{{command}}` не знайдена!", "SUCCESS": "Команда `{{command}}` успішно перезавантажена!" } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ef19c452..b99576bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "jaba", - "version": "4.1.16", + "version": "4.1.17", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "jaba", - "version": "4.1.16", + "version": "4.1.17", "license": "ISC", "dependencies": { "@discord-player/extractor": "^3.0.2", diff --git a/package.json b/package.json index 6710f466..b0142a75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "jaba", - "version": "4.1.16", + "version": "4.1.17", "description": "My Discord Bot", "main": "index.js", "private": true,