This commit is contained in:
JonnyBro 2022-11-18 15:33:35 +05:00
parent caca0a260f
commit 545684f21a
16 changed files with 158 additions and 421 deletions

View file

@ -12,7 +12,28 @@ class Config extends BaseCommand {
.setName("config")
.setDescription(client.translate("administration/config:DESCRIPTION"))
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator),
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addSubcommand(subcommand => subcommand.setName("list")
.setDescription(client.translate("administration/config:LIST"))
)
.addSubcommand(subcommand => subcommand.setName("set")
.setDescription(client.translate("administration/config:SET"))
.addStringOption(option => option.setName("setting")
.setDescription(client.translate("administration/config:SETTING"))
.addChoices(
{ name: client.translate("administration/config:BIRTHDAYS"), value: "birthdays" },
{ name: client.translate("administration/config:MODLOGS"), value: "modlogs" },
{ name: client.translate("administration/config:NEWS"), value: "news" },
{ name: client.translate("administration/config:REPORTS"), value: "reports" },
{ name: client.translate("administration/config:SUGGESTIONS"), value: "suggestions" }
)
.setRequired(true))
.addBooleanOption(option => option.setName("state")
.setDescription(client.translate("common:STATE"))
.setRequired(true))
.addChannelOption(option => option.setName("channel")
.setDescription(client.translate("common:CHANNEL")))
),
aliases: [],
dirname: __dirname,
ownerOnly: false
@ -32,6 +53,9 @@ class Config extends BaseCommand {
* @param {Object} data
*/
async execute(client, interaction, data) {
const command = interaction.options.getSubcommand();
if (command === "list") {
const guildData = data.guildData;
const embed = new EmbedBuilder()
@ -81,30 +105,71 @@ class Config extends BaseCommand {
},
{
name: interaction.translate("administration/config:SPECIAL_CHANNELS"),
value: interaction.translate("administration/config:NEWS", {
value: interaction.translate("administration/config:NEWS_LIST", {
channel: guildData.plugins.news ? `<#${guildData.plugins.news}>` : `*${interaction.translate("common:NOT_DEFINED")}*`
}) + "\n" +
interaction.translate("administration/config:SUGGESTIONS", {
interaction.translate("administration/config:SUGGESTIONS_LIST", {
channel: guildData.plugins.suggestions ? `<#${guildData.plugins.suggestions}>` : `*${interaction.translate("common:NOT_DEFINED")}*`
}) + "\n" +
interaction.translate("administration/config:REPORTS", {
interaction.translate("administration/config:REPORTS_LIST", {
channel: guildData.plugins.reports ? `<#${guildData.plugins.reports}>` : `*${interaction.translate("common:NOT_DEFINED")}*`
}) + "\n" +
interaction.translate("administration/config:MODLOGS", {
interaction.translate("administration/config:MODLOGS_LIST", {
channel: guildData.plugins.modlogs ? `<#${guildData.plugins.modlogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`
}) + "\n" +
interaction.translate("administration/config:BIRTHDAYS", {
interaction.translate("administration/config:BIRTHDAYS_LIST", {
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})`
}
// {
// name: interaction.translate("administration/config:DASHBOARD_TITLE"),
// value: `[${interaction.translate("administration/config:DASHBOARD_CONTENT")}](${client.config.dashboard.baseURL})`
// }
]);
interaction.reply({
embeds: [embed]
embeds: [embed],
ephemeral: true
});
} else {
const setting = interaction.options.getString("setting");
const state = interaction.options.getBoolean("state");
const channel = interaction.options.getChannel("channel");
await changeSetting(interaction, setting, state, channel);
}
}
}
/**
*
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {String} setting
* @param {Boolean} state
* @param {import("discord.js").GuildTextBasedChannel} channel
* @returns
*/
async function changeSetting(interaction, setting, state, channel) {
if (!state) {
interaction.guild.data.plugins[setting] = null;
interaction.guild.data.markModified(`plugins.${setting}`);
await interaction.guild.data.save();
return interaction.reply({
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
ephemeral: true
});
} else {
if (channel) {
interaction.guild.data.plugins[setting] = channel.id;
interaction.guild.data.markModified(`plugins.${setting}`);
await interaction.guild.data.save();
return interaction.reply({
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
ephemeral: true
});
} else return interaction.reply({
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: ${interaction.guild.data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${interaction.guild.data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`}`,
ephemeral: true
});
}
}

View file

@ -1,62 +0,0 @@
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"))
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.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,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const 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;

View file

@ -1,62 +0,0 @@
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"))
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.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,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const 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;

View file

@ -1,62 +0,0 @@
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"))
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.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,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const 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;

View file

@ -1,62 +0,0 @@
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"))
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.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,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const 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;

View file

@ -1,62 +0,0 @@
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"))
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.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,
ownerOnly: false
});
}
/**
*
* @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const 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;

View file

@ -1,3 +1,12 @@
### JaBa v4.1.15
* Изменения
* Переписана команда *config*.
* Теперь с её помощью можно просматривать и изменять настройки сервера.
* Использование смотрите в *help*.
* Удалено
* Команды *setbirthdays*, *setmodlogs*, *setnews*, *setreports*, *setsuggests*.
### JaBa v4.1.14
* Добавлено
* Команда *selectroles* - Возможность выбора необязательных ролей пользователями.

View file

@ -55,7 +55,7 @@ class CommandHandler extends BaseEvent {
});
}
client.logger.log(`User ${interaction.user.tag} used ${command.command.name} in ${interaction.guild.name} with arguments: ${interaction.options.data.map(arg => { return `${arg.name}: ${arg.value}`; }).join(", ")}`, "cmd");
client.logger.log(`User ${interaction.user.tag} used ${command.command.name} in ${interaction.guild.name} with arguments: ${interaction.options.data ? interaction.options.data.map(arg => { return `${arg.name}: ${arg.value}`; }).join(", ") : "no args"}`, "cmd");
return command.execute(client, interaction, data);
}

View file

@ -1,18 +1,26 @@
{
"DESCRIPTION": "Показать настройки сервера",
"USAGE": "",
"EXAMPLES": "config",
"DESCRIPTION": "Изменить или показать настройки сервера",
"USAGE": "list\nset [setting] (state) (#channel)",
"EXAMPLES": "config list\nconfig set setting:reports state:True channel:#reports",
"LIST": "Показать настройки сервера",
"SET": "Изменить настройки сервера",
"SETTING": "Параметр",
"BIRTHDAYS": "Поздравления с днём рождения",
"MODLOGS": "Логи модерации",
"NEWS": "Новости бота",
"REPORTS": "Жалобы",
"SUGGESTIONS": "Предложения",
"NEWS_LIST": "Новости бота: {{channel}}",
"MODLOGS_LIST": "Логи модерации: {{channel}}",
"BIRTHDAYS_LIST": "Поздравления с днём рождения: {{channel}}",
"SUGGESTIONS_LIST": "Предложения: {{channel}}",
"REPORTS_LIST": "Жалобы: {{channel}}",
"AUTOROLE_TITLE": "Автоназначение роли при входе",
"WELCOME_TITLE": "Приветствие",
"WELCOME_CONTENT": "Канал: {{channel}}\nКарточка: {{withImage}}",
"GOODBYE_TITLE": "Прощание",
"GOODBYE_CONTENT": "Канал: {{channel}}\nКарточка: {{withImage}}",
"SPECIAL_CHANNELS": "Специальные каналы",
"NEWS": "Новости бота: {{channel}}",
"MODLOGS": "Логи модерации: {{channel}}",
"BIRTHDAYS": "Поздравления с днём рождения: {{channel}}",
"SUGGESTIONS": "Предложения: {{channel}}",
"REPORTS": "Жалобы: {{channel}}",
"AUTOMOD_TITLE": "Автомодерация",
"AUTOMOD_CONTENT": "Автомодерация включена.\nИгнорируемые каналы: {{channels}}",
"AUTO_SANCTIONS": "Автоматические наказания",

View file

@ -1,7 +0,0 @@
{
"DESCRIPTION": "Установить канал для поздравлений с днём рождения",
"USAGE": "[state] (#channel)",
"EXAMPLES": "setbirthdays state:True channel:#birthdays\nsetbirthdays state:False",
"ENABLED": "Поздравления включены в канале **{{channel}}**!",
"DISABLED": "Поздравления отключены!"
}

View file

@ -1,7 +0,0 @@
{
"DESCRIPTION": "Установить канал для логов модерации",
"USAGE": "[state] (#channel)",
"EXAMPLES": "setmodlogs state:True channel:#логи\nsetmodlogs state:False",
"ENABLED": "Логи модерации включены в канале **{{channel}}**!",
"DISABLED": "Логи модерации отключены!"
}

View file

@ -1,7 +0,0 @@
{
"DESCRIPTION": "Установить канал для новостей бота",
"USAGE": "[state] (#channel)",
"EXAMPLES": "setnews state:True channel:#bot-news\nsetnews state:False",
"ENABLED": "Новости бота включены в канале **{{channel}}**!",
"DISABLED": "Новости бота отключены!"
}

View file

@ -1,7 +0,0 @@
{
"DESCRIPTION": "Установить канал для жалоб",
"USAGE": "[state] (#channel)",
"EXAMPLES": "setreports state:True channel:#жалобы\nsetreports state:False",
"ENABLED": "Жалобы будут отправляться в **{{channel}}**!",
"DISABLED": "Жалобы отключены!"
}

View file

@ -1,7 +0,0 @@
{
"DESCRIPTION": "Установить канал для предложений",
"USAGE": "[state] (#channel)",
"EXAMPLES": "setsuggests state:True channel:#предложения\nsetsuggests state:False",
"ENABLED": "Предложения будут отправляться в **{{channel}}**!",
"DISABLED": "Предложения отключены!"
}

4
package-lock.json generated
View file

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

View file

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