This commit is contained in:
JonnyBro 2022-12-07 18:43:20 +05:00
parent 236ef93ac1
commit d137003f78
19 changed files with 172 additions and 57 deletions

3
.gitignore vendored
View file

@ -22,3 +22,6 @@
# Node modules # Node modules
node_modules node_modules
yarn.lock yarn.lock
# Backups
/.backup

45
commands/Fun/cat.js Normal file
View file

@ -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;

45
commands/Fun/dog.js Normal file
View file

@ -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;

View file

@ -14,7 +14,7 @@ class Help extends BaseCommand {
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option =>
option.setName("command") option.setName("command")
.setDescription(client.translate("owner/reload:COMMAND"))), .setDescription(client.translate("common:COMMAND"))),
aliases: [], aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false ownerOnly: false
@ -40,13 +40,7 @@ class Help extends BaseCommand {
const categories = []; const categories = [];
const command = interaction.options.getString("command"); const command = interaction.options.getString("command");
if (command) { if (command) return interaction.editReply({ embeds: [ generateCommandHelp(interaction, command) ] });
const embed = generateCommandHelp(interaction, command);
return interaction.editReply({
embeds: [embed]
});
}
commands.forEach(c => { commands.forEach(c => {
if (!categories.includes(c.category)) { if (!categories.includes(c.category)) {
@ -80,42 +74,38 @@ class Help extends BaseCommand {
const collector = msg.createMessageComponentCollector({ filter, idle: (15 * 1000) }); const collector = msg.createMessageComponentCollector({ filter, idle: (15 * 1000) });
collector.on("collect", async i => { 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(); i.deferUpdate();
const arg = i?.values[0]; const arg = i?.values[0];
if (categories.includes(arg)) {
const categoryCommands = commands.filter(cmd => cmd.category === arg).map(c => { const categoryCommands = commands.filter(cmd => cmd.category === arg).map(c => {
return { return {
label: c.command.name, name: `**${c.command.name}**`,
value: c.command.name value: interaction.translate(`${arg.toLowerCase()}/${c.command.name}:DESCRIPTION`)
}; };
}); });
const commandsRow = new ActionRowBuilder() const embed = new EmbedBuilder()
.addComponents( .setColor(client.config.embed.color)
new SelectMenuBuilder() .setFooter({
.setCustomId("help_commands_select") text: client.config.embed.footer
.setPlaceholder(client.translate("common:NOTHING_SELECTED")) })
.addOptions(categoryCommands) .setAuthor({
); name: interaction.translate("general/help:COMMANDS_IN", { category: arg })
})
.addFields(categoryCommands)
.addFields([
{
name: "\u200B",
value: interaction.translate("general/help:INFO")
}
]);
return await interaction.editReply({
content: interaction.translate("general/help:COMMANDS_IN", {
category: arg
}),
components: [commandsRow]
});
} else {
const embed = generateCommandHelp(interaction, arg);
return interaction.editReply({ return interaction.editReply({
content: null, content: null,
components: [],
embeds: [embed] embeds: [embed]
}); });
} }
}
}); });
collector.on("end", () => { collector.on("end", () => {

View file

@ -35,9 +35,9 @@ class Warn extends BaseCommand {
const member = interaction.targetMember; const member = interaction.targetMember;
const memberPosition = member.roles.highest.position; const memberPosition = member.roles.highest.position;
const moderationPosition = interaction.member.roles.highest.position; const moderationPosition = interaction.member.roles.highest.position;
if (member.user.bot) return; 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"); 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"); if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition)) return interaction.error("moderation/ban:SUPERIOR", null, { ephemeral: true });
const memberData = await client.findOrCreateMember({ const memberData = await client.findOrCreateMember({
id: member.id, id: member.id,
@ -46,9 +46,7 @@ class Warn extends BaseCommand {
const modal = new ModalBuilder() const modal = new ModalBuilder()
.setCustomId("warn_modal") .setCustomId("warn_modal")
.setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { .setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { nickname: member.user.tag }).normalize("NFKD"));
nickname: member.user.tag
}));
const reasonInput = new TextInputBuilder() const reasonInput = new TextInputBuilder()
.setCustomId("warn_reason") .setCustomId("warn_reason")
@ -115,7 +113,7 @@ class Warn extends BaseCommand {
count: data.guildData.casesCount count: data.guildData.casesCount
}) })
}) })
.setColor("#e02316"); .setColor(client.config.embed.color);
interaction.guild.members.ban(member); interaction.guild.members.ban(member);
interaction.success("moderation/setwarns:AUTO_BAN", { interaction.success("moderation/setwarns:AUTO_BAN", {
username: member.user.tag, username: member.user.tag,
@ -140,7 +138,7 @@ class Warn extends BaseCommand {
count: data.guildData.casesCount count: data.guildData.casesCount
}) })
}) })
.setColor("#e88709"); .setColor(client.config.embed.color);
member.kick().catch(() => {}); member.kick().catch(() => {});
interaction.success("moderation/setwarns:AUTO_KICK", { interaction.success("moderation/setwarns:AUTO_KICK", {
username: member.user.tag, username: member.user.tag,
@ -163,7 +161,7 @@ class Warn extends BaseCommand {
name: interaction.translate("moderation/warn:CASE", { name: interaction.translate("moderation/warn:CASE", {
caseNumber: data.guildData.casesCount caseNumber: data.guildData.casesCount
}) })
}).setColor("#8c14e2"); }).setColor(client.config.embed.color);
submitted.reply({ submitted.reply({
content: interaction.translate("moderation/warn:WARNED", { content: interaction.translate("moderation/warn:WARNED", {

View file

@ -15,7 +15,7 @@ class Reload extends BaseCommand {
.setDescription(client.translate("owner/reload:DESCRIPTION")) .setDescription(client.translate("owner/reload:DESCRIPTION"))
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => option.setName("command") .addStringOption(option => option.setName("command")
.setDescription(client.translate("owner/reload:COMMAND")) .setDescription(client.translate("common:COMMAND"))
.setRequired(true)), .setRequired(true)),
aliases: [], aliases: [],
dirname: __dirname, dirname: __dirname,

View file

@ -1,3 +1,13 @@
### JaBa v4.1.17
* Добавлено
* Команды *cat* и *dog*.
* Изменения
* Переписана команда *help*.
* Исправления
* Ошибка команды *warn* если имя пользователя содержит нестандартные символы.
### JaBa v4.1.16 ### JaBa v4.1.16
* Добавлено * Добавлено
* Наконец-то возвращена и починена команда *seek*. * Наконец-то возвращена и починена команда *seek*.

View file

@ -4,11 +4,13 @@
"APPLY": "Применить", "APPLY": "Применить",
"AUTHOR": "Автор", "AUTHOR": "Автор",
"AVAILABLE_OPTIONS": "Доступные параметры:", "AVAILABLE_OPTIONS": "Доступные параметры:",
"CATEGORY": "Категория",
"CANCEL": "Отменить", "CANCEL": "Отменить",
"CHANNEL": "Канал", "CHANNEL": "Канал",
"CHANNELS": "Каналы", "CHANNELS": "Каналы",
"COLOR": "Цвет", "COLOR": "Цвет",
"CONTENT": "Содержимое", "CONTENT": "Содержимое",
"COMMAND": "Команда",
"CREATION": "Создан", "CREATION": "Создан",
"CREDITS": "Кредиты", "CREDITS": "Кредиты",
"DATE": "Дата", "DATE": "Дата",

View file

@ -0,0 +1,5 @@
{
"DESCRIPTION": "Всё как с крабом, только котик",
"USAGE": "",
"EXAMPLES": "cat"
}

View file

@ -0,0 +1,5 @@
{
"DESCRIPTION": "Вы не поверите... изображение собачки!",
"USAGE": "",
"EXAMPLES": "dog"
}

View file

@ -3,14 +3,14 @@
"USAGE": "(command)", "USAGE": "(command)",
"EXAMPLES": "help\nhelp command:ping", "EXAMPLES": "help\nhelp command:ping",
"NOT_FOUND": "Команда {{command}} не найдена", "NOT_FOUND": "Команда {{command}} не найдена",
"COMMANDS_IN": "Доступные команды в категории `{{category}}`:", "COMMANDS_IN": "Доступные команды в категории \"{{category}}\":",
"FIELD_USAGE": "Использование", "FIELD_USAGE": "Использование",
"FIELD_DESCRIPTION": "Описание", "FIELD_DESCRIPTION": "Описание",
"FIELD_ALIASES": "Сокращения", "FIELD_ALIASES": "Сокращения",
"FIELD_EXAMPLES": "Примеры", "FIELD_EXAMPLES": "Примеры",
"NO_ALIAS": "Нет сокращений", "NO_ALIAS": "Нет сокращений",
"CMD_TITLE": "Помощь по {{cmd}}", "CMD_TITLE": "Помощь по {{cmd}}",
"INFO": "● Чтобы получить помощь по определённой команде используйте `help [команда]`", "INFO": "● Чтобы получить помощь по определённой команде используйте `/help [command:command_name]`",
"FIELD_PERMISSIONS": "Необходимые права", "FIELD_PERMISSIONS": "Необходимые права",
"NO_REQUIRED_PERMISSION": "Никаких особых прав не нужно", "NO_REQUIRED_PERMISSION": "Никаких особых прав не нужно",
"TITLE": "{{name}} | Команды", "TITLE": "{{name}} | Команды",

View file

@ -2,7 +2,6 @@
"DESCRIPTION": "Перезагрузить команду", "DESCRIPTION": "Перезагрузить команду",
"USAGE": "[command]", "USAGE": "[command]",
"EXAMPLES": "reload command:help", "EXAMPLES": "reload command:help",
"COMMAND": "Команда",
"NOT_FOUND": "Команда `{{command}}` не найдена!", "NOT_FOUND": "Команда `{{command}}` не найдена!",
"SUCCESS": "Команда `{{command}}` успешно перезагружена!" "SUCCESS": "Команда `{{command}}` успешно перезагружена!"
} }

View file

@ -4,11 +4,13 @@
"APPLY": "Застосувати", "APPLY": "Застосувати",
"AUTHOR": "Автор", "AUTHOR": "Автор",
"AVAILABLE_OPTIONS": "Доступні параметри:", "AVAILABLE_OPTIONS": "Доступні параметри:",
"CATEGORY": "Категорія",
"CANCEL": "Скасувати", "CANCEL": "Скасувати",
"CHANNEL": "Канал", "CHANNEL": "Канал",
"CHANNELS": "Канали", "CHANNELS": "Канали",
"COLOR": "Колір", "COLOR": "Колір",
"CONTENT": "Вміст", "CONTENT": "Вміст",
"COMMAND": "Команда",
"CREATION": "Створено", "CREATION": "Створено",
"CREDITS": "Кредити", "CREDITS": "Кредити",
"DATE": "Дата", "DATE": "Дата",
@ -20,7 +22,9 @@
"EMOJI": "Емодзі", "EMOJI": "Емодзі",
"ENABLE": "Увімкнути", "ENABLE": "Увімкнути",
"ENABLED": "Увімкнено", "ENABLED": "Увімкнено",
"ID": "ID сервера", "SERVER_ID": "ID сервера",
"MESSAGE_ID": "ID повідомлення",
"USER_ID": "ID користувача",
"INT": "Ціле число", "INT": "Ціле число",
"IP": "IP-адреса", "IP": "IP-адреса",
"JOINED": "Приєднався", "JOINED": "Приєднався",

View file

@ -0,0 +1,5 @@
{
"DESCRIPTION": "Всё как с крабом, только котик",
"USAGE": "",
"EXAMPLES": "cat"
}

View file

@ -0,0 +1,5 @@
{
"DESCRIPTION": "Вы не поверите... изображение собачки!",
"USAGE": "",
"EXAMPLES": "dog"
}

View file

@ -10,7 +10,7 @@
"FIELD_EXAMPLES": "Приклади", "FIELD_EXAMPLES": "Приклади",
"NO_ALIAS": "Немає скорочень", "NO_ALIAS": "Немає скорочень",
"CMD_TITLE": "Допомога з {{cmd}}", "CMD_TITLE": "Допомога з {{cmd}}",
"INFO": "● Щоб отримати допомогу по певній команді, використовуйте `help [команда]`", "INFO": "● Щоб отримати допомогу по певній команді, використовуйте `/help [command:command_name]`",
"FIELD_PERMISSIONS": "Необхідні права", "FIELD_PERMISSIONS": "Необхідні права",
"NO_REQUIRED_PERMISSION": "Жодних особливих прав не потрібно", "NO_REQUIRED_PERMISSION": "Жодних особливих прав не потрібно",
"TITLE": "{{name}} | Команди", "TITLE": "{{name}} | Команди",

View file

@ -2,7 +2,6 @@
"DESCRIPTION": "Перезавантажити команду", "DESCRIPTION": "Перезавантажити команду",
"USAGE": "[command]", "USAGE": "[command]",
"EXAMPLES": "reload command:help", "EXAMPLES": "reload command:help",
"COMMAND": "Команда",
"NOT_FOUND": "Команда `{{command}}` не знайдена!", "NOT_FOUND": "Команда `{{command}}` не знайдена!",
"SUCCESS": "Команда `{{command}}` успішно перезавантажена!" "SUCCESS": "Команда `{{command}}` успішно перезавантажена!"
} }

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{ {
"name": "jaba", "name": "jaba",
"version": "4.1.16", "version": "4.1.17",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "jaba", "name": "jaba",
"version": "4.1.16", "version": "4.1.17",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"@discord-player/extractor": "^3.0.2", "@discord-player/extractor": "^3.0.2",

View file

@ -1,6 +1,6 @@
{ {
"name": "jaba", "name": "jaba",
"version": "4.1.16", "version": "4.1.17",
"description": "My Discord Bot", "description": "My Discord Bot",
"main": "index.js", "main": "index.js",
"private": true, "private": true,