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
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)
.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,42 +74,38 @@ 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];
if (categories.includes(arg)) {
const categoryCommands = commands.filter(cmd => cmd.category === arg).map(c => {
return {
label: c.command.name,
value: c.command.name
name: `**${c.command.name}**`,
value: interaction.translate(`${arg.toLowerCase()}/${c.command.name}:DESCRIPTION`)
};
});
const commandsRow = new ActionRowBuilder()
.addComponents(
new SelectMenuBuilder()
.setCustomId("help_commands_select")
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
.addOptions(categoryCommands)
);
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")
}
]);
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]
});
}
}
});
collector.on("end", () => {

View file

@ -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", {

View file

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

View file

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

View file

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

View file

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

View file

@ -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": "Приєднався",

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

View file

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

4
package-lock.json generated
View file

@ -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",

View file

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