Compare commits

..

No commits in common. "e6f239894f3ebf01aff0141261572575b8f9162c" and "aa5d328d386df40a5be4e353139881e47733a919" have entirely different histories.

7638 changed files with 711374 additions and 9866 deletions

27
.gitignore vendored
View file

@ -1,21 +1,28 @@
# Trash
.DS_Store
Thumbs.db
# Bot Configuration # Bot Configuration
/config.js /config.js
# DB # DB
/giveaways.json /giveaways.json
# commands.md
**/commands.md
# Data
/.data
# Clips # Clips
/clips/* /clips
# Mac OS files
.DS_Store
# IDE
.vscode
# Node # Node
package-lock.json
node_modules node_modules
yarn.lock
# Dashboard DB # Backups
/json.sqlite /.backup
# Cookies
cookies.json

4
.gitmodules vendored
View file

@ -1,4 +0,0 @@
[submodule "dashboard/dashboard-core"]
path = dashboard/dashboard-core
url = https://git.jonnybro.ru/jonny_bro/dashboard-core
branch = main

View file

@ -1,11 +0,0 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "lf",
"printWidth": 250,
"semi": true,
"tabWidth": 4,
"trailingComma": "all",
"useTabs": true,
"parser": "babel"
}

111
README.md
View file

@ -1,71 +1,66 @@
<img width="150" height="150" align="left" style="float: left; margin: 0 10px 0 0;" src="https://images-ext-1.discordapp.net/external/khumNb7SPgoX2KAmnB5-37LF8Hsg_gb9BithY5gaO_w/%3Fsize%3D2048/https/cdn.discordapp.com/avatars/708637495054565426/e1e9a50ec08988d1b25c13f8bd4801bd.webp"> <img width="150" height="150" align="left" style="float: left; margin: 0 10px 0 0;" src="https://cdn.discordapp.com/attachments/1005529755296206940/1090005990717534269/af98d49ebc9bf28b40b45ed5a0a623b4.webp">
# JaBa Bot # JaBa Bot
[![](https://img.shields.io/discord/892727526911258654?logo=discord&&colorB=00BFFF&label=%D0%9A%D0%BE%D0%BF%D0%B8%D0%BF%D0%B0%D1%81%D1%82%D0%B5%D1%80%D1%8B&style=flat-square)](https://discord.gg/Ptkj2n9nzZ)
[![](https://img.shields.io/discord/568120814776614924.svg?logo=discord&colorB=00BFFF&label=Atlanta%20Emojis)](https://discord.gg/NPkySYKMkN)
[![](https://img.shields.io/badge/discord.js-v14.8.0-blue.svg?logo=npm)](https://github.com/discordjs/discord.js)
[![](https://www.codefactor.io/repository/github/JonnyBro/JaBa/badge)](https://www.codefactor.io/repository/github/JonnyBro/JaBa)
[![](https://img.shields.io/github/license/JonnyBro/JaBa?label=%D0%9B%D0%B8%D1%86%D0%B5%D0%BD%D0%B7%D0%B8%D1%8F%20&style=flat-square)](https://github.com/JonnyBro/JaBa/blob/main/LICENSE)<br>
JaBa это *Discord* бот с открытым (теперь) исходным кодом, написанный [Jonny_Bro](https://github.com/JonnyBro) на JavaScript с помощью [discord.js](https://github.com/discordjs/discord.js) и [Mongoose](https://mongoosejs.com). Поставьте звёздочку если вам нравится что я делаю :3
[![image](https://img.shields.io/discord/892727526911258654?logo=discord&&colorB=00BFFF&label=Discord&style=flat-square)](https://discord.gg/Ptkj2n9nzZ) ## Функционал
[![image](https://img.shields.io/badge/discord.js-v14.14.1-blue.svg?logo=npm)](https://github.com/discordjs/discord.js) ### Готовый бот
[![image](https://www.codefactor.io/repository/github/JonnyBro/JaBa/badge)](https://www.codefactor.io/repository/github/JonnyBro/JaBa) JaBa предлагает:
[![image](https://img.shields.io/github/license/JonnyBro/JaBa?label=License&style=flat-square)](https://github.com/JonnyBro/JaBa/blob/main/LICENSE)\ * **/** Поддержка слэш-команд
JaBa is an open source Discord Bot written by [Jonny_Bro](https://github.com/JonnyBro) using [discord.js](https://github.com/discordjs/discord.js) and [Mongoose](https://mongoosejs.com). * ✉️ Поддержка команд в личных сообщениях
* 🇷🇺 Поддержка локализации (любое кол-во языков)
* ⚙️ Панель управления для настройки разнообразных параметров бота, для каждого сервера отдельно<br>
## Functionality ### Множество команд
JaBa имеет множество функций, вот **8 основных категорий**:
* 👩‍💼 **Администрирование**: `automod`, `autorole`, `config`, `goodbye`, `selectroles`, `stealemoji` и ещё **3** команды!
* 🚓 **Модерация**: `clear`, `giveaway`, `poll`, `warn` и ещё **3** команды!
* 🎵 **Музыка**: `play`, `skip`, `queue`, `nowplaying`, `shuffle` и ещё **7** команды!
* 💰 **Экономика**: `profile`, `work`, `achievements`, `slots`, `tictactoe`, `leaderboard` и ещё **12** команд!
* 👻 **Веселье**: `8ball`, `crab`, `lmgtfy`, `lovecalc`, `memes` и ещё **2** команды!
* 🖨️ **Основные**: `afk`, `avatar`, `boosters`, `minecraft`, `remindme`, `shorturl`, `serverinfo`, `userinfo`, `whois` и ещё **семь** команд!
* ❤ **NSFW**: `nsfw` =)
* 👑 **Команды владельца**: `eval`, `getinvite`, `servers-list` и ещё **2** команды!
JaBa offers: [Список изменений](/dashboard/public/docs/updates.md)<br>
[Полный список команд](http://jababot.duckdns.org:8080/docs)
* Slash and Context commands. ### *Относительно* мощная панель управления
* Supports commands in DMs. У JaBa есть своя панель управления с доступом к настройке параметров сервера и просмотру таблицы лидеров! Панель работает на Express и EJS!
* Localization support (any language; English, Russian and Ukrainian for now). <!-- <img align="left" style="float: centrer; margin: 0 10px 0 0;" src="https://zupimages.net/up/19/31/c3ya.png" height="200" width="350"/>
* Dashboard for changing various settings. <img align="center" style="float: left; margin: 0 10px 0 0;" src="https://zupimages.net/up/19/31/vnq5.png" height="200" width="350"/>
* Basic messages monitoring (updating and deletion). <img align="center" style="float: centrer; margin: 0 10px 0 0;" src="https://zupimages.net/up/19/31/htga.png" height="200" width="350"/> -->
## Commands Вы можете **настраивать параметры** каждого сервера где есть JaBa (вы должны иметь права администратора), **просматривать таблицу лидеров**, **управлять своим профилем**!
> Код панели находится в папке dashboard!
JaBa does many thing, here is **8 main categories**: ## Установка
### Приглашение бота
Вы можете пригласить JaBa на свой сервер, для этого вам нужно написать @Jonny_Bro#4226 в Discord или найти @JaBa#9042 на другом сервере.
Я решил сделать так, чтобы не было проблем с YouTube!<br><br>
### Хост своей версии
Вы можете модифицировать код JaBa и запустить его на своей машине!<br>
Для этого следуйте [данной инструкции](https://github.com/JonnyBro/JaBa/wiki/Установка-JaBa-на-своей-машине)!
* **Administration**: `automod`, `autorole`, `config`, `goodbye`, `selectroles`, `stealemoji` and **3** more! ## Ссылки
* **Moderation**: `clear`, `giveaway`, `poll`, `warn` and **4** more! * [Список команд и список изменений](http://jababot.duckdns.org/docs)
* **Music**: `play`, `skip`, `queue`, `nowplaying`, `shuffle` and **8** more! * [Инструкция по установке](https://github.com/JonnyBro/JaBa/wiki/Установка-JaBa-на-своей-машине)
* **Economy**: `profile`, `work`, `achievements`, `slots`, `tictactoe`, `leaderboard` and **9** more! * [Discord](https://discord.gg/Ptkj2n9nzZ)
* **Fun**: `8ball`, `crab`, `lmgtfy`, `lovecalc`, `memes` and **2** more! * [Github](https://github.com/JonnyBro/JaBa/)
* **General**: `afk`, `avatar`, `boosters`, `minecraft`, `remindme`, `shorturl`, `serverinfo`, `userinfo`, `whois` and **7** more! * [Панель управления](http://jababot.duckdns.org)
* **NSFW**: `nsfw` =)
* **Bot's owner commands**: `eval`, `servers`, `reload` and **2** more!
## *Kinda* Cool Dashboard ## Поддержка
Перед **созданием сообщения об ошибке или вопросе**, пожалуйста, убедитесь что оно ещё не создано: [тык](https://github.com/JonnyBro/JaBa/issues).
JaBa has it's own dashboard to change server's settings! Если у вас есть какие-либо вопросы, вы можете задать их на моём [Discord сервере](https://discord.gg/NPkySYKMkN).
Если вы хотите помочь в разработке, можете создать форк и отправить запрос на вытягивание: [тык](https://github.com/JonnyBro/JaBa/pulls)!
## Get The Bot
### Ready To Use
You can invite JaBa on your server, message me (@jonny_bro) on Discord, find @JaBa#9042 on the server that uses it or join my [Server](https://discord.gg/NPkySYKMkN).
> [!IMPORTANT]
> I'm not sharing the invite link or YouTube will cry
### Selfhosting
You can host JaBa yourself.\
Use [this instruction](https://github.com/JonnyBro/JaBa/wiki/Self-Hosting) to learn how!
## Links
* [Changelog](https://blog.jababot.ru)
* [Full commands list](https://dash.jababot.ru/commands)
* [Discord](https://discord.gg/Ptkj2n9nzZ)
* [Github](https://github.com/JonnyBro/JaBa/)
* [Dashboard](https://dash.jababot.ru)
## Support
If you have any questions you can ask them on my [Discord Server](https://discord.gg/NPkySYKMkN).\
If you want to contribute, feel free to fork this repo and making a pull request!
# TODO # TODO
- [ ] Починить панель управления 😣
* [ ] Finish and release *dashboard-core* submodule. ## Лицения
JaBa использует лицензию *GNU GPL v3.0*. Вся информация о лицензии имеется в [LICENSE](https://github.com/JonnyBro/JaBa/blob/main/LICENSE)
## License
JaBa uses *GNU GPL v3.0* license. You can find it here [LICENSE](LICENSE).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 32 KiB

BIN
assets/img/b.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
assets/img/facepalm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 KiB

BIN
assets/img/nob.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View file

@ -7,6 +7,10 @@ class BaseCommand {
* @type {import("discord.js").SlashCommandBuilder | import("discord.js").ContextMenuCommandBuilder | import("discord.js").ApplicationCommandData} * @type {import("discord.js").SlashCommandBuilder | import("discord.js").ContextMenuCommandBuilder | import("discord.js").ApplicationCommandData}
*/ */
this.command = options.command; this.command = options.command;
/**
* @type {Array<String>}
*/
this.aliases = options.aliases || [];
/** /**
* @type {Boolean} * @type {Boolean}
*/ */
@ -15,8 +19,8 @@ class BaseCommand {
/** /**
* @type {String} * @type {String}
*/ */
this.category = this.dirname ? this.dirname.split(path.sep)[parseInt(this.dirname.split(path.sep).length - 1, 10)] : "Other"; this.category = (this.dirname ? this.dirname.split(path.sep)[parseInt(this.dirname.split(path.sep).length - 1, 10)] : "Other");
} }
} }
module.exports = BaseCommand; module.exports = BaseCommand;

View file

@ -11,4 +11,4 @@ class BaseEvent {
} }
} }
module.exports = BaseEvent; module.exports = BaseEvent;

View file

@ -1,376 +0,0 @@
const { Client, Collection, SlashCommandBuilder, ContextMenuCommandBuilder, EmbedBuilder, PermissionsBitField, ChannelType } = require("discord.js"),
{ Player } = require("discord-player"),
{ GiveawaysManager } = require("discord-giveaways"),
{ REST } = require("@discordjs/rest"),
{ Routes } = require("discord-api-types/v10");
const BaseEvent = require("./BaseEvent.js"),
BaseCommand = require("./BaseCommand.js"),
path = require("path"),
fs = require("fs").promises,
mongoose = require("mongoose");
class JaBaClient extends Client {
constructor(options) {
super(options);
this.config = require("../config");
this.customEmojis = require("../emojis");
this.languages = require("../languages/language-meta");
this.commands = new Collection();
this.logger = require("../helpers/logger");
this.wait = require("node:timers/promises").setTimeout;
this.functions = require("../helpers/functions");
this.guildsData = require("../base/Guild");
this.usersData = require("../base/User");
this.membersData = require("../base/Member");
this.dashboard = require("../dashboard/dashboard");
this.states = {};
this.knownGuilds = [];
this.databaseCache = {};
this.databaseCache.users = new Collection();
this.databaseCache.guilds = new Collection();
this.databaseCache.members = new Collection();
this.databaseCache.usersReminds = new Collection();
this.player = new Player(this);
this.player.extractors.loadDefault();
this.player.events.on("playerStart", async (queue, track) => {
const m = (
await queue.metadata.channel.send({
content: this.translate("music/play:NOW_PLAYING", { songName: `${track.title} - ${track.author}` }, queue.metadata.data.guild.language),
})
).id;
if (track.durationMS > 1)
setTimeout(() => {
const message = queue.metadata.channel.messages.cache.get(m);
if (message && message.deletable) message.delete();
}, track.durationMS);
else
setTimeout(() => {
const message = queue.metadata.channel.messages.cache.get(m);
if (message && message.deletable) message.delete();
}, 5 * 60 * 1000);
});
this.player.events.on("emptyQueue", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.data.guild.language)));
this.player.events.on("emptyChannel", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.data.guild.language)));
this.player.events.on("playerError", (queue, e) => {
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.data.guild.language) });
console.log(e);
});
this.player.events.on("error", (queue, e) => {
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.data.guild.language) });
console.log(e);
});
this.giveawaysManager = new GiveawaysManager(this, {
storage: "./giveaways.json",
default: {
botsCanWin: false,
embedColor: this.config.embed.color,
embedColorEnd: "#FF0000",
reaction: "🎉",
},
});
}
/**
* Initializes the client by logging in with the provided token and connecting to the MongoDB database.
*
* This method is called during the client's startup process to set up the necessary connections and resources.
*
* @returns {Promise<void>} A Promise that resolves when the client is fully initialized.
*/
async init() {
this.login(this.config.token);
mongoose
.connect(this.config.mongoDB)
.then(() => {
this.logger.log("Connected to the Mongodb database.");
})
.catch(err => {
this.logger.error(`Unable to connect to the Mongodb database.\nError: ${err}`);
});
// const autoUpdateDocs = require("../helpers/autoUpdateDocs");
// autoUpdateDocs.update(this);
}
/**
* Loads all the commands from the specified directory and registers them with the Discord API.
*
* This method is responsible for dynamically loading all the command files from the specified directory,
* creating instances of the corresponding command classes, and registering the commands with the Discord API.
* It also handles any additional setup or initialization required by the loaded commands.
*
* @param {string} dir - The directory path where the command files are located.
* @returns {Promise<void>} A Promise that resolves when all the commands have been loaded and registered.
*/
async loadCommands(dir) {
const rest = new REST().setToken(this.config.token),
filePath = path.join(__dirname, dir),
folders = (await fs.readdir(filePath)).map(file => path.join(filePath, file)).filter(async path => (await fs.lstat(path)).isDirectory());
const commands = [];
for (let index = 0; index < folders.length; index++) {
const folder = folders[index];
if (folder.endsWith("!DISABLED")) continue;
const files = await fs.readdir(folder);
for (let index = 0; index < files.length; index++) {
const file = files[index];
if (file.endsWith(".js")) {
const Command = require(path.join(folder, file));
if (Command.prototype instanceof BaseCommand) {
const command = new Command(this);
this.commands.set(command.command.name, command);
if (command.onLoad && typeof command.onLoad === "function") await command.onLoad(this);
commands.push(command.command instanceof SlashCommandBuilder || command.command instanceof ContextMenuCommandBuilder ? command.command.toJSON() : command.command);
this.logger.log(`Successfully loaded "${file}" command file. (Command: ${command.command.name})`);
}
}
}
}
try {
if (this.config.production) await rest.put(Routes.applicationCommands(this.config.userId), { body: commands });
else await rest.put(Routes.applicationGuildCommands(this.config.userId, this.config.support.id), { body: commands });
this.logger.log("Successfully registered application commands.");
} catch (err) {
console.log(err);
}
}
/**
* Returns the default language from the list of available languages.
* @returns {Language} The default language.
*/
get defaultLanguage() {
return this.languages.find(language => language.default);
}
/**
* Translates a key using the specified locale, or the default language if no locale is provided.
* @param {string} key The translation key to look up.
* @param {any[]} args Any arguments to pass to the translation function.
* @param {string} [locale=this.defaultLanguage.name] The locale to use for the translation. Defaults to the default language.
* @returns {string} The translated string.
*/
translate(key, args, locale = this.defaultLanguage.name) {
const lang = this.translations.get(locale);
return lang(key, args);
}
/**
* Generates an EmbedBuilder instance with the provided data.
* @param {Object} data - The data to use for the embed.
* @param {string} [data.title] - The title of the embed.
* @param {string} [data.description] - The description of the embed.
* @param {string} [data.thumbnail] - The URL of the thumbnail image for the embed.
* @param {Object[]} [data.fields] - An array of field objects for the embed.
* @param {string} [data.image] - The URL of the image for the embed.
* @param {string} [data.url] - The URL to be used as the embed's hyperlink.
* @param {number} [data.color] - The color of the embed's border. If not provided, the default color from the client's configuration will be used.
* @param {string} [data.footer] - The text to be displayed as the embed's footer. If not provided, the default footer from the client's configuration will be used.
* @param {Date} [data.timestamp] - The timestamp to be displayed in the embed's footer. If not provided, the current timestamp will be used.
* @param {string|Object} [data.author] - The author information for the embed. Can be a string (name) or an object with `name` and/or `iconURL` properties.
* @returns {EmbedBuilder} The generated EmbedBuilder instance.
*/
embed(data) {
const embed = new EmbedBuilder()
.setTitle(data.title || null)
.setDescription(data.description || null)
.setThumbnail(data.thumbnail || null)
.addFields(data.fields || [])
.setImage(data.image || null)
.setURL(data.url || null);
if (data.color) embed.setColor(data.color);
else if (data.color === null) embed.setColor(null);
else embed.setColor(this.config.embed.color);
if (data.footer) embed.setFooter(data.footer);
else if (data.footer === null) embed.setFooter(null);
else embed.setFooter(this.config.embed.footer);
if (data.timestamp) embed.setTimestamp(data.timestamp);
else if (data.timestamp === null) embed.setTimestamp(null);
else embed.setTimestamp();
if (!data.author || data.author === null) embed.setAuthor(null);
else if (typeof data.author === "string") embed.setAuthor({ name: data.author, iconURL: this.user.avatarURL() });
else if (typeof data.author === "object" && (data.author.iconURL !== null || data.author.iconURL !== undefined)) embed.setAuthor({ name: data.author.name, iconURL: data.author.iconURL });
else embed.setAuthor(data.author);
return embed;
}
/**
* Creates an invite for the specified guild.
* @param {string} guildId - The ID of the guild to create the invite for.
* @returns {Promise<string>} The URL of the created invite, or an error message if no suitable channel was found or the bot lacks the necessary permissions.
*/
async createInvite(guildId) {
const guild = this.guilds.cache.get(guildId),
member = guild.members.me,
channel = guild.channels.cache.find(ch => ch.permissionsFor(member.id).has(PermissionsBitField.FLAGS.CREATE_INSTANT_INVITE) && (ch.type === ChannelType.GuildText || ch.type === ChannelType.GuildVoice));
if (channel) return (await channel.createInvite()).url || "No channels found or missing permissions";
}
/**
* Loads a command from the specified directory and file.
* @param {string} dir - The directory containing the command file.
* @param {string} file - The name of the command file (without the .js extension).
* @returns {Promise<string>} A log message indicating the successful loading of the command.
*/
async loadCommand(dir, file) {
const Command = require(path.join(dir, `${file}.js`));
if (!(Command.prototype instanceof BaseCommand)) return this.logger.error("Tried to load a non-command file!");
const command = new Command(this);
this.commands.set(command.command.name, command);
if (command.onLoad && typeof command.onLoad === "function") await command.onLoad(this);
return this.logger.log(`Successfully loaded "${file}" command file. (Command: ${command.command.name})`);
}
/**
* Unloads a command from the specified directory and file.
* @param {string} dir - The directory containing the command file.
* @param {string} name - The name of the command file (without the .js extension).
* @returns {void} This method does not return a value.
*/
async unloadCommand(dir, name) {
delete require.cache[require.resolve(`${dir}${path.sep}${name}.js`)];
return;
}
/**
* Loads all event files from the specified directory and its subdirectories.
* @param {string} dir - The directory containing the event files.
* @returns {void} This method does not return a value.
*/
async loadEvents(dir) {
const filePath = path.join(__dirname, dir);
const files = await fs.readdir(filePath);
for (let index = 0; index < files.length; index++) {
const file = files[index];
const stat = await fs.lstat(path.join(filePath, file));
if (stat.isDirectory()) this.loadEvents(path.join(dir, file));
if (file.endsWith(".js")) {
const Event = require(path.join(filePath, file));
if (Event.prototype instanceof BaseEvent) {
const event = new Event();
if (!event.name || !event.name.length) return console.error(`Cannot load "${file}" event file: Event name is not set!`);
if (event.once) this.once(event.name, event.execute.bind(event, this));
else this.on(event.name, event.execute.bind(event, this));
this.logger.log(`Successfully loaded "${file}" event file. (Event: ${event.name})`);
}
}
}
}
/**
* Finds or creates a user in the database based on the provided user ID.
* @param {string} userID - The ID of the user to find or create.
* @returns {Promise<Object>} The user data object, either retrieved from the database or newly created.
*/
async findOrCreateUser(userID) {
let userData = await this.usersData.findOne({ id: userID });
if (userData) {
this.databaseCache.users.set(userID, userData);
return userData;
} else {
userData = new this.usersData({ id: userID });
await userData.save();
this.databaseCache.users.set(userID, userData);
return userData;
}
}
/**
* Finds or creates a member in the database based on the provided member ID and guild ID.
* @param {Object} options - The options for finding or creating the member.
* @param {string} options.id - The ID of the member to find or create.
* @param {string} options.guildId - The ID of the guild the member belongs to.
* @returns {Promise<Object>} The member data object, either retrieved from the database or newly created.
*/
async findOrCreateMember({ id: memberID, guildId }) {
let memberData = await this.membersData.findOne({ guildID: guildId, id: memberID });
if (memberData) {
this.databaseCache.members.set(`${memberID}${guildId}`, memberData);
return memberData;
} else {
memberData = new this.membersData({ id: memberID, guildID: guildId });
await memberData.save();
const guildData = await this.findOrCreateGuild(guildId);
if (guildData) {
guildData.members.push(memberData._id);
await guildData.save();
}
this.databaseCache.members.set(`${memberID}${guildId}`, memberData);
return memberData;
}
}
/**
* Finds or creates a guild in the database based on the provided guild ID.
* @param {string} guildId - The ID of the guild to find or create.
* @returns {Promise<Object>} The guild data object, either retrieved from the database or newly created.
*/
async findOrCreateGuild(guildId) {
let guildData = await this.guildsData.findOne({ id: guildId }).populate("members");
if (guildData) {
this.databaseCache.guilds.set(guildId, guildData);
return guildData;
} else {
guildData = new this.guildsData({ id: guildId });
await guildData.save();
this.databaseCache.guilds.set(guildId, guildData);
return guildData;
}
}
}
module.exports = JaBaClient;

View file

@ -9,47 +9,35 @@ module.exports = mongoose.model("Guild", new Schema({
members: [{ type: Schema.Types.ObjectId, ref: "Member" }], members: [{ type: Schema.Types.ObjectId, ref: "Member" }],
language: { type: String, default: languages.find(l => l.default).name }, language: { type: String, default: languages.find(l => l.default).name },
plugins: { plugins: { type: Object, default: {
type: Object, welcome: {
default: { enabled: false,
welcome: { message: null,
enabled: false, channel: null,
message: null, withImage: null,
channel: null,
withImage: null,
},
goodbye: {
enabled: false,
message: null,
channel: null,
withImage: null,
},
autorole: {
enabled: false,
role: null,
},
automod: {
enabled: false,
ignored: [],
},
warnsSanctions: {
kick: null,
ban: null,
},
monitoring: {
messageUpdate: null,
messageDelete: null,
},
tickets: {
count: 0,
ticketLogs: null,
transcriptionLogs: null,
ticketsCategory: null,
},
suggestions: null,
reports: null,
birthdays: null,
modlogs: null,
}, },
}, goodbye: {
})); enabled: false,
message: null,
channel: null,
withImage: null,
},
autorole: {
enabled: false,
role: null,
},
automod: {
enabled: false,
ignored: [],
},
warnsSanctions: {
kick: false,
ban: false,
},
news: false,
suggestions: false,
modlogs: false,
birthdays: false,
reports: false,
} },
}));

345
base/JaBa.js Normal file
View file

@ -0,0 +1,345 @@
const { Client, Collection, SlashCommandBuilder, ContextMenuCommandBuilder } = require("discord.js"),
{ Player } = require("discord-player"),
{ GiveawaysManager } = require("discord-giveaways"),
{ REST } = require("@discordjs/rest"),
{ Routes } = require("discord-api-types/v10");
const BaseEvent = require("./BaseEvent.js"),
BaseCommand = require("./BaseCommand.js"),
path = require("path"),
fs = require("fs").promises,
mongoose = require("mongoose");
class JaBa extends Client {
constructor(options) {
super(options);
this.config = require("../config");
this.customEmojis = require("../emojis");
this.languages = require("../languages/language-meta");
this.commands = new Collection();
this.logger = require("../helpers/logger");
this.wait = require("node:timers/promises").setTimeout;
this.functions = require("../helpers/functions");
this.guildsData = require("../base/Guild");
this.usersData = require("../base/User");
this.membersData = require("../base/Member");
this.dashboard = require("../dashboard/app");
this.states = {};
this.knownGuilds = [];
this.databaseCache = {};
this.databaseCache.users = new Collection();
this.databaseCache.guilds = new Collection();
this.databaseCache.members = new Collection();
this.databaseCache.usersReminds = new Collection();
this.databaseCache.mutedUsers = new Collection();
this.player = Player.singleton(this, {
autoRegisterExtractor: false,
});
this.player.events.on("playerStart", async (queue, track) => {
const m = await queue.metadata.channel.send({ content: this.translate("music/play:NOW_PLAYING", { songName: track.title }, queue.metadata.channel.guild.data.language) });
if (track.durationMS > 1)
setTimeout(() => {
if (m.deletable) m.delete();
}, track.durationMS);
else
setTimeout(() => {
if (m.deletable) m.delete();
}, (5 * 60 * 1000)); // m * s * ms
});
this.player.events.on("emptyQueue", queue => queue.metadata.channel.send(this.translate("music/play:QUEUE_ENDED", null, queue.metadata.channel.guild.data.language)));
this.player.events.on("emptyChannel", queue => queue.metadata.channel.send(this.translate("music/play:STOP_EMPTY", null, queue.metadata.channel.guild.data.language)));
this.player.events.on("playerError", (queue, e) => {
console.log(e);
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.channel.guild.data.language) });
});
this.player.events.on("error", (queue, e) => {
console.log(e);
queue.metadata.channel.send({ content: this.translate("music/play:ERR_OCCURRED", { error: e.message }, queue.metadata.channel.guild.data.language) });
});
this.giveawaysManager = new GiveawaysManager(this, {
storage: "./giveaways.json",
default: {
botsCanWin: false,
embedColor: this.config.embed.color,
embedColorEnd: "#FF0000",
reaction: "🎉",
},
});
}
/**
* Login into bot account, connect to DB and update docs
*/
async init() {
this.login(this.config.token);
mongoose.connect(this.config.mongoDB, {
useNewUrlParser: true,
useUnifiedTopology: true,
}).then(() => {
this.logger.log("Connected to the Mongodb database.", "log");
}).catch(err => {
this.logger.log(`Unable to connect to the Mongodb database. Error: ${err}`, "error");
});
await this.player.extractors.loadDefault();
const autoUpdateDocs = require("../helpers/autoUpdateDocs");
autoUpdateDocs.update(this);
}
/**
* Load commands from directory
* @param {String} dir Directory where's all commands located
* @returns
*/
async loadCommands(dir) {
const rest = new REST().setToken(this.config.token),
filePath = path.join(__dirname, dir),
folders = (await fs.readdir(filePath))
.map(file => path.join(filePath, file))
.filter(async path => (await fs.lstat(path)).isDirectory());
const commands = [];
for (let index = 0; index < folders.length; index++) {
const folder = folders[index];
if (folder.endsWith("!DISABLED")) continue;
const files = await fs.readdir(folder);
for (let index = 0; index < files.length; index++) {
const file = files[index];
if (file.endsWith(".js")) {
const Command = require(path.join(folder, file));
if (Command.prototype instanceof BaseCommand) {
const command = new Command(this);
this.commands.set(command.command.name, command);
const aliases = [];
if (command.aliases && Array.isArray(command.aliases) && command.aliases.length > 0)
command.aliases.forEach(alias => {
const command_alias = (command.command instanceof SlashCommandBuilder || command.command instanceof ContextMenuCommandBuilder) ? { ...command.command.toJSON() } : { ...command.command };
command_alias.name = alias;
aliases.push(command_alias);
this.commands.set(alias, command);
});
commands.push((command.command instanceof SlashCommandBuilder || command.command instanceof ContextMenuCommandBuilder) ? command.command.toJSON() : command.command, ...aliases);
if (command.onLoad || typeof command.onLoad === "function") await command.onLoad(this);
this.logger.log(`Successfully loaded "${file}" command file. (Command: ${command.command.name})`);
}
}
}
}
try {
if (this.config.production)
await rest.put(
Routes.applicationCommands(this.config.user), {
body: commands,
},
);
else
await rest.put(
Routes.applicationGuildCommands(this.config.user, this.config.support.id), {
body: commands,
},
);
this.logger.log("Successfully registered application commands.");
} catch (err) {
this.logger.log("Cannot load commands: " + err.message, "error");
}
}
/**
* Load single command in directory
* @param {String} dir Directory where command is
* @param {String} file Filename of the command
*/
async loadCommand(dir, file) {
const Command = require(path.join(dir, `${file}.js`));
if (Command.prototype instanceof BaseCommand) {
const command = new Command(this);
this.commands.set(command.command.name, command);
const aliases = [];
if (command.aliases && Array.isArray(command.aliases) && command.aliases.length > 0)
command.aliases.forEach(alias => {
const command_alias = command.command instanceof SlashCommandBuilder ? { ...command.command.toJSON() } : { ...command.command };
command_alias.name = alias;
aliases.push(command_alias);
this.commands.set(alias, command);
});
if (command.onLoad || typeof command.onLoad === "function") await command.onLoad(this);
this.logger.log(`Successfully loaded "${file}" command file. (Command: ${command.command.name})`);
return;
}
}
/**
* Unload command from cache
* @param {String} dir Directory of the command
* @param {String} name Name of the command
*/
async unloadCommand(dir, name) {
delete require.cache[require.resolve(`${dir}${path.sep}${name}.js`)];
return;
}
/**
* Load events from directory
* @param {String} dir Directory where's all events located
* @returns
*/
async loadEvents(dir) {
const filePath = path.join(__dirname, dir);
const files = await fs.readdir(filePath);
for (let index = 0; index < files.length; index++) {
const file = files[index];
const stat = await fs.lstat(path.join(filePath, file));
if (stat.isDirectory()) this.loadEvents(path.join(dir, file));
if (file.endsWith(".js")) {
const Event = require(path.join(filePath, file));
if (Event.prototype instanceof BaseEvent) {
const event = new Event();
if (!event.name || !event.name.length) return console.error(`Cannot load "${file}" event file: Event name is not set!`);
if (event.once) this.once(event.name, event.execute.bind(event, this));
else this.on(event.name, event.execute.bind(event, this));
this.logger.log(`Successfully loaded "${file}" event file. (Event: ${event.name})`);
}
}
}
}
/**
* Get default language
* @returns {String} Default bot's language
*/
get defaultLanguage() {
return this.languages.find(language => language.default).name;
}
/**
* Translate from key to language
* @param {String} key Key
* @param {Array} args Arguments for translation
* @param {String} locale Language
*/
translate(key, args, locale = this.defaultLanguage) {
const language = this.translations.get(locale);
if (!language) throw "Invalid language set in data.";
return language(key, args);
}
/**
* Find or create user in DB
* @param {Array} param0 { id: User ID }
* @param {Boolean} isLean Return JSON instead Mongoose model?
* @returns {import("./User")} Mongoose model or JSON of this user
*/
async findOrCreateUser({ id: userID }, isLean) {
if (this.databaseCache.users.get(userID)) return isLean ? this.databaseCache.users.get(userID).toJSON() : this.databaseCache.users.get(userID);
else {
let userData = (isLean ? await this.usersData.findOne({
id: userID,
}).lean() : await this.usersData.findOne({
id: userID,
}));
if (userData) {
if (!isLean) this.databaseCache.users.set(userID, userData);
return userData;
} else {
userData = new this.usersData({
id: userID,
});
await userData.save();
this.databaseCache.users.set(userID, userData);
return isLean ? userData.toJSON() : userData;
}
}
}
/**
* Find or create member in DB
* @param {Array} param0 { id: Member ID }
* @param {Boolean} isLean Return JSON instead Mongoose model?
* @returns {import("./Member")} Mongoose model or JSON of this member
*/
async findOrCreateMember({ id: memberID, guildId }, isLean) {
if (this.databaseCache.members.get(`${memberID}${guildId}`)) return isLean ? this.databaseCache.members.get(`${memberID}${guildId}`).toJSON() : this.databaseCache.members.get(`${memberID}${guildId}`);
else {
let memberData = (isLean ? await this.membersData.findOne({
guildID: guildId,
id: memberID,
}).lean() : await this.membersData.findOne({
guildID: guildId,
id: memberID,
}));
if (memberData) {
if (!isLean) this.databaseCache.members.set(`${memberID}${guildId}`, memberData);
return memberData;
} else {
memberData = new this.membersData({
id: memberID,
guildID: guildId,
});
await memberData.save();
const guild = await this.findOrCreateGuild({
id: guildId,
});
if (guild) {
guild.members.push(memberData._id);
await guild.save();
}
this.databaseCache.members.set(`${memberID}${guildId}`, memberData);
return isLean ? memberData.toJSON() : memberData;
}
}
}
/**
* Find or create guild in DB
* @param {Array} param0 { id: Guild ID }
* @param {Boolean} isLean Return JSON instead Mongoose model?
* @returns {import("./Guild")} Mongoose model or JSON of this guild
*/
async findOrCreateGuild({ id: guildId }, isLean) {
if (this.databaseCache.guilds.get(guildId)) return isLean ? this.databaseCache.guilds.get(guildId).toJSON() : this.databaseCache.guilds.get(guildId);
else {
let guildData = (isLean ? await this.guildsData.findOne({
id: guildId,
}).populate("members").lean() : await this.guildsData.findOne({
id: guildId,
}).populate("members"));
if (guildData) {
if (!isLean) this.databaseCache.guilds.set(guildId, guildData);
return guildData;
} else {
guildData = new this.guildsData({
id: guildId,
});
await guildData.save();
this.databaseCache.guilds.set(guildId, guildData);
return isLean ? guildData.toJSON() : guildData;
}
}
}
}
module.exports = JaBa;

View file

@ -13,21 +13,15 @@ module.exports = mongoose.model("Member", new mongoose.Schema({
registeredAt: { type: Number, default: Date.now() }, registeredAt: { type: Number, default: Date.now() },
cooldowns: { cooldowns: { type: Object, default: {
type: Object, work: 0,
default: { rob: 0,
work: 0, } },
rob: 0,
},
},
sanctions: { type: Array, default: [] }, sanctions: { type: Array, default: [] },
mute: { mute: { type: Object, default: {
type: Object, muted: false,
default: { case: null,
muted: false, endDate: null,
case: null, } },
endDate: null, }));
},
},
}));

View file

@ -4,7 +4,8 @@ const mongoose = require("mongoose"),
const genToken = () => { const genToken = () => {
let token = ""; let token = "";
const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwzy0123456789.-_"; const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwzy0123456789.-_";
for (let i = 0; i < 32; i++) token += characters.charAt(Math.floor(Math.random() * characters.length)); for (let i = 0; i < 32; i++)
token += characters.charAt(Math.floor(Math.random() * characters.length));
return token; return token;
}; };
@ -19,67 +20,61 @@ const userSchema = new mongoose.Schema({
registeredAt: { type: Number, default: Date.now() }, registeredAt: { type: Number, default: Date.now() },
achievements: { achievements: { type: Object, default: {
type: Object, married: {
default: { achieved: false,
married: { progress: {
achieved: false, now: 0,
progress: { total: 1,
now: 0,
total: 1,
},
},
work: {
achieved: false,
progress: {
now: 0,
total: 10,
},
},
firstCommand: {
achieved: false,
progress: {
now: 0,
total: 1,
},
},
slots: {
achieved: false,
progress: {
now: 0,
total: 3,
},
},
tip: {
achieved: false,
progress: {
now: 0,
total: 1,
},
},
rep: {
achieved: false,
progress: {
now: 0,
total: 20,
},
},
invite: {
achieved: false,
progress: {
now: 0,
total: 1,
},
}, },
}, },
}, work: {
achieved: false,
progress: {
now: 0,
total: 10,
},
},
firstCommand: {
achieved: false,
progress: {
now: 0,
total: 1,
},
},
slots: {
achieved: false,
progress: {
now: 0,
total: 3,
},
},
tip: {
achieved: false,
progress: {
now: 0,
total: 1,
},
},
rep: {
achieved: false,
progress: {
now: 0,
total: 20,
},
},
invite: {
achieved: false,
progress: {
now: 0,
total: 1,
},
},
} },
cooldowns: { cooldowns: { type: Object, default: {
type: Object, rep: 0,
default: { } },
rep: 0,
},
},
afk: { type: String, default: null }, afk: { type: String, default: null },
reminds: { type: Array, default: [] }, reminds: { type: Array, default: [] },
@ -87,7 +82,7 @@ const userSchema = new mongoose.Schema({
apiToken: { type: String, default: genToken() }, apiToken: { type: String, default: genToken() },
}); });
userSchema.method("getAchievements", async function () { userSchema.method("getAchievements", async function() {
const canvas = Canvas.createCanvas(1800, 250), const canvas = Canvas.createCanvas(1800, 250),
ctx = canvas.getContext("2d"); ctx = canvas.getContext("2d");
@ -110,4 +105,4 @@ userSchema.method("getAchievements", async function () {
return canvas.toBuffer(); return canvas.toBuffer();
}); });
module.exports = mongoose.model("User", userSchema); module.exports = mongoose.model("User", userSchema);

View file

@ -1,73 +0,0 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Ban extends BaseCommand {
/**
*
* @param {import("../../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("ban")
.setDescription(client.translate("moderation/ban:DESCRIPTION"))
.setDescriptionLocalizations({
uk: client.translate("moderation/ban:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/ban:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.BanMembers)
.addUserOption(option =>
option
.setName("user")
.setDescription(client.translate("common:USER"))
.setDescriptionLocalizations({
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true),
)
.addStringOption(option =>
option
.setName("reason")
.setDescription(client.translate("common:REASON"))
.setDescriptionLocalizations({
uk: client.translate("common:REASON", null, "uk-UA"),
ru: client.translate("common:REASON", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
await interaction.deferReply();
const member = interaction.options.getMember("user"),
reason = interaction.options.getString("reason"),
memberPosition = member.roles.highest.position,
moderationPosition = interaction.member.roles.highest.position;
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true, edit: true });
if (member.id === interaction.member.id) return interaction.error("moderation/ban:YOURSELF", null, { ephemeral: true, edit: true });
if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition) && member.bannable) return interaction.error("moderation/ban:SUPERIOR", null, { ephemeral: true, edit: true });
await member.ban({
reason,
});
interaction.success("moderation/ban:SUCCESS", {
user: member.user.toString(),
reason,
}, { edit: true });
}
}
module.exports = Ban;

View file

@ -5,39 +5,40 @@ const BaseCommand = require("../../base/BaseCommand");
class ImportMee6 extends BaseCommand { class ImportMee6 extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
command: new SlashCommandBuilder() command: new SlashCommandBuilder()
.setName("importmee6") .setName("importmee6")
.setDescription(client.translate("economy/importmee6:DESCRIPTION")) .setDescription(client.translate("economy/importmee6:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({ "uk": client.translate("economy/importmee6:DESCRIPTION", null, "uk-UA") })
uk: client.translate("economy/importmee6:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/importmee6:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
await interaction.deferReply(); await interaction.deferReply();
const level = (await Mee6Api.getUserXp(interaction.guildId, interaction.member)).level; const level = (await Mee6Api.getUserXp(interaction.guildId, interaction.member)).level;
interaction.data.member.level = level; data.memberData.level = level;
interaction.data.member.exp = 0; await data.memberData.save();
interaction.data.member.markModified("level");
interaction.data.member.markModified("exp");
await interaction.data.member.save();
interaction.editReply({ interaction.editReply({
content: interaction.translate("owner/debug:SUCCESS_LEVEL", { content: interaction.translate("owner/debug:SUCCESS_LEVEL", {
@ -48,4 +49,4 @@ class ImportMee6 extends BaseCommand {
} }
} }
module.exports = ImportMee6; module.exports = ImportMee6;

View file

@ -1,73 +0,0 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Kick extends BaseCommand {
/**
*
* @param {import("../../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("kick")
.setDescription(client.translate("moderation/kick:DESCRIPTION"))
.setDescriptionLocalizations({
uk: client.translate("moderation/kick:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/kick:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.KickMembers)
.addUserOption(option =>
option
.setName("user")
.setDescription(client.translate("common:USER"))
.setDescriptionLocalizations({
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true),
)
.addStringOption(option =>
option
.setName("reason")
.setDescription(client.translate("common:REASON"))
.setDescriptionLocalizations({
uk: client.translate("common:REASON", null, "uk-UA"),
ru: client.translate("common:REASON", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
await interaction.deferReply();
const member = interaction.options.getMember("user"),
reason = interaction.options.getString("reason"),
memberPosition = member.roles.highest.position,
moderationPosition = interaction.member.roles.highest.position;
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true, edit: true });
if (member.id === interaction.member.id) return interaction.error("moderation/kick:YOURSELF", null, { ephemeral: true, edit: true });
if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition) && member.kickable) return interaction.error("moderation/kick:SUPERIOR", null, { ephemeral: true, edit: true });
await member.kick({
reason,
});
interaction.success("moderation/kick:SUCCESS", {
user: member.user.toString(),
reason,
}, { edit: true });
}
}
module.exports = Kick;

View file

@ -1,11 +1,11 @@
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
fetch = require("node-fetch"); fetch = require("node-fetch");
class Memes extends BaseCommand { class Memes extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,67 +13,84 @@ class Memes extends BaseCommand {
.setName("memes") .setName("memes")
.setDescription(client.translate("fun/memes:DESCRIPTION")) .setDescription(client.translate("fun/memes:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("fun/memes:DESCRIPTION", null, "uk-UA"), "uk": client.translate("fun/memes:DESCRIPTION", null, "uk-UA"),
ru: client.translate("fun/memes:DESCRIPTION", null, "ru-RU"), "ru": client.translate("fun/memes:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
async onLoad(client) { async onLoad() {
client.on("interactionCreate", async interaction => { //...
if (!interaction.isStringSelectMenu()) return; }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();
if (interaction.customId === "memes_select") { const tags = ["funny", "memes", "dankmemes", "me_irl", "wholesomememes"].map(tag =>
interaction.deferUpdate(); JSON.parse(JSON.stringify({
label: tag,
value: tag,
})),
);
interaction.guild.data = await client.findOrCreateGuild(interaction.guildId); const row = new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId("memes_select")
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
.addOptions(tags),
);
const tag = interaction.values[0]; const msg = await interaction.editReply({
content: interaction.translate("common:AVAILABLE_OPTIONS"),
fetchReply: true,
components: [row],
});
const filter = i => i.user.id === interaction.user.id;
const collector = msg.createMessageComponentCollector({ filter, idle: (2 * 60 * 1000) });
collector.on("collect", async i => {
if (i.isStringSelectMenu() && i.customId === "memes_select") {
i.deferUpdate();
const tag = i.values[0];
const res = await fetch(`https://meme-api.com/gimme/${tag}`).then(response => response.json()); const res = await fetch(`https://meme-api.com/gimme/${tag}`).then(response => response.json());
const embed = client.embed({ const embed = new EmbedBuilder()
title: res.title, .setColor(client.config.embed.color)
description: `${interaction.translate("fun/memes:SUBREDDIT")}: **${res.subreddit}**\n${interaction.translate("common:AUTHOR")}: **${res.author}**\n${interaction.translate("fun/memes:UPS")}: **${res.ups}**`, .setFooter({
image: res.url, text: client.config.embed.footer,
}); })
.setTitle(res.title)
.setDescription(`${interaction.translate("fun/memes:SUBREDDIT")}: **${res.subreddit}**\n${interaction.translate("common:AUTHOR")}: **${res.author}**\n${interaction.translate("fun/memes:UPS")}: **${res.ups}**`)
.setImage(res.url)
.setTimestamp();
await interaction.editReply({ await interaction.editReply({
embeds: [embed], embeds: [embed],
}); });
} }
}); });
}
/** collector.on("end", () => {
* return interaction.editReply({
* @param {import("../../base/Client")} client components: [],
* @param {import("discord.js").ChatInputCommandInteraction} interaction });
*/
async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });
const tags = ["funny", "memes", "dankmemes", "me_irl", "wholesomememes"].map(tag =>
JSON.parse(
JSON.stringify({
label: tag,
value: tag,
}),
),
);
const row = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder().setCustomId("memes_select").setPlaceholder(interaction.translate("common:NOTHING_SELECTED")).addOptions(tags));
await interaction.editReply({
components: [row],
}); });
} }
} }
module.exports = Memes; module.exports = Memes;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Staff extends BaseCommand { class Staff extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,47 +12,52 @@ class Staff extends BaseCommand {
.setName("staff") .setName("staff")
.setDescription(client.translate("general/staff:DESCRIPTION")) .setDescription(client.translate("general/staff:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/staff:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/staff:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/staff:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/staff:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.guild.members.fetch(); await interaction.guild.members.fetch();
const administrators = interaction.guild.members.cache.filter(m => m.permissions.has(PermissionsBitField.Flags.Administrator) && !m.user.bot); const administrators = interaction.guild.members.cache.filter(m => m.permissions.has(PermissionsBitField.Flags.Administrator) && !m.user.bot);
const moderators = interaction.guild.members.cache.filter(m => !administrators.has(m.id) && m.permissions.has(PermissionsBitField.Flags.ManageMessages) && !m.user.bot); const moderators = interaction.guild.members.cache.filter(m => !administrators.has(m.id) && m.permissions.has(PermissionsBitField.Flags.ManageMessages) && !m.user.bot);
const embed = new EmbedBuilder()
const embed = client.embed({ .setAuthor({
author: {
name: interaction.translate("general/staff:TITLE", { name: interaction.translate("general/staff:TITLE", {
guild: interaction.guild.name, guild: interaction.guild.name,
}), }),
iconURL: interaction.guild.iconURL(), })
}, .addFields([
fields: [
{ {
name: interaction.translate("general/staff:ADMINS"), name: interaction.translate("general/staff:ADMINS"),
value: value: (administrators.size > 0 ? administrators.map(a => `${a.presence ? client.customEmojis.status[a.presence.status] : client.customEmojis.status.offline} | <@${a.user.id}>`).join("\n") : interaction.translate("general/staff:NO_ADMINS")),
administrators.size > 0
? administrators.map(a => `${a.presence ? client.customEmojis.status[a.presence.status] : client.customEmojis.status.offline} | <@${a.user.id}>`).join("\n")
: interaction.translate("general/staff:NO_ADMINS"),
}, },
{ {
name: interaction.translate("general/staff:MODS"), name: interaction.translate("general/staff:MODS"),
value: moderators.size > 0 ? moderators.map(m => `${m.presence ? client.customEmojis.status[m.presence.status] : client.customEmojis.status.offline} | <@${m.user.id}>`).join("\n") : interaction.translate("general/staff:NO_MODS"), value: (moderators.size > 0 ? moderators.map(m => `${m.presence ? client.customEmojis.status[m.presence.status] : client.customEmojis.status.offline} | <@${m.user.id}>`).join("\n") : interaction.translate("general/staff:NO_MODS")),
}, },
], ])
}); .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
@ -60,4 +65,4 @@ class Staff extends BaseCommand {
} }
} }
module.exports = Staff; module.exports = Staff;

View file

@ -1,73 +0,0 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Addemoji extends BaseCommand {
/**
*
* @param {import("../../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("addemoji")
.setDescription(client.translate("administration/addemoji:DESCRIPTION"))
.setDescriptionLocalizations({
uk: client.translate("administration/addemoji:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/addemoji:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
.addStringOption(option =>
option
.setName("link")
.setDescription(client.translate("common:LINK"))
.setDescriptionLocalizations({
uk: client.translate("common:LINK", null, "uk-UA"),
ru: client.translate("common:LINK", null, "ru-RU"),
})
.setRequired(true),
)
.addStringOption(option =>
option
.setName("name")
.setDescription(client.translate("common:NAME"))
.setDescriptionLocalizations({
uk: client.translate("common:NAME", null, "uk-UA"),
ru: client.translate("common:NAME", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
const link = interaction.options.getString("link"),
name = interaction.options.getString("name");
interaction.guild.emojis
.create({
name: name,
attachment: link,
})
.then(emoji =>
interaction.success("administration/stealemoji:SUCCESS", {
emoji: emoji.name,
}, { ephemeral: true }),
)
.catch(e => {
interaction.error("administration/stealemoji:ERROR", {
emoji: name,
e,
}, { ephemeral: true });
});
}
}
module.exports = Addemoji;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField, ChannelType } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Automod extends BaseCommand { class Automod extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,87 +12,77 @@ class Automod extends BaseCommand {
.setName("automod") .setName("automod")
.setDescription(client.translate("administration/automod:DESCRIPTION")) .setDescription(client.translate("administration/automod:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/automod:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/automod:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/automod:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/automod:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addSubcommand(subcommand => .addBooleanOption(option => option.setName("state")
subcommand .setDescription(client.translate("common:STATE"))
.setName("toggle") .setDescriptionLocalizations({
.setDescription(client.translate("administration/automod:TOGGLE")) "uk": client.translate("common:STATE", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:STATE", null, "ru-RU"),
uk: client.translate("administration/automod:TOGGLE", null, "uk-UA"), })
ru: client.translate("administration/automod:TOGGLE", null, "ru-RU"), .setRequired(true))
}) .addChannelOption(option => option.setName("channel")
.addBooleanOption(option => .setDescription(client.translate("common:CHANNEL"))
option .setDescriptionLocalizations({
.setName("state") "uk": client.translate("common:CHANNEL", null, "uk-UA"),
.setDescription(client.translate("common:STATE")) "ru": client.translate("common:CHANNEL", null, "ru-RU"),
.setDescriptionLocalizations({ })
uk: client.translate("common:STATE", null, "uk-UA"), .addChannelTypes(ChannelType.GuildText)),
ru: client.translate("common:STATE", null, "ru-RU"), aliases: [],
})
.setRequired(true),
),
)
.addSubcommand(subcommand =>
subcommand
.setName("ignore")
.setDescription(client.translate("administration/automod:IGNORE"))
.setDescriptionLocalizations({
uk: client.translate("administration/automod:IGNORE", null, "uk-UA"),
ru: client.translate("administration/automod:IGNORE", null, "ru-RU"),
})
.addChannelOption(option =>
option
.setName("channel")
.setDescription(client.translate("common:CHANNEL"))
.setDescriptionLocalizations({
uk: client.translate("common:CHANNEL", null, "uk-UA"),
ru: client.translate("common:CHANNEL", null, "ru-RU"),
})
.addChannelTypes(ChannelType.GuildText)
.setRequired(true),
),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const { data } = interaction, //...
state = interaction.options.getBoolean("state"), }
channel = interaction.options.getChannel("channel"), /**
command = interaction.options.getSubcommand(); *
* @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"),
channel = interaction.options.getChannel("channel");
if (command === "toggle") { if (state) {
data.guild.plugins.automod = { data.guildData.plugins.automod = {
enabled: state, enabled: true,
ignored: [], ignored: [],
}; };
data.guildData.markModified("plugins.automod");
await data.guildData.save();
data.guild.markModified("plugins.automod"); return interaction.success("administration/automod:ENABLED");
await data.guild.save(); } else {
if (channel) {
data.guildData.plugins.automod.ignored.push(channel);
data.guildData.markModified("plugins.automod");
await data.guildData.save();
interaction.success(`administration/automod:${state ? "ENABLED" : "DISABLED"}`); interaction.success("administration/automod:DISABLED_CHANNEL", {
} else if (command === "ignore") { channel: channel.toString(),
data.guild.plugins.automod.ignored.push(channel.id); });
} else {
data.guildData.plugins.automod = {
enabled: false,
ignored: [],
};
data.guildData.markModified("plugins.automod");
await data.guildData.save();
data.guild.markModified("plugins.automod"); interaction.success("administration/automod:DISABLED");
await data.guild.save(); }
interaction.success("administration/automod:DISABLED_CHANNEL", {
channel: channel.toString(),
});
} }
} }
} }
module.exports = Automod; module.exports = Automod;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Autorole extends BaseCommand { class Autorole extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,66 +12,70 @@ class Autorole extends BaseCommand {
.setName("autorole") .setName("autorole")
.setDescription(client.translate("administration/autorole:DESCRIPTION")) .setDescription(client.translate("administration/autorole:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/autorole:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/autorole:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/autorole:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/autorole:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addBooleanOption(option => .addBooleanOption(option => option.setName("state")
option .setDescription(client.translate("common:STATE"))
.setName("state") .setDescriptionLocalizations({
.setDescription(client.translate("common:STATE")) "uk": client.translate("common:STATE", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:STATE", null, "ru-RU"),
uk: client.translate("common:STATE", null, "uk-UA"), })
ru: client.translate("common:STATE", null, "ru-RU"), .setRequired(true))
}) .addRoleOption(option => option.setName("role")
.setRequired(true), .setDescription(client.translate("common:ROLE"))
) .setDescriptionLocalizations({
.addRoleOption(option => "uk": client.translate("common:ROLE", null, "uk-UA"),
option "ru": client.translate("common:ROLE", null, "ru-RU"),
.setName("role") })),
.setDescription(client.translate("common:ROLE")) aliases: [],
.setDescriptionLocalizations({
uk: client.translate("common:ROLE", null, "uk-UA"),
ru: client.translate("common:ROLE", null, "ru-RU"),
}),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const guildData = interaction.data.guild, //...
state = interaction.options.getBoolean("state"), }
role = interaction.options.getRole("role"); /**
*
* @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");
guildData.plugins.autorole = { if (state) {
enabled: state, const role = interaction.options.getRole("role");
role, if (!role) return interaction.error("administration/autorole:MISSING_ROLE");
};
if (state && role) { data.guildData.plugins.autorole = {
guildData.markModified("plugins.autorole"); enabled: true,
await guildData.save(); role: role.id,
};
data.guildData.markModified("plugins.autorole");
await data.guildData.save();
interaction.success("administration/autorole:ENABLED", { interaction.success("administration/autorole:SUCCESS_ENABLED", {
role: role.toString(), role: role.toString(),
}); });
} else { } else {
guildData.plugins.autorole.enabled = false; data.guildData.plugins.autorole = {
enabled: false,
role: null,
};
data.guildData.markModified("plugins.autorole");
await data.guildData.save();
guildData.markModified("plugins.autorole"); interaction.success("administration/autorole:SUCCESS_DISABLED");
await guildData.save();
interaction.success("administration/autorole:DISABLED");
} }
} }
} }
module.exports = Autorole; module.exports = Autorole;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField, ChannelType } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Config extends BaseCommand { class Config extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,155 +12,144 @@ class Config extends BaseCommand {
.setName("config") .setName("config")
.setDescription(client.translate("administration/config:DESCRIPTION")) .setDescription(client.translate("administration/config:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/config:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/config:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/config:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/config:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("list")
subcommand .setDescription(client.translate("administration/config:LIST"))
.setName("list") .setDescriptionLocalizations({
.setDescription(client.translate("administration/config:LIST")) "uk": client.translate("administration/config:LIST", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("administration/config:LIST", null, "ru-RU"),
uk: client.translate("administration/config:LIST", null, "uk-UA"), }),
ru: client.translate("administration/config:LIST", null, "ru-RU"),
}),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("set")
subcommand .setDescription(client.translate("administration/config:SET"))
.setName("set") .setDescriptionLocalizations({
.setDescription(client.translate("administration/config:SET")) "uk": client.translate("administration/config:SET", null, "uk-UA"),
"ru": client.translate("administration/config:SET", null, "ru-RU"),
})
.addStringOption(option => option.setName("setting")
.setDescription(client.translate("administration/config:SETTING"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/config:SET", null, "uk-UA"), "uk": client.translate("administration/config:SETTING", null, "uk-UA"),
ru: client.translate("administration/config:SET", null, "ru-RU"), "ru": client.translate("administration/config:SETTING", null, "ru-RU"),
}) })
.addStringOption(option => .setChoices(
option { name: client.translate("administration/config:BIRTHDAYS"), value: "birthdays" },
.setName("setting") { name: client.translate("administration/config:MODLOGS"), value: "modlogs" },
.setDescription(client.translate("administration/config:SETTING")) { name: client.translate("administration/config:NEWS"), value: "news" },
.setDescriptionLocalizations({ { name: client.translate("administration/config:REPORTS"), value: "reports" },
uk: client.translate("administration/config:SETTING", null, "uk-UA"), { name: client.translate("administration/config:SUGGESTIONS"), value: "suggestions" },
ru: client.translate("administration/config:SETTING", null, "ru-RU"),
})
.setChoices(
{ name: client.translate("administration/config:BIRTHDAYS"), value: "birthdays" },
{ name: client.translate("administration/config:MODLOGS"), value: "modlogs" },
{ name: client.translate("administration/config:REPORTS"), value: "reports" },
{ name: client.translate("administration/config:SUGGESTIONS"), value: "suggestions" },
{ name: client.translate("administration/config:TICKETSCATEGORY"), value: "tickets.ticketsCategory" },
{ name: client.translate("administration/config:TICKETLOGS"), value: "tickets.ticketLogs" },
{ name: client.translate("administration/config:TRANSCRIPTIONLOGS"), value: "tickets.transcriptionLogs" },
{ name: client.translate("administration/config:MESSAGEUPDATE"), value: "monitoring.messageUpdate" },
{ name: client.translate("administration/config:MESSAGEDELETE"), value: "monitoring.messageDelete" },
)
.setRequired(true),
) )
.addBooleanOption(option => .setRequired(true))
option .addBooleanOption(option => option.setName("state")
.setName("state") .setDescription(client.translate("common:STATE"))
.setDescription(client.translate("common:STATE")) .setDescriptionLocalizations({
.setDescriptionLocalizations({ "uk": client.translate("common:STATE", null, "uk-UA"),
uk: client.translate("common:STATE", null, "uk-UA"), "ru": client.translate("common:STATE", null, "ru-RU"),
ru: client.translate("common:STATE", null, "ru-RU"), })
}) .setRequired(true))
.setRequired(true), .addChannelOption(option => option.setName("channel")
) .setDescription(client.translate("common:CHANNEL"))
.addChannelOption(option => .setDescriptionLocalizations({
option "uk": client.translate("common:CHANNEL", null, "uk-UA"),
.setName("channel") "ru": client.translate("common:CHANNEL", null, "ru-RU"),
.setDescription(client.translate("common:CHANNEL")) })),
.setDescriptionLocalizations({
uk: client.translate("common:CHANNEL", null, "uk-UA"),
ru: client.translate("common:CHANNEL", null, "ru-RU"),
}),
),
), ),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const guildData = interaction.data.guild, //...
command = interaction.options.getSubcommand(); }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const command = interaction.options.getSubcommand();
if (command === "list") { if (command === "list") {
const embed = client.embed({ const guildData = data.guildData;
author: {
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.guild.name, name: interaction.guild.name,
iconURL: interaction.guild.iconURL(), iconURL: interaction.guild.iconURL(),
}, })
fields: [ .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
})
.addFields([
{ {
name: interaction.translate("administration/config:WELCOME_TITLE"), name: interaction.translate("administration/config:WELCOME_TITLE"),
value: guildData.plugins.welcome.enabled value: guildData.plugins.welcome.enabled ? interaction.translate("administration/config:WELCOME_CONTENT", {
? interaction.translate("administration/config:WELCOME_CONTENT", { channel: `<#${guildData.plugins.welcome.channel}>`,
channel: `<#${guildData.plugins.welcome.channel}>`, withImage: guildData.plugins.welcome.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO"),
withImage: guildData.plugins.welcome.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO"), }) : interaction.translate("common:DISABLED"),
}) : interaction.translate("common:DISABLED"),
inline: true, inline: true,
}, },
{ {
name: interaction.translate("administration/config:GOODBYE_TITLE"), name: interaction.translate("administration/config:GOODBYE_TITLE"),
value: guildData.plugins.goodbye.enabled value: guildData.plugins.goodbye.enabled ? interaction.translate("administration/config:GOODBYE_CONTENT", {
? interaction.translate("administration/config:GOODBYE_CONTENT", { channel: `<#${guildData.plugins.goodbye.channel}>`,
channel: `<#${guildData.plugins.goodbye.channel}>`, withImage: guildData.plugins.goodbye.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO"),
withImage: guildData.plugins.goodbye.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO"), }) : interaction.translate("common:DISABLED"),
}) : interaction.translate("common:DISABLED"),
inline: true, inline: true,
}, },
{ {
name: interaction.translate("administration/config:AUTOROLE_TITLE"), name: interaction.translate("administration/config:AUTOROLE_TITLE"),
value: guildData.plugins.autorole.enabled ? `<@&${guildData.plugins.autorole.role}>` : interaction.translate("common:DISABLED"), value: guildData.plugins.autorole.enabled ? `<@&${guildData.plugins.autorole.role}>`
: interaction.translate("common:DISABLED"),
}, },
{ {
name: interaction.translate("administration/config:AUTO_SANCTIONS"), name: interaction.translate("administration/config:AUTO_SANCTIONS"),
value: value: (guildData.plugins.warnsSanctions.kick ? interaction.translate("administration/config:KICK_CONTENT", {
(guildData.plugins.warnsSanctions.kick count: guildData.plugins.warnsSanctions.kick,
? interaction.translate("administration/config:KICK_CONTENT", { }) : interaction.translate("administration/config:KICK_NOT_DEFINED")) + "\n" + (guildData.plugins.warnsSanctions.ban ? interaction.translate("administration/config:BAN_CONTENT", {
count: guildData.plugins.warnsSanctions.kick, count: guildData.plugins.warnsSanctions.ban,
}) : interaction.translate("administration/config:KICK_NOT_DEFINED")) + }) : interaction.translate("administration/config:BAN_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"), name: interaction.translate("administration/config:AUTOMOD_TITLE"),
value: guildData.plugins.automod.enabled value: guildData.plugins.automod.enabled ? interaction.translate("administration/config:AUTOMOD_CONTENT", {
? interaction.translate("administration/config:AUTOMOD_CONTENT", { channels: guildData.plugins.automod.ignored.map(ch => ` ${ch}`),
channels: guildData.plugins.automod.ignored.map(ch => ` ${ch}`), }) : interaction.translate("common:DISABLED"),
}) : interaction.translate("common:DISABLED"),
},
{
name: interaction.translate("administration/config:MONITORING_CHANNELS"),
value:
`${interaction.translate("administration/config:MESSAGEUPDATE")}: ${guildData.plugins?.monitoring?.messageUpdate ? `<#${guildData.plugins?.monitoring?.messageUpdate}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` +
`${interaction.translate("administration/config:MESSAGEDELETE")}: ${guildData.plugins?.monitoring?.messageDelete ? `<#${guildData.plugins?.monitoring?.messageDelete}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n`,
}, },
{ {
name: interaction.translate("administration/config:SPECIAL_CHANNELS"), name: interaction.translate("administration/config:SPECIAL_CHANNELS"),
value: value: interaction.translate("administration/config:NEWS_LIST", {
`${interaction.translate("administration/config:BIRTHDAYS")}: ${guildData.plugins?.birthdays ? `<#${guildData.plugins.birthdays}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + channel: guildData.plugins.news ? `<#${guildData.plugins.news}>` : `*${interaction.translate("common:NOT_DEFINED")}*`,
`${interaction.translate("administration/config:MODLOGS")}: ${guildData.plugins?.modlogs ? `<#${guildData.plugins.modlogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + }) + "\n" +
`${interaction.translate("administration/config:REPORTS")}: ${guildData.plugins?.reports ? `<#${guildData.plugins.reports}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + interaction.translate("administration/config:SUGGESTIONS_LIST", {
`${interaction.translate("administration/config:SUGGESTIONS")}: ${guildData.plugins?.suggestions ? `<#${guildData.plugins.suggestions}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + channel: guildData.plugins.suggestions ? `<#${guildData.plugins.suggestions}>` : `*${interaction.translate("common:NOT_DEFINED")}*`,
`${interaction.translate("administration/config:TICKETSCATEGORY")}: ${guildData.plugins?.tickets?.ticketsCategory ? `<#${guildData.plugins?.tickets?.ticketsCategory}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + }) + "\n" +
`${interaction.translate("administration/config:TICKETLOGS")}: ${guildData.plugins?.tickets?.ticketLogs ? `<#${guildData.plugins?.tickets?.ticketLogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` + interaction.translate("administration/config:REPORTS_LIST", {
`${interaction.translate("administration/config:TRANSCRIPTIONLOGS")}: ${guildData.plugins?.tickets?.transcriptionLogs ? `<#${guildData.plugins?.tickets?.transcriptionLogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n`, channel: guildData.plugins.reports ? `<#${guildData.plugins.reports}>` : `*${interaction.translate("common:NOT_DEFINED")}*`,
}) + "\n" +
interaction.translate("administration/config:MODLOGS_LIST", {
channel: guildData.plugins.modlogs ? `<#${guildData.plugins.modlogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`,
}) + "\n" +
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"), // name: interaction.translate("administration/config:DASHBOARD_TITLE"),
value: `[${interaction.translate("administration/config:DASHBOARD_CONTENT")}](${client.config.dashboard.domain})`, // value: `[${interaction.translate("administration/config:DASHBOARD_CONTENT")}](${client.config.dashboard.baseURL})`
}, // }
], ]);
});
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
@ -181,78 +170,35 @@ class Config extends BaseCommand {
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {String} setting * @param {String} setting
* @param {Boolean} state * @param {Boolean} state
* @param {import("discord.js").GuildTextBasedChannel | import("discord.js").CategoryChannel} channel * @param {import("discord.js").GuildTextBasedChannel} channel
* @returns * @returns
*/ */
async function changeSetting(interaction, setting, state, channel) { async function changeSetting(interaction, setting, state, channel) {
const settingSplitted = setting.split("."), if (!state) {
data = interaction.data.guild; interaction.guild.data.plugins[setting] = null;
interaction.guild.data.markModified(`plugins.${setting}`);
await interaction.guild.data.save();
if (settingSplitted.length === 2) { return interaction.reply({
if (data.plugins[settingSplitted[0]] === undefined) data.plugins[settingSplitted[0]] = {}; content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
ephemeral: true,
if (!state) { });
data.plugins[settingSplitted[0]][settingSplitted[1]] = null;
data.markModified(`plugins.${settingSplitted[0]}`);
await data.save();
return interaction.reply({
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
ephemeral: true,
});
} else {
if (settingSplitted[1] === "ticketsCategory" && channel.type !== ChannelType.GuildCategory) return interaction.reply({ content: interaction.translate("administration/config:TICKETS_NOT_CATEGORY"), ephemeral: true });
if (channel) {
data.plugins[settingSplitted[0]][settingSplitted[1]] = channel.id;
data.markModified(`plugins.${settingSplitted[0]}`);
await data.save();
return interaction.reply({
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: **${interaction.translate("common:ENABLED")}** (${channel.toString()})`,
ephemeral: true,
});
} else
return interaction.reply({
content: `${interaction.translate(`administration/config:${settingSplitted.length === 2 ? settingSplitted[1].toUpperCase() : setting.toUpperCase()}`)}: ${
data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`
}`,
ephemeral: true,
});
}
} else { } else {
if (!state) { if (channel) {
data.plugins[setting] = null; interaction.guild.data.plugins[setting] = channel.id;
interaction.guild.data.markModified(`plugins.${setting}`);
data.markModified(`plugins.${setting}`); await interaction.guild.data.save();
await data.save();
return interaction.reply({ return interaction.reply({
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`, 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, ephemeral: true,
}); });
} else {
if (channel) {
data.plugins[setting] = channel.id;
data.markModified(`plugins.${setting}`);
await 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()}`)}: ${
data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`
}`,
ephemeral: true,
});
}
} }
} }
module.exports = Config; module.exports = Config;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Goodbye extends BaseCommand { class Goodbye extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,79 +12,70 @@ class Goodbye extends BaseCommand {
.setName("goodbye") .setName("goodbye")
.setDescription(client.translate("administration/goodbye:DESCRIPTION")) .setDescription(client.translate("administration/goodbye:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/goodbye:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/goodbye:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/goodbye:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/goodbye:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("test")
subcommand .setDescription(client.translate("administration/goodbye:TEST"))
.setName("test") .setDescriptionLocalizations({
.setDescription(client.translate("administration/goodbye:TEST")) "uk": client.translate("administration/goodbye:TEST", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("administration/goodbye:TEST", null, "ru-RU"),
uk: client.translate("administration/goodbye:TEST", null, "uk-UA"), }),
ru: client.translate("administration/goodbye:TEST", null, "ru-RU"),
}),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("config")
subcommand .setDescription(client.translate("administration/goodbye:CONFIG"))
.setName("config") .setDescriptionLocalizations({
.setDescription(client.translate("administration/goodbye:CONFIG")) "uk": client.translate("administration/goodbye:CONFIG", null, "uk-UA"),
"ru": client.translate("administration/goodbye:CONFIG", null, "ru-RU"),
})
.addBooleanOption(option => option.setName("state")
.setDescription(client.translate("common:STATE"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/goodbye:CONFIG", null, "uk-UA"), "uk": client.translate("common:STATE", null, "uk-UA"),
ru: client.translate("administration/goodbye:CONFIG", null, "ru-RU"), "ru": client.translate("common:STATE", null, "ru-RU"),
}) })
.addBooleanOption(option => .setRequired(true))
option .addChannelOption(option => option.setName("channel")
.setName("state") .setDescription(client.translate("common:CHANNEL"))
.setDescription(client.translate("common:STATE")) .setDescriptionLocalizations({
.setDescriptionLocalizations({ "uk": client.translate("common:CHANNEL", null, "uk-UA"),
uk: client.translate("common:STATE", null, "uk-UA"), "ru": client.translate("common:CHANNEL", null, "ru-RU"),
ru: client.translate("common:STATE", null, "ru-RU"), }))
}) .addStringOption(option => option.setName("message")
.setRequired(true), .setDescription(client.translate("administration/goodbye:MESSAGE"))
) .setDescriptionLocalizations({
.addChannelOption(option => "uk": client.translate("administration/goodbye:MESSAGE", null, "uk-UA"),
option "ru": client.translate("administration/goodbye:MESSAGE", null, "ru-RU"),
.setName("channel") }))
.setDescription(client.translate("common:CHANNEL")) .addBooleanOption(option => option.setName("image")
.setDescriptionLocalizations({ .setDescription(client.translate("administration/goodbye:IMAGE"))
uk: client.translate("common:CHANNEL", null, "uk-UA"), .setDescriptionLocalizations({
ru: client.translate("common:CHANNEL", null, "ru-RU"), "uk": client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
}), "ru": client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
) })),
.addStringOption(option =>
option
.setName("message")
.setDescription(client.translate("administration/goodbye:MESSAGE"))
.setDescriptionLocalizations({
uk: client.translate("administration/goodbye:MESSAGE", null, "uk-UA"),
ru: client.translate("administration/goodbye:MESSAGE", null, "ru-RU"),
}),
)
.addBooleanOption(option =>
option
.setName("image")
.setDescription(client.translate("administration/goodbye:IMAGE"))
.setDescriptionLocalizations({
uk: client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
ru: client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
}),
),
), ),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const guildData = interaction.data.guild, //...
command = interaction.options.getSubcommand(); }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const command = interaction.options.getSubcommand();
if (command === "test") { if (command === "test") {
client.emit("guildMemberRemove", interaction.member); client.emit("guildMemberRemove", interaction.member);
@ -94,38 +85,36 @@ class Goodbye extends BaseCommand {
const state = interaction.options.getBoolean("state"); const state = interaction.options.getBoolean("state");
if (!state) { if (!state) {
guildData.plugins.goodbye = { data.guildData.plugins.goodbye = {
enabled: false, enabled: false,
message: null, message: null,
channelID: null, channelID: null,
withImage: null, withImage: null,
}; };
data.guildData.markModified("plugins.goodbye");
await data.guildData.save();
guildData.markModified("plugins.goodbye"); interaction.success("administration/goodbye:DISABLED");
await guildData.save();
interaction.success("administration/goodbye:DISABLED", null, { ephemeral: true });
} else { } else {
const channel = interaction.options.getChannel("channel") || interaction.channel; const channel = interaction.options.getChannel("channel") || interaction.channel;
const message = interaction.options.getString("message") || interaction.translate("administration/goodbye:DEFAULT_MESSAGE"); const message = interaction.options.getString("message") || interaction.translate("administration/goodbye:DEFAULT_MESSAGE");
const image = interaction.options.getBoolean("image") === true ? true : false; const image = interaction.options.getBoolean("image") || true;
guildData.plugins.goodbye = { data.guildData.plugins.goodbye = {
enabled: true, enabled: true,
channel: channel.id, channel: channel.id,
message: message, message: message,
withImage: image, withImage: image,
}; };
data.guildData.markModified("plugins.goodbye");
guildData.markModified("plugins.goodbye"); await data.guildData.save();
await guildData.save();
interaction.success("administration/goodbye:ENABLED", { interaction.success("administration/goodbye:ENABLED", {
channel: `${channel.toString()}`, channel: `<#${data.guildData.plugins.goodbye.channel}>`,
}, { ephemeral: true }); }, { ephemeral: true });
} }
} }
} }
} }
module.exports = Goodbye; module.exports = Goodbye;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Selectroles extends BaseCommand { class Selectroles extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,86 +12,67 @@ class Selectroles extends BaseCommand {
.setName("selectroles") .setName("selectroles")
.setDescription(client.translate("administration/selectroles:DESCRIPTION")) .setDescription(client.translate("administration/selectroles:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/selectroles:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/selectroles:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/selectroles:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/selectroles:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("message")
subcommand .setDescription(client.translate("administration/selectroles:MESSAGE"))
.setName("message") .setDescriptionLocalizations({
.setDescription(client.translate("administration/selectroles:MESSAGE")) "uk": client.translate("administration/selectroles:MESSAGE", null, "uk-UA"),
"ru": client.translate("administration/selectroles:MESSAGE", null, "ru-RU"),
})
.addStringOption(option => option.setName("text")
.setDescription(client.translate("common:MESSAGE"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/selectroles:MESSAGE", null, "uk-UA"), "uk": client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("administration/selectroles:MESSAGE", null, "ru-RU"), "ru": client.translate("common:MESSAGE", null, "ru-RU"),
}) })
.addStringOption(option => .setRequired(true)),
option
.setName("text")
.setDescription(client.translate("common:MESSAGE"))
.setDescriptionLocalizations({
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("addrole")
subcommand .setDescription(client.translate("administration/selectroles:ADDROLE"))
.setName("addrole") .setDescriptionLocalizations({
.setDescription(client.translate("administration/selectroles:ADDROLE")) "uk": client.translate("administration/selectroles:ADDROLE", null, "uk-UA"),
"ru": client.translate("administration/selectroles:ADDROLE", null, "ru-RU"),
})
.addChannelOption(option => option.setName("channel")
.setDescription(client.translate("common:CHANNEL"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/selectroles:ADDROLE", null, "uk-UA"), "uk": client.translate("common:CHANNEL", null, "uk-UA"),
ru: client.translate("administration/selectroles:ADDROLE", null, "ru-RU"), "ru": client.translate("common:CHANNEL", null, "ru-RU"),
}) })
.addChannelOption(option => .setRequired(true))
option .addStringOption(option => option.setName("message_id")
.setName("channel") .setDescription(client.translate("common:MESSAGE_ID"))
.setDescription(client.translate("common:CHANNEL")) .setDescriptionLocalizations({
.setDescriptionLocalizations({ "uk": client.translate("common:MESSAGE_ID", null, "uk-UA"),
uk: client.translate("common:CHANNEL", null, "uk-UA"), "ru": client.translate("common:MESSAGE_ID", null, "ru-RU"),
ru: client.translate("common:CHANNEL", null, "ru-RU"), })
}) .setRequired(true))
.setRequired(true), .addRoleOption(option => option.setName("role")
) .setDescription(client.translate("common:ROLE"))
.addStringOption(option => .setDescriptionLocalizations({
option "uk": client.translate("common:ROLE", null, "uk-UA"),
.setName("message_id") "ru": client.translate("common:ROLE", null, "ru-RU"),
.setDescription(client.translate("common:MESSAGE_ID")) })
.setDescriptionLocalizations({ .setRequired(true)),
uk: client.translate("common:MESSAGE_ID", null, "uk-UA"),
ru: client.translate("common:MESSAGE_ID", null, "ru-RU"),
})
.setRequired(true),
)
.addRoleOption(option =>
option
.setName("role")
.setDescription(client.translate("common:ROLE"))
.setDescriptionLocalizations({
uk: client.translate("common:ROLE", null, "uk-UA"),
ru: client.translate("common:ROLE", null, "ru-RU"),
})
.setRequired(true),
),
), ),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
async onLoad(client) { async onLoad(client) {
client.on("interactionCreate", async interaction => { client.on("interactionCreate", async interaction => {
if (!interaction.isStringSelectMenu()) return; if (!interaction.isStringSelectMenu()) return;
if (interaction.customId === "auto_roles") { if (interaction.customId === "auto_roles") {
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const removed = interaction.component.options.filter(option => { const removed = interaction.component.options.filter(option => {
return !interaction.values.includes(option.value); return !interaction.values.includes(option.value);
}); });
@ -111,11 +92,11 @@ class Selectroles extends BaseCommand {
} }
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
@ -142,27 +123,33 @@ class Selectroles extends BaseCommand {
let row = message.components[0]; let row = message.components[0];
if (!row) row = new ActionRowBuilder(); if (!row) row = new ActionRowBuilder();
const option = [ const option = [{
{ label: role.name,
label: role.name, value: role.id,
value: role.id, }];
},
];
const menu = row.components[0]; const menu = row.components[0];
if (menu) { if (menu) {
for (const o of menu.options) { for (const o of menu.options) {
if (o.value === option[0].value) return interaction.error("administration/selectroles:ALREADY_IN_MENU", null, { edit: true }); if (o.value === option[0].value) return interaction.error("administration/selectroles:ALREADY_IN_MENU");
} }
row = ActionRowBuilder.from(row).setComponents( row = ActionRowBuilder.from(row)
StringSelectMenuBuilder.from(menu) .setComponents(
StringSelectMenuBuilder.from(menu)
.setMinValues(0)
.setMaxValues(menu.options.length + 1)
.addOptions(option),
);
} else {
row.addComponents(
new StringSelectMenuBuilder()
.setCustomId("auto_roles")
.setMinValues(0) .setMinValues(0)
.setMaxValues(menu.options.length + 1) .setMaxValues(1)
.setPlaceholder(interaction.translate("common:AVAILABLE_OPTIONS"))
.addOptions(option), .addOptions(option),
); );
} else {
row.addComponents(new StringSelectMenuBuilder().setCustomId("auto_roles").setMinValues(0).setMaxValues(1).setPlaceholder(interaction.translate("common:AVAILABLE_OPTIONS")).addOptions(option));
} }
message.edit({ message.edit({
@ -179,4 +166,4 @@ class Selectroles extends BaseCommand {
} }
} }
module.exports = Selectroles; module.exports = Selectroles;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Set extends BaseCommand { class Set extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,56 +12,55 @@ class Set extends BaseCommand {
.setName("set") .setName("set")
.setDescription(client.translate("administration/set:DESCRIPTION")) .setDescription(client.translate("administration/set:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/set:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/set:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/set:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/set:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option => .addStringOption(option => option.setName("type")
option .setDescription(client.translate("owner/debug:TYPE"))
.setName("type") .setDescriptionLocalizations({
.setDescription(client.translate("owner/debug:TYPE")) "uk": client.translate("owner/debug:TYPE", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("owner/debug:TYPE", null, "ru-RU"),
uk: client.translate("owner/debug:TYPE", null, "uk-UA"), })
ru: client.translate("owner/debug:TYPE", null, "ru-RU"), .setRequired(true)
}) .setChoices(
.setRequired(true) { name: client.translate("common:LEVEL"), value: "level" },
.setChoices( { name: client.translate("common:XP"), value: "xp" },
{ name: client.translate("common:LEVEL"), value: "level" }, { name: client.translate("common:CREDITS"), value: "credits" },
{ name: client.translate("common:XP"), value: "xp" }, { name: client.translate("economy/transactions:BANK"), value: "bank" },
{ name: client.translate("common:CREDITS"), value: "credits" }, ))
{ name: client.translate("economy/transactions:BANK"), value: "bank" }, .addUserOption(option => option.setName("user")
), .setDescription(client.translate("common:USER"))
) .setDescriptionLocalizations({
.addUserOption(option => "uk": client.translate("common:USER", null, "uk-UA"),
option "ru": client.translate("common:USER", null, "ru-RU"),
.setName("user") })
.setDescription(client.translate("common:USER")) .setRequired(true))
.setDescriptionLocalizations({ .addIntegerOption(option => option.setName("int")
uk: client.translate("common:USER", null, "uk-UA"), .setDescription(client.translate("common:INT"))
ru: client.translate("common:USER", null, "ru-RU"), .setDescriptionLocalizations({
}) "uk": client.translate("common:INT", null, "uk-UA"),
.setRequired(true), "ru": client.translate("common:INT", null, "ru-RU"),
) })
.addIntegerOption(option => .setRequired(true)),
option aliases: [],
.setName("int")
.setDescription(client.translate("common:INT"))
.setDescriptionLocalizations({
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const type = interaction.options.getString("type"), const type = interaction.options.getString("type"),
@ -79,10 +78,7 @@ class Set extends BaseCommand {
switch (type) { switch (type) {
case "level": { case "level": {
memberData.level = int; memberData.level = int;
memberData.markModified("level");
await memberData.save(); await memberData.save();
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(), user: member.toString(),
amount: int, amount: int,
@ -91,10 +87,7 @@ class Set extends BaseCommand {
case "xp": { case "xp": {
memberData.exp = int; memberData.exp = int;
memberData.markModified("exp");
await memberData.save(); await memberData.save();
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(), user: member.toString(),
amount: int, amount: int,
@ -103,10 +96,7 @@ class Set extends BaseCommand {
case "credits": { case "credits": {
memberData.money = int; memberData.money = int;
memberData.markModified("money");
await memberData.save(); await memberData.save();
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(), user: member.toString(),
amount: int, amount: int,
@ -115,10 +105,7 @@ class Set extends BaseCommand {
case "bank": { case "bank": {
memberData.bankSold = int; memberData.bankSold = int;
memberData.markModified("bankSold");
await memberData.save(); await memberData.save();
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, { return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
user: member.toString(), user: member.toString(),
amount: int, amount: int,
@ -128,4 +115,4 @@ class Set extends BaseCommand {
} }
} }
module.exports = Set; module.exports = Set;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Setlang extends BaseCommand { class Setlang extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,41 +12,47 @@ class Setlang extends BaseCommand {
.setName("setlang") .setName("setlang")
.setDescription(client.translate("administration/setlang:DESCRIPTION")) .setDescription(client.translate("administration/setlang:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/setlang:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/setlang:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/setlang:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/setlang:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option => .addStringOption(option => option.setName("language")
option .setDescription(client.translate("common:LANGUAGE"))
.setName("language") .setDescriptionLocalizations({
.setDescription(client.translate("common:LANGUAGE")) "uk": client.translate("common:LANGUAGE", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:LANGUAGE", null, "ru-RU"),
uk: client.translate("common:LANGUAGE", null, "uk-UA"), })
ru: client.translate("common:LANGUAGE", null, "ru-RU"), .setRequired(true)
}) .setChoices(
.setRequired(true) { name: "English", value: "en-US" },
.setChoices({ name: "English", value: "en-US" }, { name: "Русский", value: "ru-RU" }, { name: "Українська", value: "uk-UA" }), { name: "Русский", value: "ru-RU" },
), { name: "Українська", value: "uk-UA" },
)),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const guildData = interaction.data.guild, //...
lang = interaction.options.getString("language"), }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const lang = interaction.options.getString("language"),
language = client.languages.find(l => l.name === lang); language = client.languages.find(l => l.name === lang);
guildData.language = language.name; data.guildData.language = language.name;
await data.guildData.save();
guildData.markModified("language");
await guildData.save();
return interaction.success("administration/setlang:SUCCESS", { return interaction.success("administration/setlang:SUCCESS", {
lang: language.nativeName, lang: language.nativeName,
@ -54,4 +60,4 @@ class Setlang extends BaseCommand {
} }
} }
module.exports = Setlang; module.exports = Setlang;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, parseEmoji, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, parseEmoji, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Stealemoji extends BaseCommand { class Stealemoji extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,44 +12,48 @@ class Stealemoji extends BaseCommand {
.setName("stealemoji") .setName("stealemoji")
.setDescription(client.translate("administration/stealemoji:DESCRIPTION")) .setDescription(client.translate("administration/stealemoji:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/stealemoji:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/stealemoji:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/stealemoji:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/stealemoji:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addStringOption(option => .addStringOption(option => option.setName("emoji")
option .setDescription(client.translate("common:EMOJI"))
.setName("emoji") .setDescriptionLocalizations({
.setDescription(client.translate("common:EMOJI")) "uk": client.translate("common:EMOJI", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:EMOJI", null, "ru-RU"),
uk: client.translate("common:EMOJI", null, "uk-UA"), })
ru: client.translate("common:EMOJI", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const parsedEmoji = parseEmoji(interaction.options.getString("emoji")); const parsedEmoji = parseEmoji(interaction.options.getString("emoji")),
ext = parsedEmoji.animated ? "gif" : "png";
interaction.guild.emojis interaction.guild.emojis
.create({ .create({
name: parsedEmoji.name, name: parsedEmoji.name,
attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${parsedEmoji.animated ? "gif" : "png"}`, attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${ext}`,
}) })
.then(emoji => .then(emoji => interaction.success("administration/stealemoji:SUCCESS", {
interaction.success("administration/stealemoji:SUCCESS", { emoji: emoji.name,
emoji: emoji.name, }, { ephemeral: true }))
}, { ephemeral: true }),
)
.catch(e => { .catch(e => {
interaction.error("administration/stealemoji:ERROR", { interaction.error("administration/stealemoji:ERROR", {
emoji: parsedEmoji.name, emoji: parsedEmoji.name,
@ -59,4 +63,4 @@ class Stealemoji extends BaseCommand {
} }
} }
module.exports = Stealemoji; module.exports = Stealemoji;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Welcome extends BaseCommand { class Welcome extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,79 +12,70 @@ class Welcome extends BaseCommand {
.setName("welcome") .setName("welcome")
.setDescription(client.translate("administration/welcome:DESCRIPTION")) .setDescription(client.translate("administration/welcome:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/welcome:DESCRIPTION", null, "uk-UA"), "uk": client.translate("administration/welcome:DESCRIPTION", null, "uk-UA"),
ru: client.translate("administration/welcome:DESCRIPTION", null, "ru-RU"), "ru": client.translate("administration/welcome:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild) .setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("test")
subcommand .setDescription(client.translate("administration/goodbye:TEST"))
.setName("test") .setDescriptionLocalizations({
.setDescription(client.translate("administration/goodbye:TEST")) "uk": client.translate("administration/goodbye:TEST", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("administration/goodbye:TEST", null, "ru-RU"),
uk: client.translate("administration/goodbye:TEST", null, "uk-UA"), }),
ru: client.translate("administration/goodbye:TEST", null, "ru-RU"),
}),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("config")
subcommand .setDescription(client.translate("administration/goodbye:CONFIG"))
.setName("config") .setDescriptionLocalizations({
.setDescription(client.translate("administration/goodbye:CONFIG")) "uk": client.translate("administration/goodbye:CONFIG", null, "uk-UA"),
"ru": client.translate("administration/goodbye:CONFIG", null, "ru-RU"),
})
.addBooleanOption(option => option.setName("state")
.setDescription(client.translate("common:STATE"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("administration/goodbye:CONFIG", null, "uk-UA"), "uk": client.translate("common:STATE", null, "uk-UA"),
ru: client.translate("administration/goodbye:CONFIG", null, "ru-RU"), "ru": client.translate("common:STATE", null, "ru-RU"),
}) })
.addBooleanOption(option => .setRequired(true))
option .addChannelOption(option => option.setName("channel")
.setName("state") .setDescription(client.translate("common:CHANNEL"))
.setDescription(client.translate("common:STATE")) .setDescriptionLocalizations({
.setDescriptionLocalizations({ "uk": client.translate("common:CHANNEL", null, "uk-UA"),
uk: client.translate("common:STATE", null, "uk-UA"), "ru": client.translate("common:CHANNEL", null, "ru-RU"),
ru: client.translate("common:STATE", null, "ru-RU"), }))
}) .addStringOption(option => option.setName("message")
.setRequired(true), .setDescription(client.translate("administration/goodbye:MESSAGE"))
) .setDescriptionLocalizations({
.addChannelOption(option => "uk": client.translate("administration/goodbye:MESSAGE", null, "uk-UA"),
option "ru": client.translate("administration/goodbye:MESSAGE", null, "ru-RU"),
.setName("channel") }))
.setDescription(client.translate("common:CHANNEL")) .addBooleanOption(option => option.setName("image")
.setDescriptionLocalizations({ .setDescription(client.translate("administration/goodbye:IMAGE"))
uk: client.translate("common:CHANNEL", null, "uk-UA"), .setDescriptionLocalizations({
ru: client.translate("common:CHANNEL", null, "ru-RU"), "uk": client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
}), "ru": client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
) })),
.addStringOption(option =>
option
.setName("message")
.setDescription(client.translate("administration/goodbye:MESSAGE"))
.setDescriptionLocalizations({
uk: client.translate("administration/goodbye:MESSAGE", null, "uk-UA"),
ru: client.translate("administration/goodbye:MESSAGE", null, "ru-RU"),
}),
)
.addBooleanOption(option =>
option
.setName("image")
.setDescription(client.translate("administration/goodbye:IMAGE"))
.setDescriptionLocalizations({
uk: client.translate("administration/goodbye:IMAGE", null, "uk-UA"),
ru: client.translate("administration/goodbye:IMAGE", null, "ru-RU"),
}),
),
), ),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const guildData = interaction.data.guild, //...
command = interaction.options.getSubcommand(); }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const command = interaction.options.getSubcommand();
if (command === "test") { if (command === "test") {
client.emit("guildMemberAdd", interaction.member); client.emit("guildMemberAdd", interaction.member);
@ -94,38 +85,36 @@ class Welcome extends BaseCommand {
const state = interaction.options.getBoolean("state"); const state = interaction.options.getBoolean("state");
if (!state) { if (!state) {
guildData.plugins.welcome = { data.guildData.plugins.welcome = {
enabled: false, enabled: false,
message: null, message: null,
channelID: null, channelID: null,
withImage: null, withImage: null,
}; };
data.guildData.markModified("plugins.welcome");
await data.guildData.save();
guildData.markModified("plugins.welcome"); interaction.success("administration/welcome:DISABLED");
await guildData.save();
interaction.success("administration/welcome:DISABLED", null, { ephemeral: true });
} else { } else {
const channel = interaction.options.getChannel("channel") || interaction.channel; const channel = interaction.options.getChannel("channel") || interaction.channel;
const message = interaction.options.getString("message") || interaction.translate("administration/welcome:DEFAULT_MESSAGE"); const message = interaction.options.getString("message") || interaction.translate("administration/welcome:DEFAULT_MESSAGE");
const image = interaction.options.getBoolean("image") === true ? true : false; const image = interaction.options.getBoolean("image") || true;
guildData.plugins.welcome = { data.guildData.plugins.welcome = {
enabled: true, enabled: true,
channel: channel.id, channel: channel.id,
message: message, message: message,
withImage: image, withImage: image,
}; };
data.guildData.markModified("plugins.welcome");
guildData.markModified("plugins.welcome"); await data.guildData.save();
await guildData.save();
interaction.success("administration/welcome:ENABLED", { interaction.success("administration/welcome:ENABLED", {
channel: `${channel.toString()}`, channel: `<#${data.guildData.plugins.welcome.channel}>`,
}, { ephemeral: true }); }, { ephemeral: true });
} }
} }
} }
} }
module.exports = Welcome; module.exports = Welcome;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Achievements extends BaseCommand { class Achievements extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,99 +12,109 @@ class Achievements extends BaseCommand {
.setName("achievements") .setName("achievements")
.setDescription(client.translate("economy/achievements:DESCRIPTION")) .setDescription(client.translate("economy/achievements:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/achievements:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/achievements:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/achievements:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/achievements:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })),
ru: client.translate("common:USER", null, "ru-RU"), aliases: [],
}),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const user = interaction.options.getUser("user") || interaction.member; const user = interaction.options.getUser("user") || interaction.member;
if (user.bot) return interaction.error("economy/profile:BOT_USER"); if (user.bot) return interaction.error("economy/profile:BOT_USER");
const userData = user.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(user.id); const userData = (user.id === interaction.user.id ? data.userData : await client.findOrCreateUser({
id: user.id,
}));
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("economy/achievements:TITLE"), name: interaction.translate("economy/achievements:TITLE"),
iconURL: user.displayAvatarURL(), })
.setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
embed.addFields([
{
name: interaction.translate("economy/achievements:SEND_CMD"),
value: interaction.translate("economy/achievements:PROGRESS", {
now: userData.achievements.firstCommand.progress.now,
total: userData.achievements.firstCommand.progress.total,
percent: Math.round(100 * (userData.achievements.firstCommand.progress.now / userData.achievements.firstCommand.progress.total)),
}),
}, },
fields: [ {
{ name: interaction.translate("economy/achievements:CLAIM_SALARY"),
name: interaction.translate("economy/achievements:SEND_CMD"), value: interaction.translate("economy/achievements:PROGRESS", {
value: interaction.translate("economy/achievements:PROGRESS", { now: userData.achievements.work.progress.now,
now: userData.achievements.firstCommand.progress.now, total: userData.achievements.work.progress.total,
total: userData.achievements.firstCommand.progress.total, percent: Math.round(100 * (userData.achievements.work.progress.now / userData.achievements.work.progress.total)),
percent: Math.round(100 * (userData.achievements.firstCommand.progress.now / userData.achievements.firstCommand.progress.total)), }),
}), },
}, {
{ name: interaction.translate("economy/achievements:MARRY"),
name: interaction.translate("economy/achievements:CLAIM_SALARY"), value: interaction.translate("economy/achievements:PROGRESS", {
value: interaction.translate("economy/achievements:PROGRESS", { now: userData.achievements.married.progress.now,
now: userData.achievements.work.progress.now, total: userData.achievements.married.progress.total,
total: userData.achievements.work.progress.total, percent: Math.round(100 * (userData.achievements.married.progress.now / userData.achievements.married.progress.total)),
percent: Math.round(100 * (userData.achievements.work.progress.now / userData.achievements.work.progress.total)), }),
}), },
}, {
{ name: interaction.translate("economy/achievements:SLOTS"),
name: interaction.translate("economy/achievements:MARRY"), value: interaction.translate("economy/achievements:PROGRESS", {
value: interaction.translate("economy/achievements:PROGRESS", { now: userData.achievements.slots.progress.now,
now: userData.achievements.married.progress.now, total: userData.achievements.slots.progress.total,
total: userData.achievements.married.progress.total, percent: Math.round(100 * (userData.achievements.slots.progress.now / userData.achievements.slots.progress.total)),
percent: Math.round(100 * (userData.achievements.married.progress.now / userData.achievements.married.progress.total)), }),
}), },
}, {
{ name: interaction.translate("economy/achievements:TIP"),
name: interaction.translate("economy/achievements:SLOTS"), value: interaction.translate("economy/achievements:PROGRESS", {
value: interaction.translate("economy/achievements:PROGRESS", { now: userData.achievements.tip.progress.now,
now: userData.achievements.slots.progress.now, total: userData.achievements.tip.progress.total,
total: userData.achievements.slots.progress.total, percent: Math.round(100 * (userData.achievements.tip.progress.now / userData.achievements.tip.progress.total)),
percent: Math.round(100 * (userData.achievements.slots.progress.now / userData.achievements.slots.progress.total)), }),
}), },
}, {
{ name: interaction.translate("economy/achievements:REP"),
name: interaction.translate("economy/achievements:TIP"), value: interaction.translate("economy/achievements:PROGRESS", {
value: interaction.translate("economy/achievements:PROGRESS", { now: userData.achievements.rep.progress.now,
now: userData.achievements.tip.progress.now, total: userData.achievements.rep.progress.total,
total: userData.achievements.tip.progress.total, percent: Math.round(100 * (userData.achievements.rep.progress.now / userData.achievements.rep.progress.total)),
percent: Math.round(100 * (userData.achievements.tip.progress.now / userData.achievements.tip.progress.total)), }),
}), },
}, {
{ name: interaction.translate("economy/achievements:INVITE"),
name: interaction.translate("economy/achievements:REP"), value: interaction.translate("economy/achievements:PROGRESS", {
value: interaction.translate("economy/achievements:PROGRESS", { now: userData.achievements.invite.progress.now,
now: userData.achievements.rep.progress.now, total: userData.achievements.invite.progress.total,
total: userData.achievements.rep.progress.total, percent: Math.round(100 * (userData.achievements.invite.progress.now / userData.achievements.invite.progress.total)),
percent: Math.round(100 * (userData.achievements.rep.progress.now / userData.achievements.rep.progress.total)), }),
}), },
}, ]);
{
name: interaction.translate("economy/achievements:INVITE"),
value: interaction.translate("economy/achievements:PROGRESS", {
now: userData.achievements.invite.progress.now,
total: userData.achievements.invite.progress.total,
percent: Math.round(100 * (userData.achievements.invite.progress.now / userData.achievements.invite.progress.total)),
}),
},
],
});
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
@ -112,4 +122,4 @@ class Achievements extends BaseCommand {
} }
} }
module.exports = Achievements; module.exports = Achievements;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Bank extends BaseCommand { class Bank extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,60 +12,57 @@ class Bank extends BaseCommand {
.setName("bank") .setName("bank")
.setDescription(client.translate("economy/bank:DESCRIPTION")) .setDescription(client.translate("economy/bank:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/bank:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/bank:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/bank:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/bank:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addStringOption(option => .addStringOption(option => option.setName("option")
option .setDescription(client.translate("economy/bank:OPTION"))
.setName("option") .setDescriptionLocalizations({
.setDescription(client.translate("economy/bank:OPTION")) "uk": client.translate("economy/bank:OPTION", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("economy/bank:OPTION", null, "ru-RU"),
uk: client.translate("economy/bank:OPTION", null, "uk-UA"), })
ru: client.translate("economy/bank:OPTION", null, "ru-RU"), .setRequired(true)
}) .setChoices(
.setRequired(true) { name: client.translate("economy/bank:DEPOSIT"), value: "deposit" },
.setChoices({ name: client.translate("economy/bank:DEPOSIT"), value: "deposit" }, { name: client.translate("economy/bank:WITHDRAW"), value: "withdraw" }), { name: client.translate("economy/bank:WITHDRAW"), value: "withdraw" },
) ))
.addStringOption(option => .addStringOption(option => option.setName("credits")
option .setDescription(client.translate("misc:OPTION_NAN_ALL"))
.setName("credits") .setDescriptionLocalizations({
.setDescription(client.translate("misc:OPTION_NAN_ALL")) "uk": client.translate("misc:OPTION_NAN_ALL", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("misc:OPTION_NAN_ALL", null, "ru-RU"),
uk: client.translate("misc:OPTION_NAN_ALL", null, "uk-UA"), })
ru: client.translate("misc:OPTION_NAN_ALL", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const memberData = interaction.data.member, //...
choice = interaction.options.getString("option"); }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const choice = interaction.options.getString("option");
if (choice === "deposit") { if (choice === "deposit") {
const credits = interaction.options.getString("credits").toLowerCase() === "all" ? memberData.money : interaction.options.getString("credits"); const credits = interaction.options.getString("credits").toLowerCase() === "all" ? data.memberData.money : interaction.options.getString("credits");
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL"); if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
if (memberData.money < credits) if (data.memberData.money < credits) return interaction.error("economy/bank:NOT_ENOUGH_CREDIT", { money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` });
return interaction.error("economy/bank:NOT_ENOUGH_CREDIT", {
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
});
memberData.money -= credits; data.memberData.money -= credits;
memberData.bankSold += credits; data.memberData.bankSold += credits;
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("bankSold");
await memberData.save();
const info = { const info = {
user: interaction.translate("economy/transactions:BANK"), user: interaction.translate("economy/transactions:BANK"),
@ -73,19 +70,15 @@ class Bank extends BaseCommand {
date: Date.now(), date: Date.now(),
type: "send", type: "send",
}; };
memberData.transactions.push(info); data.memberData.transactions.push(info);
interaction.success("economy/bank:SUCCESS_DEP", { interaction.success("economy/bank:SUCCESS_DEP", {
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
}); });
} else { } else {
const credits = interaction.options.getString("credits") === "all" ? memberData.bankSold : interaction.options.getString("credits"); const credits = interaction.options.getString("credits") === "all" ? data.memberData.bankSold : interaction.options.getString("credits");
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL"); if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
if (memberData.bankSold < credits) if (data.memberData.bankSold < credits) return interaction.error("economy/bank:NOT_ENOUGH_BANK", { money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` });
return interaction.error("economy/bank:NOT_ENOUGH_BANK", {
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
});
const info = { const info = {
user: interaction.translate("economy/transactions:BANK"), user: interaction.translate("economy/transactions:BANK"),
@ -94,14 +87,11 @@ class Bank extends BaseCommand {
type: "got", type: "got",
}; };
memberData.transactions.push(info); data.memberData.transactions.push(info);
memberData.money += credits; data.memberData.money += credits;
memberData.bankSold -= credits; data.memberData.bankSold -= credits;
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("bankSold");
await memberData.save();
interaction.success("economy/bank:SUCCESS_WD", { interaction.success("economy/bank:SUCCESS_WD", {
money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, money: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
@ -110,4 +100,4 @@ class Bank extends BaseCommand {
} }
} }
module.exports = Bank; module.exports = Bank;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Birthdate extends BaseCommand { class Birthdate extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,85 +12,80 @@ class Birthdate extends BaseCommand {
.setName("birthdate") .setName("birthdate")
.setDescription(client.translate("economy/birthdate:DESCRIPTION")) .setDescription(client.translate("economy/birthdate:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/birthdate:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/birthdate:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/birthdate:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/birthdate:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(false)
.addIntegerOption(option => .addIntegerOption(option => option.setName("day")
option .setDescription(client.translate("economy/birthdate:DAY"))
.setName("day") .setDescriptionLocalizations({
.setDescription(client.translate("economy/birthdate:DAY")) "uk": client.translate("economy/birthdate:DAY", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("economy/birthdate:DAY", null, "ru-RU"),
uk: client.translate("economy/birthdate:DAY", null, "uk-UA"), })
ru: client.translate("economy/birthdate:DAY", null, "ru-RU"), .setRequired(true))
}) .addIntegerOption(option => option.setName("month")
.setRequired(true), .setDescription(client.translate("economy/birthdate:MONTH"))
) .setDescriptionLocalizations({
.addIntegerOption(option => "uk": client.translate("economy/birthdate:MONTH", null, "uk-UA"),
option "ru": client.translate("economy/birthdate:MONTH", null, "ru-RU"),
.setName("month") })
.setDescription(client.translate("economy/birthdate:MONTH")) .setRequired(true)
.setDescriptionLocalizations({ .setChoices(
uk: client.translate("economy/birthdate:MONTH", null, "uk-UA"), { name: client.translate("economy/birthdate:JANUARY"), value: 1 },
ru: client.translate("economy/birthdate:MONTH", null, "ru-RU"), { name: client.translate("economy/birthdate:FEBRUARY"), value: 2 },
}) { name: client.translate("economy/birthdate:MARCH"), value: 3 },
.setRequired(true) { name: client.translate("economy/birthdate:APRIL"), value: 4 },
.setChoices( { name: client.translate("economy/birthdate:MAY"), value: 5 },
{ name: client.translate("economy/birthdate:JANUARY"), value: 1 }, { name: client.translate("economy/birthdate:JUNE"), value: 6 },
{ name: client.translate("economy/birthdate:FEBRUARY"), value: 2 }, { name: client.translate("economy/birthdate:JULY"), value: 7 },
{ name: client.translate("economy/birthdate:MARCH"), value: 3 }, { name: client.translate("economy/birthdate:AUGUST"), value: 8 },
{ name: client.translate("economy/birthdate:APRIL"), value: 4 }, { name: client.translate("economy/birthdate:SEPTEMBER"), value: 9 },
{ name: client.translate("economy/birthdate:MAY"), value: 5 }, { name: client.translate("economy/birthdate:OCTOBER"), value: 10 },
{ name: client.translate("economy/birthdate:JUNE"), value: 6 }, { name: client.translate("economy/birthdate:NOVEMBER"), value: 11 },
{ name: client.translate("economy/birthdate:JULY"), value: 7 }, { name: client.translate("economy/birthdate:DECEMBER"), value: 12 },
{ name: client.translate("economy/birthdate:AUGUST"), value: 8 }, ))
{ name: client.translate("economy/birthdate:SEPTEMBER"), value: 9 }, .addIntegerOption(option => option.setName("year")
{ name: client.translate("economy/birthdate:OCTOBER"), value: 10 }, .setDescription(client.translate("economy/birthdate:YEAR"))
{ name: client.translate("economy/birthdate:NOVEMBER"), value: 11 }, .setDescriptionLocalizations({
{ name: client.translate("economy/birthdate:DECEMBER"), value: 12 }, "uk": client.translate("economy/birthdate:YEAR", null, "uk-UA"),
), "ru": client.translate("economy/birthdate:YEAR", null, "ru-RU"),
) })
.addIntegerOption(option => .setRequired(true)),
option aliases: [],
.setName("year")
.setDescription(client.translate("economy/birthdate:YEAR"))
.setDescriptionLocalizations({
uk: client.translate("economy/birthdate:YEAR", null, "uk-UA"),
ru: client.translate("economy/birthdate:YEAR", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const userData = interaction.data.user, //...
day = interaction.options.getInteger("day"), }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const day = interaction.options.getInteger("day"),
month = interaction.options.getInteger("month"), month = interaction.options.getInteger("month"),
year = interaction.options.getInteger("year"), year = interaction.options.getInteger("year"),
date = new Date(year, month - 1, day), d = new Date(year, month - 1, day);
d = Math.floor(date.getTime() / 1000);
if (!(day == date.getDate() && month - 1 == date.getMonth() && year == date.getFullYear())) return interaction.error("economy/birthdate:INVALID_DATE"); if (!(day == d.getDate() && month - 1 == d.getMonth() && year == d.getFullYear())) return interaction.error("economy/birthdate:INVALID_DATE");
if (date.getTime() > Date.now()) return interaction.error("economy/birthdate:DATE_TOO_HIGH"); if (d.getTime() > Date.now()) return interaction.error("economy/birthdate:DATE_TOO_HIGH");
if (date.getTime() < Date.now() - 2.523e12) return interaction.error("economy/birthdate:DATE_TOO_LOW"); if (d.getTime() < (Date.now() - 2.523e+12)) return interaction.error("economy/birthdate:DATE_TOO_LOW");
userData.birthdate = d; data.userData.birthdate = d;
await data.userData.save();
userData.markModified("birthdate");
await userData.save();
interaction.success("economy/birthdate:SUCCESS", { interaction.success("economy/birthdate:SUCCESS", {
date: `<t:${d}:D>`, date: client.functions.printDate(client, d),
}); });
} }
} }
module.exports = Birthdate; module.exports = Birthdate;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Divorce extends BaseCommand { class Divorce extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,49 +12,51 @@ class Divorce extends BaseCommand {
.setName("divorce") .setName("divorce")
.setDescription(client.translate("economy/divorce:DESCRIPTION")) .setDescription(client.translate("economy/divorce:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/divorce:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/divorce:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/divorce:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/divorce:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const userData = interaction.data.user; //...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
if (!data.userData.lover) return interaction.error("economy/divorce:NOT_MARRIED");
const user = client.users.cache.get(data.userData.lover) || await client.users.fetch(data.userData.lover);
if (!userData.lover) return interaction.error("economy/divorce:NOT_MARRIED"); data.userData.lover = null;
const user = client.users.cache.get(userData.lover) || await client.users.fetch(userData.lover); await data.userData.save();
userData.lover = null; const oldLover = await client.findOrCreateUser({
id: user.id,
userData.markModified("lover"); });
await userData.save();
const oldLover = await client.findOrCreateUser(user.id);
oldLover.lover = null; oldLover.lover = null;
oldLover.markModified("lover");
await oldLover.save(); await oldLover.save();
interaction.success("economy/divorce:DIVORCED", { interaction.success("economy/divorce:DIVORCED", {
user: user.toString(), user: user.toString(),
}); });
try { user.send({
user.send({ content: interaction.translate("economy/divorce:DIVORCED_U", {
content: interaction.translate("economy/divorce:DIVORCED_U", { user: interaction.member.toString(),
user: interaction.member.toString(), }),
}), });
});
} catch (e) { /**/ }
} }
} }
module.exports = Divorce; module.exports = Divorce;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Leaderboard extends BaseCommand { class Leaderboard extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,56 +12,55 @@ class Leaderboard extends BaseCommand {
.setName("leaderboard") .setName("leaderboard")
.setDescription(client.translate("economy/leaderboard:DESCRIPTION")) .setDescription(client.translate("economy/leaderboard:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/leaderboard:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/leaderboard:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/leaderboard:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/leaderboard:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addStringOption(option => .addStringOption(option => option.setName("type")
option .setDescription(client.translate("owner/debug:TYPE"))
.setName("type") .setDescriptionLocalizations({
.setDescription(client.translate("owner/debug:TYPE")) "uk": client.translate("owner/debug:TYPE", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("owner/debug:TYPE", null, "ru-RU"),
uk: client.translate("owner/debug:TYPE", null, "uk-UA"), })
ru: client.translate("owner/debug:TYPE", null, "ru-RU"), .setRequired(true)
}) .setChoices(
.setRequired(true) { name: client.translate("common:LEVEL"), value: "level" },
.setChoices({ name: client.translate("common:LEVEL"), value: "level" }, { name: client.translate("common:MONEY"), value: "money" }, { name: client.translate("common:REP"), value: "rep" }), { name: client.translate("common:MONEY"), value: "money" },
), { name: client.translate("common:REP"), value: "rep" },
)),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
const type = interaction.options.getString("type"); const type = interaction.options.getString("type");
const isOnMobile = JSON.stringify(Object.keys(interaction.member.presence.clientStatus)) === JSON.stringify(["mobile"]); const isOnMobile = JSON.stringify(Object.keys(interaction.member.presence.clientStatus)) === JSON.stringify(["mobile"]);
if (isOnMobile) if (isOnMobile) interaction.followUp({
interaction.followUp({ content: interaction.translate("economy/leaderboard:MOBILE"),
content: interaction.translate("economy/leaderboard:MOBILE"), ephemeral: true,
ephemeral: true,
});
const embed = client.embed({
author: {
name: interaction.translate("economy/leaderboard:TABLE", {
name: interaction.guild.name,
}),
iconURL: interaction.guild.iconURL(),
},
}); });
if (type === "money") { if (type === "money") {
const membersLeaderboard = [], const membersLeaderboard = [],
membersData = await client.membersData.find({ guildID: interaction.guildId }).lean(); membersData = await client.membersData.find({ guildID: interaction.guildId }).lean();
await client.functions.asyncForEach(membersData, member => { client.functions.asyncForEach(membersData, member => {
membersLeaderboard.push({ membersLeaderboard.push({
id: member.id, id: member.id,
money: member.money + member.bankSold, money: member.money + member.bankSold,
@ -79,18 +78,23 @@ class Leaderboard extends BaseCommand {
money += `${data.money}\n`; money += `${data.money}\n`;
} }
embed.data.fields = [ const embed = new EmbedBuilder()
{ .setAuthor({
name: interaction.translate("economy/leaderboard:TABLE", {
name: interaction.guild.name,
}),
iconURL: interaction.guild.iconURL(),
})
.setColor(client.config.embed.color)
.addFields({
name: interaction.translate("common:USER"), name: interaction.translate("common:USER"),
value: userNames, value: userNames,
inline: true, inline: true,
}, }, {
{
name: interaction.translate("common:CREDITS"), name: interaction.translate("common:CREDITS"),
value: money, value: money,
inline: true, inline: true,
}, });
];
interaction.editReply({ interaction.editReply({
embeds: [embed], embeds: [embed],
@ -99,7 +103,7 @@ class Leaderboard extends BaseCommand {
const membersLeaderboard = [], const membersLeaderboard = [],
membersData = await client.membersData.find({ guildID: interaction.guildId }).lean(); membersData = await client.membersData.find({ guildID: interaction.guildId }).lean();
await client.functions.asyncForEach(membersData, async member => { client.functions.asyncForEach(membersData, async member => {
membersLeaderboard.push({ membersLeaderboard.push({
id: member.id, id: member.id,
level: member.level, level: member.level,
@ -120,23 +124,31 @@ class Leaderboard extends BaseCommand {
xp.push(`${data.xp} / ${5 * (data.level * data.level) + 80 * data.level + 100}`); xp.push(`${data.xp} / ${5 * (data.level * data.level) + 80 * data.level + 100}`);
} }
embed.data.fields = [ const embed = new EmbedBuilder()
{ .setAuthor({
name: interaction.translate("common:USER"), name: interaction.translate("economy/leaderboard:TABLE", {
value: userNames.join("\n"), name: interaction.guild.name,
inline: true, }),
}, iconURL: interaction.guild.iconURL(),
{ })
name: interaction.translate("common:LEVEL"), .setColor(client.config.embed.color)
value: level.join("\n"), .addFields([
inline: true, {
}, name: interaction.translate("common:USER"),
{ value: userNames.join("\n"),
name: interaction.translate("common:XP"), inline: true,
value: xp.join("\n"), },
inline: true, {
}, name: interaction.translate("common:LEVEL"),
]; value: level.join("\n"),
inline: true,
},
{
name: interaction.translate("common:XP"),
value: xp.join("\n"),
inline: true,
},
]);
interaction.editReply({ interaction.editReply({
embeds: [embed], embeds: [embed],
@ -145,7 +157,7 @@ class Leaderboard extends BaseCommand {
const usersLeaderboard = [], const usersLeaderboard = [],
usersData = await client.usersData.find({ rep: { $gt: 0 } }).lean(); usersData = await client.usersData.find({ rep: { $gt: 0 } }).lean();
await client.functions.asyncForEach(usersData, async user => { client.functions.asyncForEach(usersData, async user => {
usersLeaderboard.push({ usersLeaderboard.push({
id: user.id, id: user.id,
rep: user.rep, rep: user.rep,
@ -163,18 +175,23 @@ class Leaderboard extends BaseCommand {
rep += `${data.rep}\n`; rep += `${data.rep}\n`;
} }
embed.data.fields = [ const embed = new EmbedBuilder()
{ .setAuthor({
name: interaction.translate("economy/leaderboard:TABLE", {
name: interaction.guild.name,
}),
iconURL: interaction.guild.iconURL(),
})
.setColor(client.config.embed.color)
.addFields({
name: interaction.translate("common:USER"), name: interaction.translate("common:USER"),
value: userNames, value: userNames,
inline: true, inline: true,
}, }, {
{
name: interaction.translate("common:REP"), name: interaction.translate("common:REP"),
value: rep, value: rep,
inline: true, inline: true,
}, });
];
interaction.editReply({ interaction.editReply({
embeds: [embed], embeds: [embed],
@ -183,4 +200,4 @@ class Leaderboard extends BaseCommand {
} }
} }
module.exports = Leaderboard; module.exports = Leaderboard;

View file

@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class Marry extends BaseCommand { class Marry extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,67 +13,68 @@ class Marry extends BaseCommand {
.setName("marry") .setName("marry")
.setDescription(client.translate("economy/marry:DESCRIPTION")) .setDescription(client.translate("economy/marry:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/marry:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/marry:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/marry:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/marry:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })
ru: client.translate("common:USER", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const userData = interaction.data.user; //...
}
if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED"); /**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
if (data.userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED");
const member = interaction.options.getMember("user"); const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/marry:BOT_USER"); if (member.user.bot) return interaction.error("economy/marry:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF"); if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF");
const otherUserData = await client.findOrCreateUser(member.id); const userData = await client.findOrCreateUser({
if (otherUserData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() }); id: member.id,
});
if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() });
for (const requester in pendings) { for (const requester in pendings) {
const receiver = pendings[requester]; const receiver = pendings[requester];
if (requester === interaction.author.id) { if (requester === interaction.author.id) {
const user = client.users.cache.get(receiver) || (await client.users.fetch(receiver)); const user = client.users.cache.get(receiver) || await client.users.fetch(receiver);
return interaction.error("economy/marry:REQUEST_AUTHOR_TO_AMEMBER", { return interaction.error("economy/marry:REQUEST_AUTHOR_TO_AMEMBER", {
user: user.toString, user: user.toString,
}); });
} else if (receiver === interaction.member.id) { } else if (receiver === interaction.member.id) {
const user = client.users.cache.get(requester) || (await client.users.fetch(requester)); const user = client.users.cache.get(requester) || await client.users.fetch(requester);
return interaction.error("economy/marry:REQUEST_AMEMBER_TO_AUTHOR", { return interaction.error("economy/marry:REQUEST_AMEMBER_TO_AUTHOR", {
user: user.toString(), user: user.toString(),
}); });
} else if (requester === member.id) { } else if (requester === member.id) {
const user = client.users.cache.get(receiver) || (await client.users.fetch(receiver)); const user = client.users.cache.get(receiver) || await client.users.fetch(receiver);
return interaction.error("economy/marry:REQUEST_AMEMBER_TO_MEMBER", { return interaction.error("economy/marry:REQUEST_AMEMBER_TO_MEMBER", {
firstUser: member.toString(), firstUser: member.toString(),
secondUser: user.toString(), secondUser: user.toString(),
}); });
} else if (receiver === member.id) { } else if (receiver === member.id) {
const user = client.users.cache.get(requester) || (await client.users.fetch(requester)); const user = client.users.cache.get(requester) || await client.users.fetch(requester);
return interaction.error("economy/marry:REQUEST_MEMBER_TO_AMEMBER", { return interaction.error("economy/marry:REQUEST_MEMBER_TO_AMEMBER", {
firstUser: member.toString(), firstUser: member.toString(),
secondUser: user.toString(), secondUser: user.toString(),
@ -83,10 +84,17 @@ class Marry extends BaseCommand {
pendings[interaction.member.id] = member.id; pendings[interaction.member.id] = member.id;
const row = new ActionRowBuilder().addComponents( const row = new ActionRowBuilder()
new ButtonBuilder().setCustomId("marry_confirm_yes").setLabel(interaction.translate("common:ACCEPT")).setStyle(ButtonStyle.Success), .addComponents(
new ButtonBuilder().setCustomId("marry_confirm_no").setLabel(interaction.translate("common:CANCEL")).setStyle(ButtonStyle.Danger), new ButtonBuilder()
); .setCustomId("marry_confirm_yes")
.setLabel(interaction.translate("common:ACCEPT"))
.setStyle(ButtonStyle.Success),
new ButtonBuilder()
.setCustomId("marry_confirm_no")
.setLabel(interaction.translate("common:CANCEL"))
.setStyle(ButtonStyle.Danger),
);
await interaction.reply({ await interaction.reply({
content: interaction.translate("economy/marry:REQUEST", { content: interaction.translate("economy/marry:REQUEST", {
@ -97,7 +105,7 @@ class Marry extends BaseCommand {
}); });
const filter = i => i.user.id === member.id; const filter = i => i.user.id === member.id;
const collector = interaction.channel.createMessageComponentCollector({ filter, idle: 10 * 60 * 1000 }); const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (10 * 60 * 1000) });
collector.on("collect", async i => { collector.on("collect", async i => {
if (i.isButton()) { if (i.isButton()) {
@ -119,44 +127,37 @@ class Marry extends BaseCommand {
} }
if (reason) { if (reason) {
userData.lover = member.id; data.userData.lover = member.id;
otherUserData.lover = interaction.member.id; await data.userData.save();
userData.lover = interaction.member.id;
userData.markModified("lover");
otherUserData.markModified("lover");
await userData.save(); await userData.save();
await otherUserData.save();
const messageOptions = { const messageOptions = {
content: `${member.toString()} :heart: ${interaction.member.toString()}`, content: `${member.toString()} :heart: ${interaction.member.toString()}`,
files: [ files: [{
{ name: "achievement_unlocked3.png",
name: "achievement_unlocked3.png", attachment: "./assets/img/achievements/achievement_unlocked3.png",
attachment: "./assets/img/achievements/achievement_unlocked3.png", }],
},
],
}; };
let sent = false; let sent = false;
if (!otherUserData.achievements.married.achieved) { if (!userData.achievements.married.achieved) {
interaction.followUp(messageOptions); interaction.followUp(messageOptions);
sent = true; sent = true;
otherUserData.achievements.married.achieved = true;
otherUserData.achievements.married.progress.now = 1;
otherUserData.markModified("achievements");
await otherUserData.save();
}
if (!userData.achievements.married.achieved) {
if (!sent) interaction.followUp(messageOptions);
userData.achievements.married.achieved = true; userData.achievements.married.achieved = true;
userData.achievements.married.progress.now = 1; userData.achievements.married.progress.now = 1;
userData.markModified("achievements.married");
userData.markModified("achievements");
await userData.save(); await userData.save();
} }
if (!data.userData.achievements.married.achieved) {
if (!sent) interaction.followUp(messageOptions);
data.userData.achievements.married.achieved = true;
data.userData.achievements.married.progress.now = 1;
data.userData.markModified("achievements.married");
await data.userData.save();
}
return interaction.editReply({ return interaction.editReply({
content: interaction.translate("economy/marry:SUCCESS", { content: interaction.translate("economy/marry:SUCCESS", {
creator: interaction.member.toString(), creator: interaction.member.toString(),
@ -164,15 +165,17 @@ class Marry extends BaseCommand {
}), }),
components: [], components: [],
}); });
} else return interaction.editReply({ } else {
content: interaction.translate("economy/marry:DENIED", { return interaction.editReply({
creator: interaction.member.toString(), content: interaction.translate("economy/marry:DENIED", {
partner: member.toString(), creator: interaction.member.toString(),
}, "error"), partner: member.toString(),
components: [], }),
}); components: [],
});
}
}); });
} }
} }
module.exports = Marry; module.exports = Marry;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Money extends BaseCommand { class Money extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,39 +12,46 @@ class Money extends BaseCommand {
.setName("money") .setName("money")
.setDescription(client.translate("economy/money:DESCRIPTION")) .setDescription(client.translate("economy/money:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/money:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/money:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/money:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/money:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })),
ru: client.translate("common:USER", null, "ru-RU"), aliases: [],
}),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
await interaction.deferReply(); await interaction.deferReply();
const member = interaction.options.getMember("user") || interaction.member; const member = interaction.options.getMember("user") || interaction.member;
if (member.user.bot) return interaction.error("economy/money:BOT_USER"); if (member.user.bot) return interaction.error("economy/money:BOT_USER");
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId }); const memberData = member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({
id: member.id,
guildId: interaction.guildId,
});
const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id)); const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id));
let globalMoney = 0; let globalMoney = 0;
await client.functions.asyncForEach(guilds, async guild => { await client.functions.asyncForEach(guilds, async guild => {
const data = await client.findOrCreateMember({ const data = await client.findOrCreateMember({
@ -54,14 +61,14 @@ class Money extends BaseCommand {
globalMoney += data.money + data.bankSold; globalMoney += data.money + data.bankSold;
}); });
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("economy/money:TITLE", { name: interaction.translate("economy/money:TITLE", {
user: member.user.getUsername(), user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
}), }),
iconURL: member.user.displayAvatarURL(), iconURL: member.user.displayAvatarURL(),
}, })
fields: [ .addFields([
{ {
name: interaction.translate("economy/profile:CASH"), name: interaction.translate("economy/profile:CASH"),
value: `**${memberData.money}** ${client.functions.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, value: `**${memberData.money}** ${client.functions.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
@ -77,13 +84,15 @@ class Money extends BaseCommand {
value: `**${globalMoney}** ${client.functions.getNoun(globalMoney, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, value: `**${globalMoney}** ${client.functions.getNoun(globalMoney, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
inline: true, inline: true,
}, },
], ])
}); .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
interaction.editReply({ interaction.editReply({
embeds: [embed], embeds: [embed],
}); });
} }
} }
module.exports = Money; module.exports = Money;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Pay extends BaseCommand { class Pay extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,89 +12,85 @@ class Pay extends BaseCommand {
.setName("pay") .setName("pay")
.setDescription(client.translate("economy/pay:DESCRIPTION")) .setDescription(client.translate("economy/pay:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/pay:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/pay:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/pay:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/pay:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })
ru: client.translate("common:USER", null, "ru-RU"), .setRequired(true))
}) .addIntegerOption(option => option.setName("amount")
.setRequired(true), .setDescription(client.translate("common:INT"))
) .setDescriptionLocalizations({
.addIntegerOption(option => "uk": client.translate("common:INT", null, "uk-UA"),
option "ru": client.translate("common:INT", null, "ru-RU"),
.setName("amount") })
.setDescription(client.translate("common:INT")) .setRequired(true)),
.setDescriptionLocalizations({ aliases: [],
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const memberData = interaction.data.member, //...
otherMember = interaction.options.getMember("user"); }
if (otherMember.user.bot) return interaction.error("economy/pay:BOT_USER"); /**
if (otherMember.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF"); *
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/pay:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/pay:YOURSELF");
const amount = interaction.options.getInteger("amount"); const amount = interaction.options.getInteger("amount");
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO"); if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
if (amount > memberData.money) if (amount > data.memberData.money) return interaction.error("economy/pay:ENOUGH_MONEY", {
return interaction.error("economy/pay:ENOUGH_MONEY", { amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`,
amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDITS:1"), interaction.translate("misc:NOUNS:CREDITS:2"), interaction.translate("misc:NOUNS:CREDITS:5"))}`, });
});
const otherMemberData = await client.findOrCreateMember({ const memberData = await client.findOrCreateMember({
id: otherMember.id, id: member.id,
guildId: interaction.guildId, guildId: interaction.guildId,
}); });
memberData.money -= amount; data.memberData.money -= amount;
await data.memberData.save();
memberData.markModified("money"); memberData.money += amount;
await memberData.save(); await memberData.save();
otherMemberData.money += amount;
otherMemberData.markModified("money");
await otherMemberData.save();
const info1 = { const info1 = {
user: otherMember.user.getUsername(), user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
amount: amount, amount: amount,
date: Date.now(), date: Date.now(),
type: "send", type: "send",
}; };
memberData.transactions.push(info1); data.memberData.transactions.push(info1);
const info2 = { const info2 = {
user: otherMember.user.getUsername(), user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
amount: amount, amount: amount,
date: Date.now(), date: Date.now(),
type: "got", type: "got",
}; };
otherMemberData.transactions.push(info2); data.memberData.transactions.push(info2);
interaction.success("economy/pay:SUCCESS", { interaction.success("economy/pay:SUCCESS", {
user: otherMember.toString(), user: member.toString(),
amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, amount: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
}); });
} }
} }
module.exports = Pay; module.exports = Pay;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Profile extends BaseCommand { class Profile extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,37 +12,48 @@ class Profile extends BaseCommand {
.setName("profile") .setName("profile")
.setDescription(client.translate("economy/profile:DESCRIPTION")) .setDescription(client.translate("economy/profile:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/profile:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/profile:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/profile:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/profile:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })),
ru: client.translate("common:USER", null, "ru-RU"), aliases: [],
}),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
await interaction.deferReply(); await interaction.deferReply();
const member = interaction.options.getMember("user") || interaction.member; const member = interaction.options.getMember("user") || interaction.member;
if (member.user.bot) return interaction.error("economy/profile:BOT_USER"); if (member.user.bot) return interaction.error("economy/profile:BOT_USER");
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId }); const memberData = (member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({
const userData = member.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(member.id); id: member.id,
guildId: interaction.guildId,
}));
const userData = (member.id === interaction.user.id ? data.userData : await client.findOrCreateUser({
id: member.id,
}));
if (userData.lover && !client.users.cache.find(u => u.id === userData.lover)) await client.users.fetch(userData.lover, true); if (userData.lover && !client.users.cache.find(u => u.id === userData.lover)) await client.users.fetch(userData.lover, true);
const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id)); const guilds = client.guilds.cache.filter(g => g.members.cache.find(m => m.id === member.id));
@ -57,15 +68,19 @@ class Profile extends BaseCommand {
const lover = client.users.cache.get(userData.lover); const lover = client.users.cache.get(userData.lover);
const embed = client.embed({ const profileEmbed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("economy/profile:TITLE", { name: interaction.translate("economy/profile:TITLE", {
user: member.user.getUsername(), user: member.nickname,
}), }),
iconURL: member.displayAvatarURL(), iconURL: member.displayAvatarURL(),
}, })
image: "attachment://achievements.png", .setImage("attachment://achievements.png")
fields: [ .addFields([
{
name: client.customEmojis.link + " " + interaction.translate("economy/profile:LINK"),
value: `[${interaction.translate("economy/profile:LINK_TEXT")}](${client.config.dashboard.baseURL}/user/${member.user.id}/${interaction.guild.id})`,
},
{ {
name: interaction.translate("economy/profile:BIO"), name: interaction.translate("economy/profile:BIO"),
value: userData.bio ? userData.bio : interaction.translate("common:UNKNOWN"), value: userData.bio ? userData.bio : interaction.translate("common:UNKNOWN"),
@ -92,7 +107,7 @@ class Profile extends BaseCommand {
}, },
{ {
name: interaction.translate("economy/profile:LEVEL"), name: interaction.translate("economy/profile:LEVEL"),
value: `**${memberData.level}**`, value:`**${memberData.level}**`,
inline: true, inline: true,
}, },
{ {
@ -102,38 +117,40 @@ class Profile extends BaseCommand {
}, },
{ {
name: interaction.translate("economy/profile:REGISTERED"), name: interaction.translate("economy/profile:REGISTERED"),
value: `<t:${Math.floor(memberData.registeredAt / 1000)}:f>`, value: client.functions.printDate(client, new Date(memberData.registeredAt)),
inline: true, inline: true,
}, },
{ {
name: interaction.translate("economy/profile:BIRTHDATE"), name: interaction.translate("economy/profile:BIRTHDATE"),
value: !userData.birthdate ? interaction.translate("common:NOT_DEFINED") : `<t:${userData.birthdate}:D>`, value: (!userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.functions.printDate(client, new Date(userData.birthdate))),
inline: true, inline: true,
}, },
{ {
name: interaction.translate("economy/profile:LOVER"), name: interaction.translate("economy/profile:LOVER"),
value: !userData.lover ? interaction.translate("common:NOT_DEFINED") : lover.getUsername(), value: (!userData.lover ? interaction.translate("common:NOT_DEFINED") : lover.discriminator === "0" ? lover.username : lover.tag),
inline: true, inline: true,
}, },
{ {
name: interaction.translate("economy/profile:ACHIEVEMENTS"), name: interaction.translate("economy/profile:ACHIEVEMENTS"),
value: interaction.translate("economy/profile:ACHIEVEMENTS_CONTENT"), value: interaction.translate("economy/profile:ACHIEVEMENTS_CONTENT"),
}, },
], ])
}); .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
})
.setTimestamp();
const achievements = await userData.getAchievements(); const buffer = await userData.getAchievements();
interaction.editReply({ interaction.editReply({
embeds: [embed], embeds: [profileEmbed],
files: [ files: [{
{ name: "achievements.png",
name: "achievements.png", attachment: buffer,
attachment: achievements, }],
},
],
}); });
} }
} }
module.exports = Profile; module.exports = Profile;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Rep extends BaseCommand { class Rep extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,75 +12,75 @@ class Rep extends BaseCommand {
.setName("rep") .setName("rep")
.setDescription(client.translate("economy/rep:DESCRIPTION")) .setDescription(client.translate("economy/rep:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/rep:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/rep:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/rep:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/rep:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })
ru: client.translate("common:USER", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const userData = interaction.data.user, //...
isInCooldown = userData.cooldowns?.rep; }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const isInCooldown = data.userData.cooldowns?.rep;
if (isInCooldown) { if (isInCooldown) {
if (isInCooldown > Date.now()) if (isInCooldown > Date.now()) return interaction.error("economy/rep:COOLDOWN", {
return interaction.error("economy/rep:COOLDOWN", { time: client.functions.convertTime(client, isInCooldown, true, true, data.guildData.language),
time: `<t:${Math.floor(isInCooldown / 1000)}:R>`, });
});
} }
const user = interaction.options.getUser("user"); const user = interaction.options.getUser("user");
if (user.bot) return interaction.error("economy/rep:BOT_USER"); if (user.bot) return interaction.error("economy/rep:BOT_USER");
if (user.id === interaction.user.id) return interaction.error("economy/rep:YOURSELF"); if (user.id === interaction.user.id) return interaction.error("economy/rep:YOURSELF");
const toWait = Math.floor((Date.now() + 12 * 60 * 60 * 1000) / 1000); // 12 hours const toWait = Date.now() + 21600000; // 12 hours
if (!userData.cooldowns) userData.cooldowns = {}; if (!data.userData.cooldowns) data.userData.cooldowns = {};
userData.cooldowns.rep = toWait; data.userData.cooldowns.rep = toWait;
data.userData.markModified("cooldowns");
await data.userData.save();
userData.markModified("cooldowns"); const userData = await client.findOrCreateUser({
await userData.save(); id: user.id,
});
const otherUserData = await client.findOrCreateUser(user.id); userData.rep++;
otherUserData.rep++; if (!userData.achievements.rep.achieved) {
userData.achievements.rep.progress.now = (userData.rep > userData.achievements.rep.progress.total ? userData.achievements.rep.progress.total : userData.rep);
if (!otherUserData.achievements.rep.achieved) { if (userData.achievements.rep.progress.now >= userData.achievements.rep.progress.total) {
otherUserData.achievements.rep.progress.now = otherUserData.rep > otherUserData.achievements.rep.progress.total ? otherUserData.achievements.rep.progress.total : otherUserData.rep; userData.achievements.rep.achieved = true;
if (otherUserData.achievements.rep.progress.now >= otherUserData.achievements.rep.progress.total) {
otherUserData.achievements.rep.achieved = true;
interaction.followUp({ interaction.followUp({
content: `${user}`, content: `${user}`,
files: [ files: [{
{ name: "achievement_unlocked6.png",
name: "achievement_unlocked6.png", attachment: "./assets/img/achievements/achievement_unlocked6.png",
attachment: "./assets/img/achievements/achievement_unlocked6.png", }],
},
],
}); });
} }
userData.markModified("achievements.rep");
} }
await userData.save();
otherUserData.markModified("rep");
await otherUserData.save();
interaction.success("economy/rep:SUCCESS", { interaction.success("economy/rep:SUCCESS", {
user: user.toString(), user: user.toString(),
@ -88,4 +88,4 @@ class Rep extends BaseCommand {
} }
} }
module.exports = Rep; module.exports = Rep;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Rob extends BaseCommand { class Rob extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,90 +12,87 @@ class Rob extends BaseCommand {
.setName("rob") .setName("rob")
.setDescription(client.translate("economy/rob:DESCRIPTION")) .setDescription(client.translate("economy/rob:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/rob:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/rob:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/rob:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/rob:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })
ru: client.translate("common:USER", null, "ru-RU"), .setRequired(true))
}) .addIntegerOption(option => option.setName("amount")
.setRequired(true), .setDescription(client.translate("common:INT"))
) .setDescriptionLocalizations({
.addIntegerOption(option => "uk": client.translate("common:INT", null, "uk-UA"),
option "ru": client.translate("common:INT", null, "ru-RU"),
.setName("amount") })
.setDescription(client.translate("common:INT")) .setRequired(true)),
.setDescriptionLocalizations({ aliases: [],
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const memberData = interaction.data.member, //...
otherMember = interaction.options.getMember("user"); }
if (otherMember.user.bot) return interaction.error("economy/pay:BOT_USER"); /**
if (otherMember.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF"); *
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const member = interaction.options.getMember("user");
if (member.user.bot) return interaction.error("economy/pay:BOT_USER");
if (member.id === interaction.member.id) return interaction.error("economy/rob:YOURSELF");
const amount = interaction.options.getInteger("amount"); const amount = interaction.options.getInteger("amount");
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO"); if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
const otherMemberData = await client.findOrCreateMember({ const memberData = await client.findOrCreateMember({
id: otherMember.id, id: member.id,
guildId: interaction.guildId, guildId: interaction.guildId,
}); });
if (amount > otherMemberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: otherMember.toString() }); if (amount > memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: member.toString() });
const isInCooldown = otherMemberData.cooldowns.rob || 0; const isInCooldown = memberData.cooldowns.rob || 0;
if (isInCooldown) { if (isInCooldown) {
if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: otherMember.toString() }); if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: member.toString() });
} }
const potentiallyLose = Math.floor(amount * 1.5); const potentiallyLose = Math.floor(amount * 1.5);
if (potentiallyLose > memberData.money) if (potentiallyLose > data.memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_AUTHOR", {
return interaction.error("economy/rob:NOT_ENOUGH_AUTHOR", { moneyMin: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
moneyMin: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, moneyCurrent: `**${data.memberData.money}** ${client.functions.getNoun(data.memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
moneyCurrent: `**${memberData.money}** ${client.functions.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, });
});
const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25); const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25);
if (itsAWon) { if (itsAWon) {
const toWait = Date.now() + 6 * 60 * 60 * 1000, const toWait = Date.now() + (6 * 60 * 60 * 1000),
randomNum = client.functions.randomNum(1, 2); randomNum = client.functions.randomNum(1, 2);
otherMemberData.cooldowns.rob = toWait; memberData.cooldowns.rob = toWait;
memberData.markModified("cooldowns");
otherMemberData.markModified("cooldowns"); await memberData.save();
await otherMemberData.save();
interaction.replyT("economy/rob:ROB_WON_" + randomNum, { interaction.replyT("economy/rob:ROB_WON_" + randomNum, {
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
user: otherMember.toString(), user: member.toString(),
}); });
memberData.money += amount; data.memberData.money += amount;
otherMemberData.money -= amount; memberData.money -= amount;
memberData.markModified("money");
otherMemberData.markModified("money");
await memberData.save(); await memberData.save();
await otherMemberData.save(); await data.memberData.save();
} else { } else {
const won = Math.floor(amount * 0.9), const won = Math.floor(amount * 0.9),
randomNum = client.functions.randomNum(1, 2); randomNum = client.functions.randomNum(1, 2);
@ -103,18 +100,16 @@ class Rob extends BaseCommand {
interaction.replyT("economy/rob:ROB_LOSE_" + randomNum, { interaction.replyT("economy/rob:ROB_LOSE_" + randomNum, {
fine: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, fine: `**${potentiallyLose}** ${client.functions.getNoun(potentiallyLose, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
offset: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, offset: `**${won}** ${client.functions.getNoun(won, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
user: otherMember.toString(), user: member.toString(),
}); });
memberData.money -= potentiallyLose; data.memberData.money -= potentiallyLose;
otherMemberData.money += won; memberData.money += won;
memberData.markModified("money");
otherMemberData.markModified("money");
await memberData.save(); await memberData.save();
await otherMemberData.save(); await data.memberData.save();
} }
} }
} }
module.exports = Rob; module.exports = Rob;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Setbio extends BaseCommand { class Setbio extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,42 +12,43 @@ class Setbio extends BaseCommand {
.setName("setbio") .setName("setbio")
.setDescription(client.translate("economy/setbio:DESCRIPTION")) .setDescription(client.translate("economy/setbio:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/setbio:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/setbio:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/setbio:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/setbio:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("text")
option .setDescription(client.translate("economy/profile:BIO"))
.setName("text") .setDescriptionLocalizations({
.setDescription(client.translate("economy/profile:BIO")) "uk": client.translate("economy/profile:BIO", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("economy/profile:BIO", null, "ru-RU"),
uk: client.translate("economy/profile:BIO", null, "uk-UA"), })
ru: client.translate("economy/profile:BIO", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const userData = interaction.data.user, //...
newBio = interaction.options.getString("text"); }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const newBio = interaction.options.getString("text");
if (newBio.length > 150) return interaction.error("economy/setbio:MAX_CHARACTERS"); if (newBio.length > 150) return interaction.error("economy/setbio:MAX_CHARACTERS");
userData.bio = newBio; data.userData.bio = newBio;
await data.userData.save();
userData.markModified("bio");
await userData.save();
interaction.success("economy/setbio:SUCCESS"); interaction.success("economy/setbio:SUCCESS");
} }
} }
module.exports = Setbio; module.exports = Setbio;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Slots extends BaseCommand { class Slots extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,53 +12,52 @@ class Slots extends BaseCommand {
.setName("slots") .setName("slots")
.setDescription(client.translate("economy/slots:DESCRIPTION")) .setDescription(client.translate("economy/slots:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/slots:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/slots:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/slots:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/slots:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addIntegerOption(option => .addIntegerOption(option => option.setName("amount")
option .setDescription(client.translate("common:INT"))
.setName("amount") .setDescriptionLocalizations({
.setDescription(client.translate("common:INT")) "uk": client.translate("common:INT", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:INT", null, "ru-RU"),
uk: client.translate("common:INT", null, "uk-UA"), })
ru: client.translate("common:INT", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
await interaction.deferReply(); await interaction.deferReply();
const { member: memberData, user: userData } = interaction.data, const amount = interaction.options.getInteger("amount");
amount = interaction.options.getInteger("amount"); if (amount > data.memberData.money) return interaction.error("economy/slots:NOT_ENOUGH", { money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}` }, { edit: true });
if (amount > memberData.money)
return interaction.error("economy/slots:NOT_ENOUGH", {
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
}, { edit: true });
const fruits = ["🍎", "🍐", "🍌", "🍇", "🍉", "🍒", "🍓"]; const fruits = ["🍎", "🍐", "🍌", "🍇", "🍉", "🍒", "🍓"];
let i1 = 0, let i1 = 0, j1 = 0, k1 = 0,
j1 = 0, i2 = 1, j2 = 1, k2 = 1,
k1 = 0, i3 = 2, j3 = 2, k3 = 2;
i2 = 1,
j2 = 1,
k2 = 1,
i3 = 2,
j3 = 2,
k3 = 2;
const colonnes = [client.functions.shuffle(fruits), client.functions.shuffle(fruits), client.functions.shuffle(fruits)]; const colonnes = [
client.functions.shuffle(fruits),
client.functions.shuffle(fruits),
client.functions.shuffle(fruits),
];
function getCredits(number, isJackpot) { function getCredits(number, isJackpot) {
if (!isJackpot) number = number * 1.5; if (!isJackpot) number = number * 1.5;
@ -77,78 +76,69 @@ class Slots extends BaseCommand {
}, 4000); }, 4000);
async function end() { async function end() {
let msg = "[ :slot_machine: | **SLOTS** ]\n------------------\n"; let msg = "[ :slot_machine: | **СЛОТЫ** ]\n------------------\n";
i1 = i1 < fruits.length - 1 ? i1 + 1 : 0; i1 = (i1 < fruits.length - 1) ? i1 + 1 : 0;
i2 = i2 < fruits.length - 1 ? i2 + 1 : 0; i2 = (i2 < fruits.length - 1) ? i2 + 1 : 0;
i3 = i3 < fruits.length - 1 ? i3 + 1 : 0; i3 = (i3 < fruits.length - 1) ? i3 + 1 : 0;
j1 = j1 < fruits.length - 1 ? j1 + 1 : 0; j1 = (j1 < fruits.length - 1) ? j1 + 1 : 0;
j2 = j2 < fruits.length - 1 ? j2 + 1 : 0; j2 = (j2 < fruits.length - 1) ? j2 + 1 : 0;
j3 = j3 < fruits.length - 1 ? j3 + 1 : 0; j3 = (j3 < fruits.length - 1) ? j3 + 1 : 0;
k1 = k1 < fruits.length - 1 ? k1 + 1 : 0; k1 = (k1 < fruits.length - 1) ? k1 + 1 : 0;
k2 = k2 < fruits.length - 1 ? k2 + 1 : 0; k2 = (k2 < fruits.length - 1) ? k2 + 1 : 0;
k3 = k3 < fruits.length - 1 ? k3 + 1 : 0; k3 = (k3 < fruits.length - 1) ? k3 + 1 : 0;
msg += colonnes[0][i1] + " : " + colonnes[1][j1] + " : " + colonnes[2][k1] + "\n"; msg += colonnes[0][i1] + " : " + colonnes[1][j1] + " : " + colonnes[2][k1] + "\n";
msg += colonnes[0][i2] + " : " + colonnes[1][j2] + " : " + colonnes[2][k2] + " **<**\n"; msg += colonnes[0][i2] + " : " + colonnes[1][j2] + " : " + colonnes[2][k2] + " **<**\n";
msg += colonnes[0][i3] + " : " + colonnes[1][j3] + " : " + colonnes[2][k3] + "\n------------------\n"; msg += colonnes[0][i3] + " : " + colonnes[1][j3] + " : " + colonnes[2][k3] + "\n------------------\n";
if (colonnes[0][i2] == colonnes[1][j2] && colonnes[1][j2] == colonnes[2][k2]) { if ((colonnes[0][i2] == colonnes[1][j2]) && (colonnes[1][j2] == colonnes[2][k2])) {
msg += "| : : : **" + interaction.translate("common:VICTORY").toUpperCase() + "** : : : |"; msg += "| : : : **" + (interaction.translate("common:VICTORY").toUpperCase()) + "** : : : |";
await interaction.editReply({ await interaction.editReply({
content: msg, content: msg,
}); });
const credits = getCredits(amount, true); const credits = getCredits(amount, true);
interaction.followUp({ interaction.followUp({
content: content: "**!! ДЖЕКПОТ !!**\n" + interaction.translate("economy/slots:VICTORY", {
"**!! JACKPOT !!**\n" + money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
interaction.translate("economy/slots:VICTORY", { won: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, user: interaction.member.toString(),
won: `**${credits}** ${client.functions.getNoun(credits, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, }),
user: interaction.member.toString(),
}),
}); });
const toAdd = credits - amount; const toAdd = credits - amount;
data.memberData.money += toAdd;
const info = { const info = {
user: interaction.translate("economy/slots:DESCRIPTION"), user: interaction.translate("economy/slots:DESCRIPTION"),
amount: toAdd, amount: toAdd,
date: Date.now(), date: Date.now(),
type: "got", type: "got",
}; };
data.memberData.transactions.push(info);
memberData.money += toAdd; if (!data.userData.achievements.slots.achieved) {
memberData.transactions.push(info); data.userData.achievements.slots.progress.now += 1;
if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) {
if (!userData.achievements.slots.achieved) { data.userData.achievements.slots.achieved = true;
userData.achievements.slots.progress.now += 1;
if (userData.achievements.slots.progress.now === userData.achievements.slots.progress.total) {
userData.achievements.slots.achieved = true;
interaction.followUp({ interaction.followUp({
files: [ files: [{
{ name: "achievement_unlocked4.png",
name: "achievement_unlocked4.png", attachment: "./assets/img/achievements/achievement_unlocked4.png",
attachment: "./assets/img/achievements/achievement_unlocked4.png", }],
},
],
}); });
} }
data.userData.markModified("achievements.slots");
userData.markModified("achievements"); await data.userData.save();
await userData.save();
} }
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("transactions");
await memberData.save();
return; return;
} }
if (colonnes[0][i2] == colonnes[1][j2] || colonnes[1][j2] == colonnes[2][k2] || colonnes[0][i2] == colonnes[2][k2]) { if (colonnes[0][i2] == colonnes[1][j2] || colonnes[1][j2] == colonnes[2][k2] || colonnes[0][i2] == colonnes[2][k2]) {
msg += "| : : : **" + interaction.translate("common:VICTORY").toUpperCase() + "** : : : |"; msg += "| : : : **" + (interaction.translate("common:VICTORY").toUpperCase()) + "** : : : |";
await interaction.editReply({ await interaction.editReply({
content: msg, content: msg,
}); });
@ -169,36 +159,28 @@ class Slots extends BaseCommand {
date: Date.now(), date: Date.now(),
type: "got", type: "got",
}; };
data.memberData.transactions.push(info);
data.memberData.money += toAdd;
memberData.money += toAdd; if (!data.userData.achievements.slots.achieved) {
memberData.transactions.push(info); data.userData.achievements.slots.progress.now += 1;
if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) {
if (!userData.achievements.slots.achieved) { data.userData.achievements.slots.achieved = true;
userData.achievements.slots.progress.now += 1;
if (userData.achievements.slots.progress.now === userData.achievements.slots.progress.total) {
userData.achievements.slots.achieved = true;
interaction.followUp({ interaction.followUp({
files: [ files: [{
{ name: "achievement_unlocked4.png",
name: "achievement_unlocked4.png", attachment: "./assets/img/achievements/achievement_unlocked4.png",
attachment: "./assets/img/achievements/achievement_unlocked4.png", }],
},
],
}); });
} }
data.userData.markModified("achievements.slots");
userData.markModified("achievements"); await data.userData.save();
await userData.save();
} }
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("transactions");
await memberData.save();
return; return;
} }
msg += "| : : : **" + interaction.translate("common:DEFEAT").toUpperCase() + "** : : : |"; msg += "| : : : **" + (interaction.translate("common:DEFEAT").toUpperCase()) + "** : : : |";
interaction.followUp({ interaction.followUp({
content: interaction.translate("economy/slots:DEFEAT", { content: interaction.translate("economy/slots:DEFEAT", {
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`, money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
@ -212,36 +194,30 @@ class Slots extends BaseCommand {
date: Date.now(), date: Date.now(),
type: "send", type: "send",
}; };
data.memberData.transactions.push(info);
data.memberData.money -= amount;
memberData.money -= amount; if (!data.userData.achievements.slots.achieved) {
memberData.transactions.push(info); data.userData.achievements.slots.progress.now = 0;
data.userData.markModified("achievements.slots");
if (!userData.achievements.slots.achieved) { await data.userData.save();
userData.achievements.slots.progress.now = 0;
userData.markModified("achievements");
await userData.save();
} }
await data.memberData.save();
memberData.markModified("money");
memberData.markModified("transactions");
await memberData.save();
return; return;
} }
async function editMsg() { async function editMsg() {
let msg = "[ :slot_machine: | **SLOTS** ]\n------------------\n"; let msg = "[ :slot_machine: | **СЛОТЫ** ]\n------------------\n";
i1 = i1 < fruits.length - 1 ? i1 + 1 : 0; i1 = (i1 < fruits.length - 1) ? i1 + 1 : 0;
i2 = i2 < fruits.length - 1 ? i2 + 1 : 0; i2 = (i2 < fruits.length - 1) ? i2 + 1 : 0;
i3 = i3 < fruits.length - 1 ? i3 + 1 : 0; i3 = (i3 < fruits.length - 1) ? i3 + 1 : 0;
j1 = j1 < fruits.length - 1 ? j1 + 1 : 0; j1 = (j1 < fruits.length - 1) ? j1 + 1 : 0;
j2 = j2 < fruits.length - 1 ? j2 + 1 : 0; j2 = (j2 < fruits.length - 1) ? j2 + 1 : 0;
j3 = j3 < fruits.length - 1 ? j3 + 1 : 0; j3 = (j3 < fruits.length - 1) ? j3 + 1 : 0;
k1 = k1 < fruits.length - 1 ? k1 + 1 : 0; k1 = (k1 < fruits.length - 1) ? k1 + 1 : 0;
k2 = k2 < fruits.length - 1 ? k2 + 1 : 0; k2 = (k2 < fruits.length - 1) ? k2 + 1 : 0;
k3 = k3 < fruits.length - 1 ? k3 + 1 : 0; k3 = (k3 < fruits.length - 1) ? k3 + 1 : 0;
msg += colonnes[0][i1] + " : " + colonnes[1][j1] + " : " + colonnes[2][k1] + "\n"; msg += colonnes[0][i1] + " : " + colonnes[1][j1] + " : " + colonnes[2][k1] + "\n";
msg += colonnes[0][i2] + " : " + colonnes[1][j2] + " : " + colonnes[2][k2] + " **<**\n"; msg += colonnes[0][i2] + " : " + colonnes[1][j2] + " : " + colonnes[2][k2] + " **<**\n";
@ -254,4 +230,4 @@ class Slots extends BaseCommand {
} }
} }
module.exports = Slots; module.exports = Slots;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Transactions extends BaseCommand { class Transactions extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,78 +12,77 @@ class Transactions extends BaseCommand {
.setName("transactions") .setName("transactions")
.setDescription(client.translate("economy/transactions:DESCRIPTION")) .setDescription(client.translate("economy/transactions:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/transactions:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/transactions:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/transactions:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/transactions:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addBooleanOption(option => .addBooleanOption(option => option.setName("clear")
option .setDescription(client.translate("economy/transactions:CLEAR"))
.setName("clear") .setDescriptionLocalizations({
.setDescription(client.translate("economy/transactions:CLEAR")) "uk": client.translate("economy/transactions:CLEAR", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("economy/transactions:CLEAR", null, "ru-RU"),
uk: client.translate("economy/transactions:CLEAR", null, "uk-UA"), })),
ru: client.translate("economy/transactions:CLEAR", null, "ru-RU"), aliases: [],
}),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const memberData = interaction.data.member; //...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
if (interaction.options.getBoolean("clear")) { if (interaction.options.getBoolean("clear")) {
memberData.transactions = []; data.memberData.transactions = [];
await data.memberData.save();
memberData.markModified("transactions");
await memberData.save();
return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true }); return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true });
} }
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("economy/transactions:EMBED_TRANSACTIONS"), name: interaction.translate("economy/transactions:EMBED_TRANSACTIONS"),
iconURL: interaction.member.displayAvatarURL(), iconURL: interaction.member.displayAvatarURL(),
}, })
}); .setColor(client.config.embed.color)
const transactions = memberData.transactions, .setFooter({
sortedTransactions = [[], []]; text: client.config.embed.footer,
});
const transactions = data.memberData.transactions,
sortedTransactions = [ [], [] ];
transactions.slice(-20).forEach(t => { transactions.slice(-20).forEach(t => {
const array = t.type === "got" ? sortedTransactions[0] : sortedTransactions[1]; const array = t.type === "got" ? sortedTransactions[0] : sortedTransactions[1];
array.push( array.push(`${interaction.translate("economy/transactions:T_USER_" + t.type.toUpperCase())}: ${t.user}\n${interaction.translate("economy/transactions:T_AMOUNT")}: ${t.amount}\n${interaction.translate("economy/transactions:T_DATE")}: ${client.functions.printDate(client, t.date, "Do MMMM YYYY, HH:mm", data.guildData.language)}\n`);
`${interaction.translate("economy/transactions:T_USER_" + t.type.toUpperCase())}: ${t.user}\n${interaction.translate("economy/transactions:T_AMOUNT")}: ${t.amount}\n${interaction.translate(
"economy/transactions:T_DATE",
)}: <t:${Math.floor(t.date / 1000)}:f>\n`,
);
}); });
if (transactions.length < 1) { if (transactions.length < 1) {
embed.data.description = interaction.translate("economy/transactions:NO_TRANSACTIONS"); embed.setDescription(interaction.translate("economy/transactions:NO_TRANSACTIONS"));
} else { } else {
if (sortedTransactions[0].length > 0) if (sortedTransactions[0].length > 0) embed.addFields([
embed.data.fields.push([ {
{ name: interaction.translate("economy/transactions:T_GOT"),
name: interaction.translate("economy/transactions:T_GOT"), value: sortedTransactions[0].join("\n"),
value: sortedTransactions[0].join("\n"), inline: true,
inline: true, },
}, ]);
]); if (sortedTransactions[1].length > 0) embed.addFields([
if (sortedTransactions[1].length > 0) {
embed.data.fields.push([ name: interaction.translate("economy/transactions:T_SEND"),
{ value: sortedTransactions[1].join("\n"),
name: interaction.translate("economy/transactions:T_SEND"), inline: true,
value: sortedTransactions[1].join("\n"), },
inline: true, ]);
},
]);
} }
interaction.reply({ interaction.reply({
@ -92,4 +91,4 @@ class Transactions extends BaseCommand {
} }
} }
module.exports = Transactions; module.exports = Transactions;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, parseEmoji } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Work extends BaseCommand { class Work extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,54 +12,63 @@ class Work extends BaseCommand {
.setName("work") .setName("work")
.setDescription(client.translate("economy/work:DESCRIPTION")) .setDescription(client.translate("economy/work:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("economy/work:DESCRIPTION", null, "uk-UA"), "uk": client.translate("economy/work:DESCRIPTION", null, "uk-UA"),
ru: client.translate("economy/work:DESCRIPTION", null, "ru-RU"), "ru": client.translate("economy/work:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
const { member: memberData, user: userData } = interaction.data, //...
isInCooldown = memberData.cooldowns?.work; }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const isInCooldown = data.memberData.cooldowns?.work;
if (isInCooldown) { if (isInCooldown) {
if (isInCooldown > Date.now()) if (isInCooldown > Date.now()) return interaction.error("economy/work:COOLDOWN", {
return interaction.error("economy/work:COOLDOWN", { time: client.functions.convertTime(client, isInCooldown, true, true, data.guildData.language),
time: `<t:${Math.floor(isInCooldown / 1000)}:R>`, });
});
} }
if (Date.now() > data.memberData.cooldowns.work + (24 * 60 * 60 * 1000)) data.memberData.workStreak = 0;
if (Date.now() > memberData.cooldowns.work + 24 * 60 * 60 * 1000) memberData.workStreak = 0; const toWait = Date.now() + (24 * 60 * 60 * 1000); // 24 hours
data.memberData.cooldowns.work = toWait;
data.memberData.markModified("cooldowns");
const toWait = Math.floor((Date.now() + 24 * 60 * 60 * 1000) / 1000); // 24 hours data.memberData.workStreak = (data.memberData.workStreak || 0) + 1;
memberData.cooldowns.work = toWait; await data.memberData.save();
memberData.workStreak = (memberData.workStreak || 0) + 1;
memberData.markModified("cooldowns"); const embed = new EmbedBuilder()
memberData.markModified("workStreak"); .setFooter({
await memberData.save();
const embed = client.embed({
footer: {
text: interaction.translate("economy/work:AWARD"), text: interaction.translate("economy/work:AWARD"),
iconURL: interaction.member.displayAvatarURL(), iconURL: interaction.member.displayAvatarURL(),
}, })
}); .setColor(client.config.embed.color);
const award = [client.customEmojis.letters.a, client.customEmojis.letters.w, client.customEmojis.letters.a, client.customEmojis.letters.r, client.customEmojis.letters.d]; const award = [
client.customEmojis.letters.a,
client.customEmojis.letters.w,
client.customEmojis.letters.a,
client.customEmojis.letters.r,
client.customEmojis.letters.d,
];
let won = 200; let won = 200;
if (memberData.workStreak >= 5) { if (data.memberData.workStreak >= 5) {
won += 200; won += 200;
embed.data.fields = [ embed.addFields([
{ {
name: interaction.translate("economy/work:SALARY"), name: interaction.translate("economy/work:SALARY"),
value: interaction.translate("economy/work:SALARY_CONTENT", { value: interaction.translate("economy/work:SALARY_CONTENT", {
@ -70,17 +79,16 @@ class Work extends BaseCommand {
name: interaction.translate("economy/work:STREAK"), name: interaction.translate("economy/work:STREAK"),
value: interaction.translate("economy/work:STREAK_CONTENT"), value: interaction.translate("economy/work:STREAK_CONTENT"),
}, },
]; ]);
data.memberData.workStreak = 0;
memberData.workStreak = 0;
} else { } else {
for (let i = 0; i < award.length; i++) { for (let i = 0; i < award.length; i++) {
if (memberData.workStreak > i) { if (data.memberData.workStreak > i) {
const letter = parseEmoji(award[i]).name.split("_")[1]; const letter = parseEmoji(award[i]).name.split("_")[1];
award[i] = `:regional_indicator_${letter.toLowerCase()}:`; award[i] = `:regional_indicator_${letter.toLowerCase()}:`;
} }
} }
embed.data.fields = [ embed.addFields([
{ {
name: interaction.translate("economy/work:SALARY"), name: interaction.translate("economy/work:SALARY"),
value: interaction.translate("economy/work:SALARY_CONTENT", { value: interaction.translate("economy/work:SALARY_CONTENT", {
@ -91,13 +99,11 @@ class Work extends BaseCommand {
name: interaction.translate("economy/work:STREAK"), name: interaction.translate("economy/work:STREAK"),
value: award.join(""), value: award.join(""),
}, },
]; ]);
} }
memberData.money += won; data.memberData.money += won;
await data.memberData.save();
memberData.markModified("money");
await memberData.save();
const info = { const info = {
user: interaction.translate("economy/work:SALARY"), user: interaction.translate("economy/work:SALARY"),
@ -105,30 +111,26 @@ class Work extends BaseCommand {
date: Date.now(), date: Date.now(),
type: "got", type: "got",
}; };
memberData.transactions.push(info); data.memberData.transactions.push(info);
const messageOptions = { const messageOptions = {
embeds: [embed], embeds: [embed],
}; };
if (!data.userData.achievements.work.achieved) {
if (!userData.achievements.work.achieved) { data.userData.achievements.work.progress.now += 1;
userData.achievements.work.progress.now += 1; if (data.userData.achievements.work.progress.now === data.userData.achievements.work.progress.total) {
if (userData.achievements.work.progress.now === userData.achievements.work.progress.total) { messageOptions.files = [{
messageOptions.files = [ name: "unlocked.png",
{ attachment: "./assets/img/achievements/achievement_unlocked1.png",
name: "unlocked.png", }];
attachment: "./assets/img/achievements/achievement_unlocked1.png", data.userData.achievements.work.achieved = true;
},
];
userData.achievements.work.achieved = true;
} }
data.userData.markModified("achievements.work");
userData.markModified("achievements"); await data.userData.save();
await userData.save();
} }
interaction.reply(messageOptions); interaction.reply(messageOptions);
} }
} }
module.exports = Work; module.exports = Work;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Eightball extends BaseCommand { class Eightball extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,51 +12,47 @@ class Eightball extends BaseCommand {
.setName("8ball") .setName("8ball")
.setDescription(client.translate("fun/8ball:DESCRIPTION")) .setDescription(client.translate("fun/8ball:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("fun/8ball:DESCRIPTION", null, "uk-UA"), "uk": client.translate("fun/8ball:DESCRIPTION", null, "uk-UA"),
ru: client.translate("fun/8ball:DESCRIPTION", null, "ru-RU"), "ru": client.translate("fun/8ball:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("question")
option .setDescription(client.translate("fun/8ball:QUESTION"))
.setName("question") .setDescriptionLocalizations({
.setDescription(client.translate("fun/8ball:QUESTION")) "uk": client.translate("fun/8ball:QUESTION", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("fun/8ball:QUESTION", null, "ru-RU"),
uk: client.translate("fun/8ball:QUESTION", null, "uk-UA"), })
ru: client.translate("fun/8ball:QUESTION", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
const question = interaction.options.getString("question"); const question = interaction.options.getString("question");
const embed = client.embed({ const answer = interaction.translate(`fun/8ball:RESPONSE_${client.functions.randomNum(1, 20)}`);
fields: [
{
name: interaction.translate("fun/8ball:QUESTION"),
value: question,
},
{
name: interaction.translate("fun/8ball:ANSWER"),
value: interaction.translate(`fun/8ball:RESPONSE_${client.functions.randomNum(1, 20)}`),
},
],
});
await client.wait(5000); await client.wait(5000);
interaction.editReply({ embeds: [embed] }); interaction.replyT("fun/8ball:ANSWER", {
question,
answer,
}, { edit: true });
} }
} }
module.exports = Eightball; module.exports = Eightball;

View file

@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class Cat extends BaseCommand { class Cat extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,32 +13,37 @@ class Cat extends BaseCommand {
.setName("cat") .setName("cat")
.setDescription(client.translate("fun/cat:DESCRIPTION")) .setDescription(client.translate("fun/cat:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("fun/cat:DESCRIPTION", null, "uk-UA"), "uk": client.translate("fun/cat:DESCRIPTION", null, "uk-UA"),
ru: client.translate("fun/cat:DESCRIPTION", null, "ru-RU"), "ru": client.translate("fun/cat:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true), .setDMPermission(true),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
const res = await fetch("https://api.thecatapi.com/v1/images/search").then(r => r.json()); const res = await fetch("https://and-here-is-my-code.glitch.me/img/cat").then(response => response.json());
const cat = res[0].url;
const embed = client.embed({ interaction.editReply({
image: cat, content: res.Link,
}); });
await interaction.editReply({ embeds: [embed] });
} }
} }
module.exports = Cat; module.exports = Cat;

49
commands/Fun/crab.js Normal file
View file

@ -0,0 +1,49 @@
const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"),
fetch = require("node-fetch");
class Crab extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("crab")
.setDescription(client.translate("fun/crab:DESCRIPTION"))
.setDescriptionLocalizations({
"uk": client.translate("fun/crab:DESCRIPTION", null, "uk-UA"),
"ru": client.translate("fun/crab:DESCRIPTION", null, "ru-RU"),
})
.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/crab").then(response => response.json());
interaction.editReply({
content: res.Link,
});
}
}
module.exports = Crab;

View file

@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class Dog extends BaseCommand { class Dog extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,32 +13,37 @@ class Dog extends BaseCommand {
.setName("dog") .setName("dog")
.setDescription(client.translate("fun/dog:DESCRIPTION")) .setDescription(client.translate("fun/dog:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("fun/dog:DESCRIPTION", null, "uk-UA"), "uk": client.translate("fun/dog:DESCRIPTION", null, "uk-UA"),
ru: client.translate("fun/dog:DESCRIPTION", null, "ru-RU"), "ru": client.translate("fun/dog:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true), .setDMPermission(true),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
const res = await fetch("https://dog.ceo/api/breeds/image/random").then(r => r.json()); const res = await fetch("https://and-here-is-my-code.glitch.me/img/dog").then(response => response.json());
const dog = res.message;
const embed = client.embed({ interaction.editReply({
image: dog, content: res.Link,
}); });
await interaction.editReply({ embeds: [embed] });
} }
} }
module.exports = Dog; module.exports = Dog;

View file

@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class LMGTFY extends BaseCommand { class LMGTFY extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,59 +13,54 @@ class LMGTFY extends BaseCommand {
.setName("lmgtfy") .setName("lmgtfy")
.setDescription(client.translate("fun/lmgtfy:DESCRIPTION")) .setDescription(client.translate("fun/lmgtfy:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("fun/lmgtfy:DESCRIPTION", null, "uk-UA"), "uk": client.translate("fun/lmgtfy:DESCRIPTION", null, "uk-UA"),
ru: client.translate("fun/lmgtfy:DESCRIPTION", null, "ru-RU"), "ru": client.translate("fun/lmgtfy:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("query")
option .setDescription(client.translate("fun/lmgtfy:QUERY"))
.setName("query") .setDescriptionLocalizations({
.setDescription(client.translate("fun/lmgtfy:QUERY")) "uk": client.translate("fun/lmgtfy:QUERY", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("fun/lmgtfy:QUERY", null, "ru-RU"),
uk: client.translate("fun/lmgtfy:QUERY", null, "uk-UA"), })
ru: client.translate("fun/lmgtfy:QUERY", null, "ru-RU"), .setRequired(true))
}) .addBooleanOption(option => option.setName("short")
.setRequired(true), .setDescription(client.translate("fun/lmgtfy:SHORT"))
) .setDescriptionLocalizations({
.addBooleanOption(option => "uk": client.translate("fun/lmgtfy:SHORT", null, "uk-UA"),
option "ru": client.translate("fun/lmgtfy:SHORT", null, "ru-RU"),
.setName("short") })
.setDescription(client.translate("fun/lmgtfy:SHORT")) .setRequired(true)),
.setDescriptionLocalizations({ aliases: [],
uk: client.translate("fun/lmgtfy:SHORT", null, "uk-UA"),
ru: client.translate("fun/lmgtfy:SHORT", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
const query = interaction.options.getString("query").replace(/[' '_]/g, "+"), const query = interaction.options.getString("query").replace(/[' '_]/g, "+"),
short = interaction.options.getBoolean("short"), short = interaction.options.getBoolean("short"),
url = `https://letmegooglethat.com/?q=${encodeURIComponent(query)}`; url = `https://letmegooglethat.com/?q=${query}`;
if (short) { if (short) {
const res = await fetch("https://plsgo.ru/rest/v3/short-urls", { const res = await fetch(`https://is.gd/create.php?format=simple&url=${encodeURIComponent(url)}`).then(res => res.text());
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"X-Api-Key": client.config.apiKeys.shlink,
},
body: new URLSearchParams({ longUrl: url }),
}).then(res => res.json());
interaction.editReply({ interaction.editReply({
content: `<${res.shortUrl}>`, content: `<${res}>`,
}); });
} else { } else {
interaction.editReply({ interaction.editReply({
@ -75,4 +70,4 @@ class LMGTFY extends BaseCommand {
} }
} }
module.exports = LMGTFY; module.exports = LMGTFY;

View file

@ -1,11 +1,11 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
md5 = require("md5"); md5 = require("md5");
class Lovecalc extends BaseCommand { class Lovecalc extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,38 +13,42 @@ class Lovecalc extends BaseCommand {
.setName("lovecalc") .setName("lovecalc")
.setDescription(client.translate("fun/lovecalc:DESCRIPTION")) .setDescription(client.translate("fun/lovecalc:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("fun/lovecalc:DESCRIPTION", null, "uk-UA"), "uk": client.translate("fun/lovecalc:DESCRIPTION", null, "uk-UA"),
ru: client.translate("fun/lovecalc:DESCRIPTION", null, "ru-RU"), "ru": client.translate("fun/lovecalc:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option =>
option option.setName("first_member")
.setName("first_member")
.setDescription(client.translate("common:USER")) .setDescription(client.translate("common:USER"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("common:USER", null, "uk-UA"), "uk": client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"), "ru": client.translate("common:USER", null, "ru-RU"),
}) })
.setRequired(true), .setRequired(true))
)
.addUserOption(option => .addUserOption(option =>
option option.setName("second_member")
.setName("second_member")
.setDescription(client.translate("common:USER")) .setDescription(client.translate("common:USER"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("common:USER", null, "uk-UA"), "uk": client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"), "ru": client.translate("common:USER", null, "ru-RU"),
}), })),
), aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const firstMember = interaction.options.getMember("first_member"), const firstMember = interaction.options.getMember("first_member"),
@ -59,16 +63,19 @@ class Lovecalc extends BaseCommand {
.join(""); .join("");
const percent = parseInt(string.slice(0, 2), 10); const percent = parseInt(string.slice(0, 2), 10);
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: `❤️ ${interaction.translate("fun/lovecalc:DESCRIPTION")}`, name: `❤️ ${interaction.translate("fun/lovecalc:DESCRIPTION")}`,
}, })
description: interaction.translate("fun/lovecalc:CONTENT", { .setDescription(interaction.translate("fun/lovecalc:CONTENT", {
percent, percent,
firstMember: firstMember.user.toString(), firstMember: firstMember.user.toString(),
secondMember: secondMember.user.toString(), secondMember: secondMember.user.toString(),
}), }))
}); .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
@ -76,4 +83,4 @@ class Lovecalc extends BaseCommand {
} }
} }
module.exports = Lovecalc; module.exports = Lovecalc;

View file

@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class Number extends BaseCommand { class Number extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,19 +13,27 @@ class Number extends BaseCommand {
.setName("number") .setName("number")
.setDescription(client.translate("fun/number:DESCRIPTION")) .setDescription(client.translate("fun/number:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("fun/number:DESCRIPTION", null, "uk-UA"), "uk": client.translate("fun/number:DESCRIPTION", null, "uk-UA"),
ru: client.translate("fun/number:DESCRIPTION", null, "ru-RU"), "ru": client.translate("fun/number:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction, data) { async execute(client, interaction, data) {
if (currentGames[interaction.guildId]) return interaction.error("fun/number:GAME_RUNNING"); if (currentGames[interaction.guildId]) return interaction.error("fun/number:GAME_RUNNING");
@ -40,7 +48,7 @@ class Number extends BaseCommand {
const filter = m => !m.author.bot; const filter = m => !m.author.bot;
const collector = new MessageCollector(interaction.channel, { const collector = new MessageCollector(interaction.channel, {
filter, filter,
time: 5 * 60 * 1000, time: (5 * 60 * 1000),
}); });
currentGames[interaction.guildId] = true; currentGames[interaction.guildId] = true;
@ -52,11 +60,12 @@ class Number extends BaseCommand {
const parsedNumber = parseInt(msg.content, 10); const parsedNumber = parseInt(msg.content, 10);
if (parsedNumber === number) { if (parsedNumber === number) {
const time = client.functions.convertTime(client, gameCreatedAt, false, false, data.guildData.language);
interaction.channel.send({ interaction.channel.send({
content: interaction.translate("fun/number:GAME_STATS", { content: interaction.translate("fun/number:GAME_STATS", {
winner: msg.author.toString(), winner: msg.author.toString(),
number, number,
time: `<t:${Math.floor(gameCreatedAt / 1000)}:R>`, time,
participantCount: participants.length, participantCount: participants.length,
participants: participants.map(p => `<@${p}>`).join(", "), participants: participants.map(p => `<@${p}>`).join(", "),
}), }),
@ -87,21 +96,17 @@ class Number extends BaseCommand {
}; };
data.memberData.transactions.push(info); data.memberData.transactions.push(info);
memberData.markModified("transactions");
await memberData.save(); await memberData.save();
} }
collector.stop(); collector.stop();
} }
if (parseInt(msg.content) < number) if (parseInt(msg.content) < number) msg.reply({
msg.reply({ content: interaction.translate("fun/number:TOO_BIG", { user: msg.author.toString(), number: parsedNumber }),
content: interaction.translate("fun/number:TOO_BIG", { user: msg.author.toString(), number: parsedNumber }), });
}); if (parseInt(msg.content) > number) msg.reply({
if (parseInt(msg.content) > number) content: interaction.translate("fun/number:TOO_SMALL", { user: msg.author.toString(), number: parsedNumber }),
msg.reply({ });
content: interaction.translate("fun/number:TOO_SMALL", { user: msg.author.toString(), number: parsedNumber }),
});
}); });
collector.on("end", (_, reason) => { collector.on("end", (_, reason) => {
@ -112,4 +117,4 @@ class Number extends BaseCommand {
} }
} }
module.exports = Number; module.exports = Number;

View file

@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class TicTacToe extends BaseCommand { class TicTacToe extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,29 +13,34 @@ class TicTacToe extends BaseCommand {
.setName("tictactoe") .setName("tictactoe")
.setDescription(client.translate("fun/tictactoe:DESCRIPTION")) .setDescription(client.translate("fun/tictactoe:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("fun/tictactoe:DESCRIPTION", null, "uk-UA"), "uk": client.translate("fun/tictactoe:DESCRIPTION", null, "uk-UA"),
ru: client.translate("fun/tictactoe:DESCRIPTION", null, "ru-RU"), "ru": client.translate("fun/tictactoe:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })
ru: client.translate("common:USER", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
tictactoe(interaction, { tictactoe(interaction, {
@ -49,6 +54,7 @@ class TicTacToe extends BaseCommand {
}); });
memberData.money += 100; memberData.money += 100;
await memberData.save();
const info = { const info = {
user: interaction.translate("economy/transactions:TTT"), user: interaction.translate("economy/transactions:TTT"),
@ -56,14 +62,9 @@ class TicTacToe extends BaseCommand {
date: Date.now(), date: Date.now(),
type: "got", type: "got",
}; };
memberData.transactions.push(info); memberData.transactions.push(info);
memberData.markModified("money");
memberData.markModified("transactions");
await memberData.save();
}); });
} }
} }
module.exports = TicTacToe; module.exports = TicTacToe;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Afk extends BaseCommand { class Afk extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,40 +12,42 @@ class Afk extends BaseCommand {
.setName("afk") .setName("afk")
.setDescription(client.translate("general/afk:DESCRIPTION")) .setDescription(client.translate("general/afk:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/afk:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/afk:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/afk:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/afk:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("message")
option .setDescription(client.translate("common:MESSAGE"))
.setName("message") .setDescriptionLocalizations({
.setDescription(client.translate("common:MESSAGE")) "uk": client.translate("common:MESSAGE", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:MESSAGE", null, "ru-RU"),
uk: client.translate("common:MESSAGE", null, "uk-UA"), })
ru: client.translate("common:MESSAGE", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
await interaction.deferReply({ ephemeral: true }); //...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
interaction.deferReply({ ephemeral: true });
const userData = interaction.data.user, const reason = interaction.options.getString("message");
reason = interaction.options.getString("message");
userData.afk = reason; data.userData.afk = reason;
await data.userData.save();
userData.markModified("afk");
await userData.save();
interaction.success("general/afk:SUCCESS", { interaction.success("general/afk:SUCCESS", {
reason, reason,
@ -53,4 +55,4 @@ class Afk extends BaseCommand {
} }
} }
module.exports = Afk; module.exports = Afk;

View file

@ -1,35 +0,0 @@
const { ContextMenuCommandBuilder, ApplicationCommandType } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class AvatarContext extends BaseCommand {
/**
*
* @param {import("../../base/Client")} client
*/
constructor() {
super({
command: new ContextMenuCommandBuilder()
.setName("Get Avatar")
.setType(ApplicationCommandType.User)
.setDMPermission(false),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").UserContextMenuCommandInteraction} interaction
*/
async execute(client, interaction) {
const avatarURL = interaction.targetUser.displayAvatarURL({ size: 2048 });
const embed = client.embed({ image: avatarURL });
interaction.reply({
embeds: [embed],
});
}
}
module.exports = AvatarContext;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Avatar extends BaseCommand { class Avatar extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,47 +12,50 @@ class Avatar extends BaseCommand {
.setName("avatar") .setName("avatar")
.setDescription(client.translate("general/avatar:DESCRIPTION")) .setDescription(client.translate("general/avatar:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/avatar:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/avatar:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/avatar:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/avatar:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), }))
ru: client.translate("common:USER", null, "ru-RU"), .addBooleanOption(option => option.setName("server")
}), .setDescription(client.translate("general/avatar:SERVER"))
) .setDescriptionLocalizations({
.addBooleanOption(option => "uk": client.translate("general/avatar:SERVER", null, "uk-UA"),
option "ru": client.translate("general/avatar:SERVER", null, "ru-RU"),
.setName("server") })),
.setDescription(client.translate("general/avatar:SERVER")) aliases: [],
.setDescriptionLocalizations({
uk: client.translate("general/avatar:SERVER", null, "uk-UA"),
ru: client.translate("general/avatar:SERVER", null, "ru-RU"),
}),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const member = interaction.options.getMember("user") || interaction.member; const member = interaction.options.getMember("user") || interaction.member;
const avatarURL = interaction.options.getBoolean("server") ? member.displayAvatarURL({ size: 2048 }) : member.user.displayAvatarURL({ size: 2048 }); const avatarURL = interaction.options.getBoolean("server") ? member.avatarURL({ size: 512 }) : member.user.avatarURL({ size: 512 });
const embed = client.embed({ image: avatarURL });
interaction.reply({ interaction.reply({
embeds: [embed], files: [{
attachment: avatarURL,
}],
}); });
} }
} }
module.exports = Avatar; module.exports = Avatar;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Boosters extends BaseCommand { class Boosters extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,41 +12,70 @@ class Boosters extends BaseCommand {
.setName("boosters") .setName("boosters")
.setDescription(client.translate("general/boosters:DESCRIPTION")) .setDescription(client.translate("general/boosters:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/boosters:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/boosters:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/boosters:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/boosters:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
async onLoad(client) { async onLoad() {
client.on("interactionCreate", async interaction => { //...
if (!interaction.isButton()) return; }
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
await interaction.deferReply();
if (interaction.customId.startsWith("boosters_")) { let currentPage = 0;
interaction.data = []; const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince);
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId); if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true });
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince), const embeds = generateBoostersEmbeds(client, interaction, boosters);
embeds = generateBoostersEmbeds(interaction, boosters);
const row = new ActionRowBuilder().addComponents( const row = new ActionRowBuilder()
new ButtonBuilder().setCustomId("boosters_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"), .addComponents(
new ButtonBuilder().setCustomId("boosters_next_page").setStyle(ButtonStyle.Primary).setEmoji("➡️"), new ButtonBuilder()
new ButtonBuilder().setCustomId("boosters_jump_page").setStyle(ButtonStyle.Secondary).setEmoji("↗️"), .setCustomId("boosters_prev_page")
new ButtonBuilder().setCustomId("boosters_stop").setStyle(ButtonStyle.Danger).setEmoji("❌"), .setStyle(ButtonStyle.Primary)
); .setEmoji("⬅️"),
new ButtonBuilder()
.setCustomId("boosters_next_page")
.setStyle(ButtonStyle.Primary)
.setEmoji("➡️"),
new ButtonBuilder()
.setCustomId("boosters_jump_page")
.setStyle(ButtonStyle.Secondary)
.setEmoji("↗️"),
new ButtonBuilder()
.setCustomId("boosters_stop")
.setStyle(ButtonStyle.Danger)
.setEmoji("⏹️"),
);
let currentPage = Number(interaction.message.content.match(/\d+/g)[0]) - 1 ?? 0; await interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[currentPage]],
components: [row],
});
if (interaction.customId === "boosters_prev_page") { const filter = i => i.user.id === interaction.user.id;
await interaction.deferUpdate(); const collector = interaction.guild === null ? (await interaction.user.createDM()).createMessageComponentCollector({ filter, idle: (20 * 1000) }) : interaction.channel.createMessageComponentCollector({ filter, idle: (20 * 1000) });
collector.on("collect", async i => {
if (i.isButton()) {
if (i.customId === "boosters_prev_page") {
i.deferUpdate();
if (currentPage !== 0) { if (currentPage !== 0) {
--currentPage; --currentPage;
@ -56,8 +85,8 @@ class Boosters extends BaseCommand {
components: [row], components: [row],
}); });
} }
} else if (interaction.customId === "boosters_next_page") { } else if (i.customId === "boosters_next_page") {
await interaction.deferUpdate(); i.deferUpdate();
if (currentPage < embeds.length - 1) { if (currentPage < embeds.length - 1) {
currentPage++; currentPage++;
@ -67,8 +96,8 @@ class Boosters extends BaseCommand {
components: [row], components: [row],
}); });
} }
} else if (interaction.customId === "boosters_jump_page") { } else if (i.customId === "boosters_jump_page") {
await interaction.deferUpdate(); i.deferUpdate();
const msg = await interaction.followUp({ const msg = await interaction.followUp({
content: interaction.translate("misc:JUMP_TO_PAGE", { content: interaction.translate("misc:JUMP_TO_PAGE", {
@ -81,7 +110,7 @@ class Boosters extends BaseCommand {
return res.author.id === interaction.user.id && !isNaN(res.content); return res.author.id === interaction.user.id && !isNaN(res.content);
}; };
interaction.channel.awaitMessages({ filter, max: 1, time: 10 * 1000 }).then(collected => { interaction.channel.awaitMessages({ filter, max: 1, time: (10 * 1000) }).then(collected => {
if (embeds[collected.first().content - 1]) { if (embeds[collected.first().content - 1]) {
currentPage = collected.first().content - 1; currentPage = collected.first().content - 1;
interaction.editReply({ interaction.editReply({
@ -98,78 +127,55 @@ class Boosters extends BaseCommand {
return; return;
} }
}); });
} else if (interaction.customId === "boosters_stop") { } else if (i.customId === "boosters_stop") {
await interaction.deferUpdate(); i.deferUpdate();
collector.stop();
row.components.forEach(component => {
component.setDisabled(true);
});
return interaction.editReply({
components: [row],
});
} }
} }
}); });
}
/** collector.on("end", () => {
* row.components.forEach(component => {
* @param {import("../../base/Client")} client component.setDisabled(true);
* @param {import("discord.js").ChatInputCommandInteraction} interaction });
*/
async execute(client, interaction) {
await interaction.deferReply();
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince); return interaction.editReply({
if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true }); components: [row],
});
const embeds = generateBoostersEmbeds(client, interaction, boosters);
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId("boosters_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"),
new ButtonBuilder().setCustomId("boosters_next_page").setStyle(ButtonStyle.Primary).setEmoji("➡️"),
new ButtonBuilder().setCustomId("boosters_jump_page").setStyle(ButtonStyle.Secondary).setEmoji("↗️"),
new ButtonBuilder().setCustomId("boosters_stop").setStyle(ButtonStyle.Danger).setEmoji("❌"),
);
await interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **1**/**${embeds.length}**`,
embeds: [embeds[0]],
components: [row],
}); });
} }
} }
/** /**
* *
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Array} boosters * @param {Array} boosters
* @returns * @returns
*/ */
function generateBoostersEmbeds(interaction, boosters) { function generateBoostersEmbeds(client, interaction, boosters) {
const embeds = []; const embeds = [];
let k = 10; let k = 10;
for (let i = 0; i < boosters.size; i += 10) { for (let i = 0; i < boosters.size; i += 10) {
const current = boosters const current = boosters.sort((a, b) => a.premiumSinceTimestamp - b.premiumSinceTimestamp).map(g => g).slice(i, k);
.sort((a, b) => a.premiumSinceTimestamp - b.premiumSinceTimestamp)
.map(g => g)
.slice(i, k);
let j = i; let j = i;
k += 10; k += 10;
const info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${Math.floor(new Date(member.premiumSince).getTime() / 1000)}**`).join("\n"); const info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${client.functions.printDate(client, member.premiumSince, null, interaction.guild.data.language)}**`).join("\n");
const embed = interaction.client.embed({
title: interaction.translate("general/boosters:BOOSTERS_LIST"),
description: info,
});
const embed = new EmbedBuilder()
.setColor(interaction.client.config.embed.color)
.setFooter({
text: interaction.client.config.embed.footer,
})
.setTitle(interaction.translate("general/boosters:BOOSTERS_LIST"))
.setDescription(info)
.setTimestamp();
embeds.push(embed); embeds.push(embed);
} }
return embeds; return embeds;
} }
module.exports = Boosters; module.exports = Boosters;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, parseEmoji } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Emoji extends BaseCommand { class Emoji extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,41 +12,50 @@ class Emoji extends BaseCommand {
.setName("emoji") .setName("emoji")
.setDescription(client.translate("general/emoji:DESCRIPTION")) .setDescription(client.translate("general/emoji:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/emoji:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/emoji:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/emoji:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/emoji:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("emoji")
option .setDescription(client.translate("common:EMOJI"))
.setName("emoji") .setDescriptionLocalizations({
.setDescription(client.translate("common:EMOJI")) "uk": client.translate("commom:EMOJI", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:EMOJI", null, "ru-RU"),
uk: client.translate("commom:EMOJI", null, "uk-UA"), })
ru: client.translate("common:EMOJI", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const rawEmoji = interaction.options.getString("emoji"); const rawEmoji = interaction.options.getString("emoji");
const parsedEmoji = parseEmoji(rawEmoji); const parsedEmoji = parseEmoji(rawEmoji);
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("general/emoji:TITLE", { name: interaction.translate("general/emoji:TITLE", {
emoji: parsedEmoji.name, emoji: parsedEmoji.name,
}), }),
}, })
fields: [ .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
})
.addFields([
{ {
name: interaction.translate("common:NAME"), name: interaction.translate("common:NAME"),
value: parsedEmoji.name, value: parsedEmoji.name,
@ -63,8 +72,7 @@ class Emoji extends BaseCommand {
name: interaction.translate("general/emoji:LINK"), name: interaction.translate("general/emoji:LINK"),
value: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${parsedEmoji.animated ? "gif" : "png"}`, value: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${parsedEmoji.animated ? "gif" : "png"}`,
}, },
], ]);
});
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
@ -72,4 +80,4 @@ class Emoji extends BaseCommand {
} }
} }
module.exports = Emoji; module.exports = Emoji;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Help extends BaseCommand { class Help extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,70 +12,33 @@ class Help extends BaseCommand {
.setName("help") .setName("help")
.setDescription(client.translate("general/help:DESCRIPTION")) .setDescription(client.translate("general/help:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/help:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/help:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/help:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/help:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option =>
option option.setName("command")
.setName("command")
.setDescription(client.translate("common:COMMAND")) .setDescription(client.translate("common:COMMAND"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("common:COMMAND", null, "uk-UA"), "uk": client.translate("common:COMMAND", null, "uk-UA"),
ru: client.translate("common:COMMAND", null, "ru-RU"), "ru": client.translate("common:COMMAND", null, "ru-RU"),
}) })
.setAutocomplete(true), .setAutocomplete(true)),
), aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
async onLoad(client) { async onLoad() {
client.on("interactionCreate", async interaction => { //...
if (!interaction.isStringSelectMenu()) return;
if (interaction.customId === "help_category_select") {
await interaction.deferUpdate();
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const arg = interaction?.values[0];
const categoryCommands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()]
.filter(cmd => cmd.category === arg)
.map(c => {
return {
name: `**${c.command.name}**`,
value: interaction.translate(`${arg.toLowerCase()}/${c.command.name}:DESCRIPTION`),
};
});
const embed = client.embed({
author: {
name: interaction.translate("general/help:COMMANDS_IN", { category: arg }),
},
fields: categoryCommands.concat({
name: "\u200B",
value: interaction.translate("general/help:INFO"),
}),
});
return interaction.editReply({
content: null,
embeds: [embed],
});
}
});
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data * @param {Object} data
*/ */
@ -83,15 +46,25 @@ class Help extends BaseCommand {
await interaction.deferReply(); await interaction.deferReply();
const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()]; const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()];
const categories = [... new Set(commands.map(c => c.category))]; const categories = [];
const command = interaction.options.getString("command"); const command = interaction.options.getString("command");
if (command) { if (command) {
if (commands.find(c => c.command.name === command).category === "Owner" && interaction.user.id !== client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { edit: true }); if (commands.find(c => c.command.name === command).category === "Owner" && interaction.user.id !== client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { edit: true, ephemeral: true });
else if (commands.find(c => c.command.name === command).category === "IAT" && interaction.guildId !== "1039187019957555252") return interaction.error("misc:OWNER_ONLY", null, { edit: true });
else return interaction.editReply({ embeds: [generateCommandHelp(interaction, command)] }); return interaction.editReply({ embeds: [ generateCommandHelp(interaction, command) ] });
} }
commands.forEach(c => {
if (!categories.includes(c.category)) {
if (c.category === "Owner" && interaction.user.id !== client.config.owner.id) return;
if (c.category === "IAT" && interaction.guildId !== "1039187019957555252") return;
if (c.category === "SunCountry" && interaction.guildId !== "600970971410857996") return;
categories.push(c.category);
}
});
const categoriesRows = categories.sort().map(c => { const categoriesRows = categories.sort().map(c => {
return { return {
label: `${c} (${commands.filter(cmd => cmd.category === c).length})`, label: `${c} (${commands.filter(cmd => cmd.category === c).length})`,
@ -99,17 +72,68 @@ class Help extends BaseCommand {
}; };
}); });
const row = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder().setCustomId("help_category_select").setPlaceholder(interaction.translate("common:NOTHING_SELECTED")).addOptions(categoriesRows)); const row = new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId("help_category_select")
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
.addOptions(categoriesRows),
);
await interaction.editReply({ const msg = await interaction.editReply({
content: interaction.translate("common:AVAILABLE_OPTIONS"),
fetchReply: true, fetchReply: true,
components: [row], components: [row],
}); });
const filter = i => i.user.id === interaction.user.id;
const collector = msg.createMessageComponentCollector({ filter, idle: (15 * 1000) });
collector.on("collect", async i => {
if (i.isStringSelectMenu() && 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`),
};
});
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 interaction.editReply({
content: null,
embeds: [embed],
});
}
});
collector.on("end", () => {
return interaction.editReply({
components: [],
});
});
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").AutocompleteInteraction} interaction * @param {import("discord.js").AutocompleteInteraction} interaction
* @returns * @returns
*/ */
@ -118,17 +142,18 @@ class Help extends BaseCommand {
commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()], commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()],
results = commands.filter(c => c.command.name.includes(command)); results = commands.filter(c => c.command.name.includes(command));
return await interaction.respond( return interaction.respond(
results.slice(0, 25).map(command => ({ results.slice(0, 25).map(command => ({
name: command.command.name, name: command.command.name,
value: command.command.name, value: command.command.name,
})), }),
); ));
} }
} }
function getPermName(bitfield = 0) { function getPermName(bitfield = 0) {
for (const key in PermissionsBitField.Flags) if (PermissionsBitField.Flags[key] === BigInt(bitfield)) return key; for (const key in PermissionsBitField.Flags)
if (PermissionsBitField.Flags[key] === BigInt(bitfield)) return key;
return null; return null;
} }
@ -136,38 +161,44 @@ function generateCommandHelp(interaction, command) {
const cmd = interaction.client.commands.get(command); const cmd = interaction.client.commands.get(command);
if (!cmd) return interaction.error("general/help:NOT_FOUND", { command }, { edit: true }); if (!cmd) return interaction.error("general/help:NOT_FOUND", { command }, { edit: true });
if (cmd.category === "Owner" && interaction.user.id !== interaction.client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { edit: true }); const usage = interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:USAGE`) === "" ?
else if (cmd.category === "IAT" && interaction.guildId !== "1039187019957555252") return interaction.error("misc:OWNER_ONLY", null, { edit: true }); interaction.translate("misc:NO_ARGS")
: interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:USAGE`);
const embed = interaction.client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("general/help:CMD_TITLE", { name: interaction.translate("general/help:CMD_TITLE", {
cmd: cmd.command.name, cmd: cmd.command.name,
}), }),
}, })
fields: [ .addFields([
{ {
name: interaction.translate("general/help:FIELD_DESCRIPTION"), name: interaction.translate("general/help:FIELD_DESCRIPTION"),
value: interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:DESCRIPTION`), value: interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:DESCRIPTION`),
}, },
{ {
name: interaction.translate("general/help:FIELD_USAGE"), name: interaction.translate("general/help:FIELD_USAGE"),
value: `*${cmd.command.dm_permission === false ? interaction.translate("general/help:GUILD_ONLY") : interaction.translate("general/help:NOT_GUILD_ONLY")}*\n\n${ value: `*${cmd.command.dm_permission === false ? interaction.translate("general/help:GUILD_ONLY") : interaction.translate("general/help:NOT_GUILD_ONLY")}*\n\n` + usage,
interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:USAGE`) === "" ? interaction.translate("misc:NO_ARGS") : interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:USAGE`)
}`,
}, },
{ {
name: interaction.translate("general/help:FIELD_EXAMPLES"), name: interaction.translate("general/help:FIELD_EXAMPLES"),
value: interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:EXAMPLES`), value: interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:EXAMPLES`),
}, },
// {
// name: interaction.translate("general/help:FIELD_ALIASES"),
// value: cmd.aliases.length > 0 ? cmd.aliases.map(a => `${a}`).join("\n") : interaction.translate("general/help:NO_ALIAS")
// },
{ {
name: interaction.translate("general/help:FIELD_PERMISSIONS"), name: interaction.translate("general/help:FIELD_PERMISSIONS"),
value: cmd.command.default_member_permissions > 0 ? interaction.translate(`misc:PERMISSIONS:${getPermName(cmd.command.default_member_permissions)}`) : interaction.translate("general/help:NO_REQUIRED_PERMISSION"), value: cmd.command.default_member_permissions > 0 ? interaction.translate(`misc:PERMISSIONS:${getPermName(cmd.command.default_member_permissions)}`) : interaction.translate("general/help:NO_REQUIRED_PERMISSION"),
}, },
], ])
}); .setColor(interaction.client.config.embed.color)
.setFooter({
text: interaction.client.config.embed.footer,
});
return embed; return embed;
} }
module.exports = Help; module.exports = Help;

View file

@ -1,11 +1,11 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
gamedig = require("gamedig"); gamedig = require("gamedig");
class Minecraft extends BaseCommand { class Minecraft extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,29 +13,34 @@ class Minecraft extends BaseCommand {
.setName("minecraft") .setName("minecraft")
.setDescription(client.translate("general/minecraft:DESCRIPTION")) .setDescription(client.translate("general/minecraft:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/minecraft:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/minecraft:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/minecraft:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/minecraft:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("ip")
option .setDescription(client.translate("common:IP"))
.setName("ip") .setDescriptionLocalizations({
.setDescription(client.translate("common:IP")) "uk": client.translate("common:IP", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:IP", null, "ru-RU"),
uk: client.translate("common:IP", null, "uk-UA"), })
ru: client.translate("common:IP", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
@ -61,27 +66,18 @@ class Minecraft extends BaseCommand {
if (!res) return interaction.error("general/minecraft:FAILED", null, { edit: true }); if (!res) return interaction.error("general/minecraft:FAILED", null, { edit: true });
const embed = client.embed({ const embed = new EmbedBuilder()
author: { name: res.name || "Unknown" }, .setAuthor({
thumbnail: `https://eu.mc-api.net/v3/server/favicon/${ip}`, name: res.name,
fields: [ })
.addFields([
{ {
name: interaction.translate("general/minecraft:FIELD_STATUS"), name: interaction.translate("general/minecraft:FIELD_STATUS"),
value: interaction.translate("general/minecraft:ONLINE"), value: interaction.translate("general/minecraft:ONLINE"),
}, },
{ {
name: interaction.translate("general/minecraft:FIELD_CONNECTED"), name: interaction.translate("general/minecraft:FIELD_CONNECTED"),
value: `**${res.raw.players ? res.raw.players.online : res.players.length}** ${client.functions.getNoun( value: `**${(res.raw.players ? res.raw.players.online : res.players.length)}** ${client.functions.getNoun((res.raw.players ? res.raw.players.online : res.players.length), interaction.translate("misc:NOUNS:PLAYERS:1"), interaction.translate("misc:NOUNS:PLAYERS:2"), interaction.translate("misc:NOUNS:PLAYERS:5"))} / **${(res.raw.players ? res.raw.players.max : res.maxplayers)}** ${client.functions.getNoun((res.raw.players ? res.raw.players.max : res.maxplayers), interaction.translate("misc:NOUNS:PLAYERS:1"), interaction.translate("misc:NOUNS:PLAYERS:2"), interaction.translate("misc:NOUNS:PLAYERS:5"))}`,
res.raw.players ? res.raw.players.online : res.players.length,
interaction.translate("misc:NOUNS:PLAYERS:1"),
interaction.translate("misc:NOUNS:PLAYERS:2"),
interaction.translate("misc:NOUNS:PLAYERS:5"),
)} / **${res.raw.players ? res.raw.players.max : res.maxplayers}** ${client.functions.getNoun(
res.raw.players ? res.raw.players.max : res.maxplayers,
interaction.translate("misc:NOUNS:PLAYERS:1"),
interaction.translate("misc:NOUNS:PLAYERS:2"),
interaction.translate("misc:NOUNS:PLAYERS:5"),
)}`,
}, },
{ {
name: interaction.translate("general/minecraft:FIELD_IP"), name: interaction.translate("general/minecraft:FIELD_IP"),
@ -92,13 +88,18 @@ class Minecraft extends BaseCommand {
name: interaction.translate("general/minecraft:FIELD_VERSION"), name: interaction.translate("general/minecraft:FIELD_VERSION"),
value: res.raw.vanilla.raw.version.name, value: res.raw.vanilla.raw.version.name,
inline: true, inline: true,
}, },
{ {
name: interaction.translate("general/minecraft:FIELD_PING"), name: interaction.translate("general/minecraft:FIELD_PING"),
value: res.raw.vanilla.ping.toString(), value: res.raw.vanilla.ping.toString(),
}, },
], ])
}); .setColor(client.config.embed.color)
.setThumbnail(`https://eu.mc-api.net/v3/server/favicon/${ip}`)
.setFooter({
text: client.config.embed.footer,
});
interaction.editReply({ interaction.editReply({
embeds: [embed], embeds: [embed],
@ -106,4 +107,4 @@ class Minecraft extends BaseCommand {
} }
} }
module.exports = Minecraft; module.exports = Minecraft;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Ping extends BaseCommand { class Ping extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,29 +12,41 @@ class Ping extends BaseCommand {
.setName("ping") .setName("ping")
.setDescription(client.translate("general/ping:DESCRIPTION")) .setDescription(client.translate("general/ping:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/ping:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/ping:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/ping:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/ping:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true), .setDMPermission(true),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
})
.setAuthor({
name: interaction.translate("general/ping:PONG"), name: interaction.translate("general/ping:PONG"),
}, iconURL: client.user.avatarURL(),
description: interaction.translate("general/ping:PING", { })
.setDescription(interaction.translate("general/ping:PING", {
ping: Math.round(client.ws.ping), ping: Math.round(client.ws.ping),
}), }));
});
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
@ -42,4 +54,4 @@ class Ping extends BaseCommand {
} }
} }
module.exports = Ping; module.exports = Ping;

View file

@ -1,11 +1,12 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
ms = require("ms"); ms = require("ms"),
moment = require("moment");
class Remindme extends BaseCommand { class Remindme extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,80 +14,66 @@ class Remindme extends BaseCommand {
.setName("remindme") .setName("remindme")
.setDescription(client.translate("general/remindme:DESCRIPTION")) .setDescription(client.translate("general/remindme:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/remindme:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/remindme:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/remindme:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/remindme:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("time")
option .setDescription(client.translate("general/remindme:TIME"))
.setName("time") .setDescriptionLocalizations({
.setDescription(client.translate("general/remindme:TIME")) "uk": client.translate("general/remindme:TIME", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("general/remindme:TIME", null, "ru-RU"),
uk: client.translate("general/remindme:TIME", null, "uk-UA"), })
ru: client.translate("general/remindme:TIME", null, "ru-RU"), .setRequired(true))
}) .addStringOption(option => option.setName("message")
.setRequired(true), .setDescription(client.translate("common:MESSAGE"))
) .setDescriptionLocalizations({
.addStringOption(option => "uk": client.translate("common:MESSAGE", null, "uk-UA"),
option "ru": client.translate("common:MESSAGE", null, "ru-RU"),
.setName("message") })
.setDescription(client.translate("common:MESSAGE")) .setRequired(true)),
.setDescriptionLocalizations({ aliases: [],
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
const userData = interaction.data.user; const time = interaction.options.getString("time");
const message = interaction.options.getString("message");
if (!userData.reminds) userData.reminds = [];
const dateNow = Date.now(); const dateNow = Date.now();
if (!data.userData.reminds) data.userData.reminds = [];
const reminder = { const rData = {
message: interaction.options.getString("message"), message: message,
createdAt: Math.floor(dateNow / 1000), createdAt: dateNow,
sendAt: Math.floor((dateNow + ms(interaction.options.getString("time"))) / 1000), sendAt: dateNow + ms(time),
}; };
userData.reminds.push(reminder); data.userData.reminds.push(rData);
data.userData.markModified("reminds");
data.userData.save();
client.databaseCache.usersReminds.set(interaction.member.id, data.userData);
userData.markModified("reminds"); interaction.success("general/remindme:SAVED", {
await userData.save(); message,
time: moment(rData.sendAt).locale(interaction.guild.data.language).format("dddd, Do MMMM YYYY, HH:mm:ss"),
client.databaseCache.usersReminds.set(interaction.user.id, userData); }, { edit: true });
const embed = client.embed({
author: interaction.translate("general/remindme:EMBED_SAVED"),
fields: [
{
name: interaction.translate("general/remindme:EMBED_TIME"),
value: `<t:${reminder.sendAt}:R>`,
},
{
name: interaction.translate("common:MESSAGE"),
value: reminder.message,
},
],
});
interaction.editReply({
embeds: [embed],
});
} }
} }
module.exports = Remindme; module.exports = Remindme;

View file

@ -1,176 +0,0 @@
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Reminds extends BaseCommand {
/**
*
* @param {import("../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("reminds")
.setDescription(client.translate("general/reminds:DESCRIPTION"))
.setDescriptionLocalizations({
uk: client.translate("general/reminds:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/reminds:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/Client")} client
*/
async onLoad(client) {
client.on("interactionCreate", async interaction => {
if (!interaction.isButton()) return;
if (interaction.customId.startsWith("reminds_")) {
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
interaction.data.user = await client.findOrCreateUser(interaction.user.id);
const reminds = interaction.data.user.reminds,
embeds = generateRemindsEmbeds(interaction, reminds);
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId("reminds_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"),
new ButtonBuilder().setCustomId("reminds_next_page").setStyle(ButtonStyle.Primary).setEmoji("➡️"),
new ButtonBuilder().setCustomId("reminds_jump_page").setStyle(ButtonStyle.Secondary).setEmoji("↗️"),
new ButtonBuilder().setCustomId("reminds_stop").setStyle(ButtonStyle.Danger).setEmoji("❌"),
);
let currentPage = Number(interaction.message.content.match(/\d+/g)[0]) - 1 ?? 0;
if (interaction.customId === "reminds_prev_page") {
await interaction.deferUpdate();
if (currentPage !== 0) {
--currentPage;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[currentPage]],
components: [row],
});
}
} else if (interaction.customId === "reminds_next_page") {
await interaction.deferUpdate();
if (currentPage < embeds.length - 1) {
currentPage++;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[currentPage]],
components: [row],
});
}
} else if (interaction.customId === "reminds_jump_page") {
await interaction.deferUpdate();
const msg = await interaction.followUp({
content: interaction.translate("misc:JUMP_TO_PAGE", {
length: embeds.length,
}),
fetchReply: true,
});
const filter = res => {
return res.author.id === interaction.user.id && !isNaN(res.content);
};
interaction.channel.awaitMessages({ filter, max: 1, time: 10 * 1000 }).then(collected => {
if (embeds[collected.first().content - 1]) {
currentPage = collected.first().content - 1;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[currentPage]],
components: [row],
});
if (collected.first().deletable) collected.first().delete();
if (msg.deletable) msg.delete();
} else {
if (collected.first().deletable) collected.first().delete();
if (msg.deletable) msg.delete();
return;
}
});
} else if (interaction.customId === "reminds_stop") {
await interaction.deferUpdate();
row.components.forEach(component => {
component.setDisabled(true);
});
return interaction.editReply({
components: [row],
});
}
}
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
await interaction.deferReply();
const reminds = interaction.data.user.reminds;
if (reminds.length === 0) return interaction.error("general/reminds:NO_REMINDS", null, { edit: true });
const embeds = generateRemindsEmbeds(interaction, reminds);
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId("reminds_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"),
new ButtonBuilder().setCustomId("reminds_next_page").setStyle(ButtonStyle.Primary).setEmoji("➡️"),
new ButtonBuilder().setCustomId("reminds_jump_page").setStyle(ButtonStyle.Secondary).setEmoji("↗️"),
new ButtonBuilder().setCustomId("reminds_stop").setStyle(ButtonStyle.Danger).setEmoji("❌"),
);
await interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **1**/**${embeds.length}**`,
embeds: [embeds[0]],
components: [row],
});
}
}
/**
*
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Array} reminds
* @returns
*/
function generateRemindsEmbeds(interaction, reminds) {
const embeds = [];
let k = 5;
for (let i = 0; i < reminds.length; i += 5) {
const current = reminds
.sort((a, b) => a.createdAt - b.createdAt)
.map(g => g)
.slice(i, k);
let j = i;
k += 5;
const info = current.map(r => `${++j}. ${interaction.client.translate("general/remindme:EMBED_CREATED")}: <t:${r.createdAt}:f>\n${interaction.client.translate("general/remindme:EMBED_TIME")}: <t:${r.sendAt}:f>\n${interaction.client.translate("common:MESSAGE")}: \`${r.message}\``).join("\n");
const embed = interaction.client.embed({
title: interaction.translate("general/reminds:REMINDS_LIST"),
description: info,
});
embeds.push(embed);
}
return embeds;
}
module.exports = Reminds;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, parseEmoji } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Report extends BaseCommand { class Report extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,61 +12,63 @@ class Report extends BaseCommand {
.setName("report") .setName("report")
.setDescription(client.translate("general/report:DESCRIPTION")) .setDescription(client.translate("general/report:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/report:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/report:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/report:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/report:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })
ru: client.translate("common:USER", null, "ru-RU"), .setRequired(true))
}) .addStringOption(option => option.setName("message")
.setRequired(true), .setDescription(client.translate("common:MESSAGE"))
) .setDescriptionLocalizations({
.addStringOption(option => "uk": client.translate("common:MESSAGE", null, "uk-UA"),
option "ru": client.translate("common:MESSAGE", null, "ru-RU"),
.setName("message") })
.setDescription(client.translate("common:MESSAGE")) .setRequired(true)),
.setDescriptionLocalizations({ aliases: [],
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const guildData = interaction.data.guild, const repChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.reports);
repChannel = interaction.guild.channels.cache.get(guildData.plugins.reports);
if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL"); if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL");
const member = interaction.options.getMember("user"); const member = interaction.options.getMember("user");
if (member.id === interaction.user.id) return interaction.error("general/report:INVALID_USER"); if (member.id === interaction.user.id) return interaction.error("general/report:INVALID_USER");
const rep = interaction.options.getString("message"); const rep = interaction.options.getString("message");
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("general/report:TITLE", { name: interaction.translate("general/report:TITLE", {
user: member.user.getUsername(), user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
}), }),
iconURL: interaction.user.displayAvatarURL(), iconURL: interaction.user.displayAvatarURL({
}, extension: "png",
fields: [ size: 512,
}),
})
.addFields([
{ {
name: interaction.translate("common:DATE"), name: interaction.translate("common:DATE"),
value: `<t:${Math.floor(Date.now() / 1000)}:D>`, value: client.functions.printDate(client, new Date(Date.now())),
}, },
{ {
name: interaction.translate("common:AUTHOR"), name: interaction.translate("common:AUTHOR"),
@ -83,8 +85,11 @@ class Report extends BaseCommand {
value: rep, value: rep,
inline: true, inline: true,
}, },
], ])
}); .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
const success = parseEmoji(client.customEmojis.cool).id; const success = parseEmoji(client.customEmojis.cool).id;
const error = parseEmoji(client.customEmojis.notcool).id; const error = parseEmoji(client.customEmojis.notcool).id;
@ -102,4 +107,4 @@ class Report extends BaseCommand {
} }
} }
module.exports = Report; module.exports = Report;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, ChannelType } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, ChannelType } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Serverinfo extends BaseCommand { class Serverinfo extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,30 +12,45 @@ class Serverinfo extends BaseCommand {
.setName("serverinfo") .setName("serverinfo")
.setDescription(client.translate("general/serverinfo:DESCRIPTION")) .setDescription(client.translate("general/serverinfo:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/serverinfo:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/serverinfo:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/serverinfo:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/serverinfo:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const { guild } = interaction; const guild = interaction.guild;
await guild.members.fetch(); await guild.members.fetch();
const owner = await guild.fetchOwner(); const owner = await guild.fetchOwner();
const embed = client.embed({ const embed = new EmbedBuilder()
author: guild.name, .setAuthor({
thumbnail: guild.iconURL(), name: guild.name,
fields: [ iconURL: guild.iconURL(),
})
.setThumbnail(guild.iconURL())
.addFields([
{
name: client.customEmojis.link + " " + interaction.translate("general/serverinfo:LINK"),
value: `[${interaction.translate("general/serverinfo:LINK_TEXT")}](${client.config.dashboard.baseURL}/stats/${guild.id})`,
},
{ {
name: client.customEmojis.title + interaction.translate("common:NAME"), name: client.customEmojis.title + interaction.translate("common:NAME"),
value: guild.name, value: guild.name,
@ -43,25 +58,13 @@ class Serverinfo extends BaseCommand {
}, },
{ {
name: client.customEmojis.calendar + interaction.translate("common:CREATION"), name: client.customEmojis.calendar + interaction.translate("common:CREATION"),
value: `<t:${guild.createdTimestamp}:D>`, value: client.functions.printDate(client, guild.createdAt),
inline: true, inline: true,
}, },
{ {
name: client.customEmojis.users + interaction.translate("common:MEMBERS"), name: client.customEmojis.users + interaction.translate("common:MEMBERS"),
value: value: `${guild.members.cache.filter(m => !m.user.bot).size} ${client.functions.getNoun(guild.members.cache.filter(m => !m.user.bot).size, interaction.translate("misc:NOUNS:MEMBERS:1"), interaction.translate("misc:NOUNS:MEMBERS:2"), interaction.translate("misc:NOUNS:MEMBERS:5"))}` +
`${guild.members.cache.filter(m => !m.user.bot).size} ${client.functions.getNoun( "\n" + `${guild.members.cache.filter(m => m.user.bot).size} ${client.functions.getNoun(guild.members.cache.filter(m => m.user.bot).size, interaction.translate("misc:NOUNS:BOTS:1"), interaction.translate("misc:NOUNS:BOTS:2"), interaction.translate("misc:NOUNS:BOTS:5"))}`,
guild.members.cache.filter(m => !m.user.bot).size,
interaction.translate("misc:NOUNS:MEMBERS:1"),
interaction.translate("misc:NOUNS:MEMBERS:2"),
interaction.translate("misc:NOUNS:MEMBERS:5"),
)}` +
"\n" +
`${guild.members.cache.filter(m => m.user.bot).size} ${client.functions.getNoun(
guild.members.cache.filter(m => m.user.bot).size,
interaction.translate("misc:NOUNS:BOTS:1"),
interaction.translate("misc:NOUNS:BOTS:2"),
interaction.translate("misc:NOUNS:BOTS:5"),
)}`,
inline: true, inline: true,
}, },
{ {
@ -86,31 +89,17 @@ class Serverinfo extends BaseCommand {
}, },
{ {
name: client.customEmojis.channels + interaction.translate("common:CHANNELS"), name: client.customEmojis.channels + interaction.translate("common:CHANNELS"),
value: value: `${guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size} ${client.functions.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"))}` +
`${guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size} ${client.functions.getNoun( "\n" + `${guild.channels.cache.filter(c => c.type === ChannelType.GuildVoice).size} ${client.functions.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"))}` +
guild.channels.cache.filter(c => c.type === ChannelType.GuildText).size, "\n" + `${guild.channels.cache.filter(c => c.type === ChannelType.GuildCategory).size} ${client.functions.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"))}`,
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.functions.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.functions.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, inline: true,
}, },
], ])
});
.setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
@ -118,4 +107,4 @@ class Serverinfo extends BaseCommand {
} }
} }
module.exports = Serverinfo; module.exports = Serverinfo;

View file

@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class Shorturl extends BaseCommand { class Shorturl extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,47 +13,44 @@ class Shorturl extends BaseCommand {
.setName("shorturl") .setName("shorturl")
.setDescription(client.translate("general/shorturl:DESCRIPTION")) .setDescription(client.translate("general/shorturl:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/shorturl:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/shorturl:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/shorturl:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/shorturl:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("url")
option .setDescription(client.translate("common:URL"))
.setName("url") .setDescriptionLocalizations({
.setDescription(client.translate("common:URL")) "uk": client.translate("common:URL", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:URL", null, "ru-RU"),
uk: client.translate("common:URL", null, "uk-UA"), })
ru: client.translate("common:URL", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true });
const url = interaction.options.getString("url"); const url = interaction.options.getString("url");
const res = await fetch("https://plsgo.ru/rest/v3/short-urls", { const res = await fetch(`https://is.gd/create.php?format=simple&url=${encodeURIComponent(url)}`).then(res => res.text());
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"X-Api-Key": client.config.apiKeys.shlink,
},
body: new URLSearchParams({ longUrl: url }),
}).then(res => res.json());
interaction.editReply({ interaction.reply({
content: `<${res.shortUrl}>`, content: `<${res}>`,
ephemeral: true,
}); });
} }
} }
module.exports = Shorturl; module.exports = Shorturl;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField, version: djsVersion } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField, version } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Stats extends BaseCommand { class Stats extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,21 +12,29 @@ class Stats extends BaseCommand {
.setName("stats") .setName("stats")
.setDescription(client.translate("general/stats:DESCRIPTION")) .setDescription(client.translate("general/stats:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/stats:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/stats:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/stats:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/stats:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true), .setDMPermission(true),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount; const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;
const servers = client.guilds.cache.size - 1; const servers = client.guilds.cache.size - 1;
let users = 0; let users = 0;
@ -35,10 +43,16 @@ class Stats extends BaseCommand {
}); });
users = users - hiddenGuildMembersCount; users = users - hiddenGuildMembersCount;
const embed = client.embed({ const statsEmbed = new EmbedBuilder()
author: interaction.translate("common:STATS"), .setColor(client.config.embed.color)
descirption: interaction.translate("general/stats:MADE"), .setFooter({
fields: [ text: client.config.embed.footer,
})
.setAuthor({
name: interaction.translate("common:STATS"),
})
.setDescription(interaction.translate("general/stats:MADE"))
.addFields([
{ {
name: client.customEmojis.stats + " " + interaction.translate("general/stats:COUNTS_TITLE"), name: client.customEmojis.stats + " " + interaction.translate("general/stats:COUNTS_TITLE"),
value: interaction.translate("general/stats:COUNTS_CONTENT", { value: interaction.translate("general/stats:COUNTS_CONTENT", {
@ -49,29 +63,24 @@ class Stats extends BaseCommand {
}, },
{ {
name: client.customEmojis.version + " " + interaction.translate("general/stats:VERSIONS_TITLE"), name: client.customEmojis.version + " " + interaction.translate("general/stats:VERSIONS_TITLE"),
value: `\`Discord.js: v${djsVersion}\`\n\`Nodejs: v${process.versions.node}\``, value: `\`Discord.js: v${version}\`\n\`Nodejs: v${process.versions.node}\``,
inline: true, inline: true,
}, },
{ {
name: client.customEmojis.ram + " " + interaction.translate("general/stats:RAM_TITLE"), name: client.customEmojis.ram + " " + interaction.translate("general/stats:RAM_TITLE"),
value: `\`${Math.floor(process.memoryUsage().heapUsed / 1024 / 1024)}MB\``, value: `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}MB\``,
inline: true, inline: true,
}, },
{ {
name: client.customEmojis.status.online + " " + interaction.translate("general/stats:ONLINE_TITLE"), name: client.customEmojis.status.online + " " + interaction.translate("general/stats:ONLINE_TITLE"),
value: interaction.translate("general/stats:ONLINE_CONTENT", { value: interaction.translate("general/stats:ONLINE_CONTENT", {
time: `<t:${Math.floor((Date.now() - client.uptime) / 1000)}:R>`, time: client.functions.convertTime(client, Date.now() + client.uptime, true, true, data.guildData.language),
}), }),
}, },
{ {
name: client.customEmojis.voice + " " + interaction.translate("general/stats:MUSIC_TITLE"), name: client.customEmojis.voice + " " + interaction.translate("general/stats:MUSIC_TITLE"),
value: interaction.translate("general/stats:MUSIC_CONTENT", { value: interaction.translate("general/stats:MUSIC_CONTENT", {
count: `${client.player.nodes.cache.size} ${client.functions.getNoun( count: `${client.player.nodes.cache.size} ${client.functions.getNoun(client.player.nodes.cache.size, interaction.translate("misc:NOUNS:SERVERS:1"), interaction.translate("misc:NOUNS:SERVERS:2"), interaction.translate("misc:NOUNS:SERVERS:5"))}`,
client.player.nodes.cache.size,
interaction.translate("misc:NOUNS:SERVERS:1"),
interaction.translate("misc:NOUNS:SERVERS:2"),
interaction.translate("misc:NOUNS:SERVERS:5"),
)}`,
}), }),
}, },
{ {
@ -81,20 +90,19 @@ class Stats extends BaseCommand {
{ {
name: client.customEmojis.link + " " + interaction.translate("general/stats:LINKS_TITLE"), name: client.customEmojis.link + " " + interaction.translate("general/stats:LINKS_TITLE"),
value: interaction.translate("misc:STATS_FOOTER", { value: interaction.translate("misc:STATS_FOOTER", {
dashboardLink: client.config.dashboard.domain, dashboardLink: client.config.dashboard.baseURL,
supportLink: "https://discord.gg/Ptkj2n9nzZ", supportLink: "https://discord.gg/Ptkj2n9nzZ",
inviteLink: client.generateInvite({ scopes: ["bot", "applications.commands"], permissions: [PermissionsBitField.Flags.Administrator] }), inviteLink: client.generateInvite({ scopes: ["bot", "applications.commands"], permissions: [ PermissionsBitField.Flags.Administrator ] }),
donateLink: "https://www.donationalerts.com/r/jonny_bro", donateLink: "https://www.donationalerts.com/r/jonny_bro",
owner: client.config.owner.id, owner: client.config.owner.id,
}), }),
}, },
], ]);
});
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [statsEmbed],
}); });
} }
} }
module.exports = Stats; module.exports = Stats;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, parseEmoji } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Suggest extends BaseCommand { class Suggest extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,48 +12,51 @@ class Suggest extends BaseCommand {
.setName("suggest") .setName("suggest")
.setDescription(client.translate("general/suggest:DESCRIPTION")) .setDescription(client.translate("general/suggest:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/suggest:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/suggest:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/suggest:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/suggest:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addStringOption(option => .addStringOption(option => option.setName("message")
option .setDescription(client.translate("common:MESSAGE"))
.setName("message") .setDescriptionLocalizations({
.setDescription(client.translate("common:MESSAGE")) "uk": client.translate("common:MESSAGE", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:MESSAGE", null, "ru-RU"),
uk: client.translate("common:MESSAGE", null, "uk-UA"), })
ru: client.translate("common:MESSAGE", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const guildData = interaction.data.guild, const suggChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.suggestions);
channel = interaction.guild.channels.cache.get(guildData.plugins.suggestions); if (!suggChannel) return interaction.error("general/suggest:MISSING_CHANNEL");
if (!channel) return interaction.error("general/suggest:MISSING_CHANNEL");
const suggestion = interaction.options.getString("message"); const suggestion = interaction.options.getString("message");
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("general/suggest:TITLE", { name: interaction.translate("general/suggest:TITLE", {
user: interaction.user.getUsername(), user: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
}), }),
iconURL: interaction.member.displayAvatarURL(), iconURL: interaction.member.displayAvatarURL(),
}, })
fields: [ .addFields([
{ {
name: interaction.translate("common:DATE"), name: interaction.translate("common:DATE"),
value: `<t:${Math.floor(Date.now() / 1000)}:D>`, value: client.functions.printDate(client, new Date(Date.now())),
}, },
{ {
name: interaction.translate("common:AUTHOR"), name: interaction.translate("common:AUTHOR"),
@ -65,13 +68,16 @@ class Suggest extends BaseCommand {
value: suggestion, value: suggestion,
inline: true, inline: true,
}, },
], ])
}); .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
const success = parseEmoji(client.customEmojis.cool).id; const success = parseEmoji(client.customEmojis.cool).id;
const error = parseEmoji(client.customEmojis.notcool).id; const error = parseEmoji(client.customEmojis.notcool).id;
channel.send({ suggChannel.send({
embeds: [embed], embeds: [embed],
}).then(async m => { }).then(async m => {
await m.react(success); await m.react(success);
@ -79,9 +85,9 @@ class Suggest extends BaseCommand {
}); });
interaction.success("general/suggest:SUCCESS", { interaction.success("general/suggest:SUCCESS", {
channel: channel.toString(), channel: suggChannel.toString(),
}, { ephemeral: true }); }, { ephemeral: true });
} }
} }
module.exports = Suggest; module.exports = Suggest;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Userinfo extends BaseCommand { class Userinfo extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,43 +12,48 @@ class Userinfo extends BaseCommand {
.setName("userinfo") .setName("userinfo")
.setDescription(client.translate("general/userinfo:DESCRIPTION")) .setDescription(client.translate("general/userinfo:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/userinfo:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/userinfo:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/userinfo:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/userinfo:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })),
ru: client.translate("common:USER", null, "ru-RU"), aliases: [],
}),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const member = interaction.options.getMember("user") || interaction.member; const member = interaction.options.getMember("user") || interaction.member;
const embed = new EmbedBuilder()
const embed = client.embed({ .setAuthor({
author: { name: `${member.user.discriminator === "0" ? member.user.username : member.user.tag} (${member.id})`,
name: `${member.user.getUsername()} (${member.id})`,
iconURL: member.displayAvatarURL(), iconURL: member.displayAvatarURL(),
}, })
thumbnail: member.displayAvatarURL(), .setThumbnail(member.displayAvatarURL({
fields: [ size: 512,
}))
.addFields([
{ {
name: ":man: " + interaction.translate("common:USERNAME"), name: ":man: " + interaction.translate("common:USERNAME"),
value: member.user.getUsername(), value: member.user.discriminator === "0" ? member.user.username : member.user.tag,
inline: true, inline: true,
}, },
{ {
@ -56,6 +61,11 @@ class Userinfo extends BaseCommand {
value: member.nickname || interaction.translate("general/userinfo:NO_NICKNAME"), value: member.nickname || interaction.translate("general/userinfo:NO_NICKNAME"),
inline: true, inline: true,
}, },
// {
// name: client.customEmojis.status[member.presence.status] + " " + interaction.translate("common:STATUS"),
// value: interaction.translate(`common:STATUS_${member.presence.status.toUpperCase()}`),
// inline: true,
// },
{ {
name: client.customEmojis.bot + " " + interaction.translate("common:ROBOT"), name: client.customEmojis.bot + " " + interaction.translate("common:ROBOT"),
value: member.user.bot ? interaction.translate("common:YES") : interaction.translate("common:NO"), value: member.user.bot ? interaction.translate("common:YES") : interaction.translate("common:NO"),
@ -63,12 +73,12 @@ class Userinfo extends BaseCommand {
}, },
{ {
name: client.customEmojis.calendar + " " + interaction.translate("common:CREATION"), name: client.customEmojis.calendar + " " + interaction.translate("common:CREATION"),
value: `<t:${member.user.createdTimestamp}:D>`, value: client.functions.printDate(client, member.user.createdAt),
inline: true, inline: true,
}, },
{ {
name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOINED"), name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOINED"),
value: `<t:${member.joinedTimestamp}:D>`, value: client.functions.printDate(client, member.joinedAt),
inline: true, inline: true,
}, },
{ {
@ -78,17 +88,35 @@ class Userinfo extends BaseCommand {
}, },
{ {
name: client.customEmojis.roles + " " + interaction.translate("common:ROLES"), name: client.customEmojis.roles + " " + interaction.translate("common:ROLES"),
value: value: (member.roles.size > 10 ? member.roles.cache.map(r => r).slice(0, 10).join(", ") + " " + interaction.translate("general/userinfo:MORE_ROLES", {
member.roles.size > 10 count: member.roles.cache.size - 10,
? member.roles.cache.map(r => r).filter(r => r.id !== interaction.guild.roles.everyone.id).slice(0, 10).join(", ") + " " + }) : (member.roles.cache.size < 1) ? interaction.translate("general/userinfo:NO_ROLE") : member.roles.cache.map(r => r).join(", ")),
interaction.translate("general/userinfo:MORE_ROLES", {
count: member.roles.cache.size - 10,
})
: member.roles.cache.size < 1 ? interaction.translate("general/userinfo:NO_ROLE") : member.roles.cache.map(r => r).filter(r => r.id !== interaction.guild.roles.everyone.id).slice(0, 10).join(", "),
inline: true, inline: true,
}, },
], ])
}); .setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
});
/*
if (member.presence.activities[0]?.name === "Custom Status") {
embed.addFields([
{
name: client.customEmojis.games + " " + interaction.translate("common:ACTIVITY"),
value: member.presence.activities[0] ? `${interaction.translate("general/userinfo:CUSTOM")}\n${member.presence.activities[0].state || interaction.translate("common:NOT_DEFINED")}` : interaction.translate("general/userinfo:NO_ACTIVITY"),
inline: true,
},
]);
} else {
embed.addFields([
{
name: client.customEmojis.games + " " + interaction.translate("common:ACTIVITY"),
value: member.presence.activities[0] ? `${member.presence.activities[0].name}\n${member.presence.activities[0].details}\n${member.presence.activities[0].state}` : interaction.translate("general/userinfo:NO_ACTIVITY"),
inline: true,
},
]);
} */
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
@ -96,4 +124,4 @@ class Userinfo extends BaseCommand {
} }
} }
module.exports = Userinfo; module.exports = Userinfo;

View file

@ -1,11 +1,11 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
fetch = require("node-fetch"); fetch = require("node-fetch");
class Whois extends BaseCommand { class Whois extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,29 +13,34 @@ class Whois extends BaseCommand {
.setName("whois") .setName("whois")
.setDescription(client.translate("general/whois:DESCRIPTION")) .setDescription(client.translate("general/whois:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("general/whois:DESCRIPTION", null, "uk-UA"), "uk": client.translate("general/whois:DESCRIPTION", null, "uk-UA"),
ru: client.translate("general/whois:DESCRIPTION", null, "ru-RU"), "ru": client.translate("general/whois:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true) .setDMPermission(true)
.addStringOption(option => .addStringOption(option => option.setName("ip")
option .setDescription(client.translate("common:IP"))
.setName("ip") .setDescriptionLocalizations({
.setDescription(client.translate("common:IP")) "uk": client.translate("common:IP", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:IP", null, "ru-RU"),
uk: client.translate("common:IP", null, "uk-UA"), })
ru: client.translate("common:IP", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
@ -45,11 +50,15 @@ class Whois extends BaseCommand {
if (whois.status === "fail") return interaction.editReply({ content: interaction.translate("general/whois:ERROR", { ip }) }); if (whois.status === "fail") return interaction.editReply({ content: interaction.translate("general/whois:ERROR", { ip }) });
const embed = client.embed({ const embed = new EmbedBuilder()
title: interaction.translate("general/whois:INFO_ABOUT", { .setTitle(interaction.translate("general/whois:INFO_ABOUT", {
ip, ip,
}), }))
fields: [ .setFooter({
text: client.config.embed.footer,
})
.setColor(client.config.embed.color)
.addFields(
{ name: interaction.translate("common:IP"), value: whois.query, inline: true }, { name: interaction.translate("common:IP"), value: whois.query, inline: true },
{ name: interaction.translate("general/whois:COUNTRY"), value: `${whois.country || interaction.translate("common:UNKNOWN")} (${whois.countryCode || interaction.translate("common:UNKNOWN")})`, inline: true }, { name: interaction.translate("general/whois:COUNTRY"), value: `${whois.country || interaction.translate("common:UNKNOWN")} (${whois.countryCode || interaction.translate("common:UNKNOWN")})`, inline: true },
{ name: interaction.translate("general/whois:REGION"), value: `${whois.regionName || interaction.translate("common:UNKNOWN")} (${whois.region || interaction.translate("common:UNKNOWN")})`, inline: true }, { name: interaction.translate("general/whois:REGION"), value: `${whois.regionName || interaction.translate("common:UNKNOWN")} (${whois.region || interaction.translate("common:UNKNOWN")})`, inline: true },
@ -59,12 +68,12 @@ class Whois extends BaseCommand {
{ name: interaction.translate("general/whois:CONTINENT"), value: `${whois.continent || interaction.translate("common:UNKNOWN")} (${whois.continentCode || interaction.translate("common:UNKNOWN")})`, inline: true }, { name: interaction.translate("general/whois:CONTINENT"), value: `${whois.continent || interaction.translate("common:UNKNOWN")} (${whois.continentCode || interaction.translate("common:UNKNOWN")})`, inline: true },
{ name: interaction.translate("general/whois:CURRENCY"), value: `${whois.currency || interaction.translate("common:UNKNOWN")}`, inline: true }, { name: interaction.translate("general/whois:CURRENCY"), value: `${whois.currency || interaction.translate("common:UNKNOWN")}`, inline: true },
{ name: interaction.translate("general/whois:ISP"), value: `${whois.isp || interaction.translate("common:UNKNOWN")}`, inline: true }, { name: interaction.translate("general/whois:ISP"), value: `${whois.isp || interaction.translate("common:UNKNOWN")}`, inline: true },
], )
}); .setTimestamp();
if (whois.proxy) embed.data.fields.push({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:PROXY") }); if (whois.proxy) embed.addFields({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:PROXY") });
if (whois.mobile) embed.data.fields.push({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:MOBILE") }); if (whois.mobile) embed.addFields({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:MOBILE") });
if (whois.hosting) embed.data.fields.push({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:HOSTING") }); if (whois.hosting) embed.addFields({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:HOSTING") });
interaction.editReply({ interaction.editReply({
embeds: [embed], embeds: [embed],
@ -72,4 +81,4 @@ class Whois extends BaseCommand {
} }
} }
module.exports = Whois; module.exports = Whois;

View file

@ -1,4 +1,4 @@
const { SlashCommandBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
fetch = require("node-fetch"), fetch = require("node-fetch"),
moment = require("moment"); moment = require("moment");
@ -6,7 +6,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class Checkjar extends BaseCommand { class Checkjar extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -14,54 +14,69 @@ class Checkjar extends BaseCommand {
.setName("checkjar") .setName("checkjar")
.setDescription(client.translate("iat/checkjar:DESCRIPTION")) .setDescription(client.translate("iat/checkjar:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("iat/checkjar:DESCRIPTION", null, "uk-UA"), "uk": client.translate("iat/checkjar:DESCRIPTION", null, "uk-UA"),
ru: client.translate("iat/checkjar:DESCRIPTION", null, "ru-RU"), "ru": client.translate("iat/checkjar:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data * @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
const clientInfo = await fetch("https://api.monobank.ua/personal/client-info", { const jarsList = await fetch("https://api.monobank.ua/personal/client-info", {
method: "GET", method: "GET",
headers: { headers: {
"X-Token": client.config.apiKeys.monobank.key, "X-Token": client.config.apiKeys.monobankApiKey,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}).then(res => res.json()); }).then(res => res.json());
const jar = clientInfo.jars.find(j => j.id === client.config.apiKeys.monobank.jar); const jar = jarsList.jars[1];
const jarTransactions = await fetch(`https://api.monobank.ua/personal/statement/${jar.id}/${Date.now() - 7 * 24 * 60 * 60 * 1000}/${Date.now()}`, {
const jarTransactions = await fetch(`https://api.monobank.ua/personal/statement/${jar.id}/${Date.now() - (7 * 24 * 60 * 60 * 1000)}/${Date.now()}`, {
method: "GET", method: "GET",
headers: { headers: {
"X-Token": client.config.apiKeys.monobank.key, "X-Token": client.config.apiKeys.monobankApiKey,
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
}).then(res => res.json()); }).then(res => res.json());
const embed = client.embed({ const embed = new EmbedBuilder()
description: `Текущий баланс: **${jar.balance / Math.pow(10, 2)}** грн\nТребуется на след. месяц: **379,18** грн (по курсу евро на 02.07.2023).\nЗдесь указаны последние 10 транзакций.`, .setColor(client.config.embed.color)
}); .setFooter({
text: client.config.embed.footer,
})
.setAuthor({
name: "Monobank API",
iconURL: "https://api.monobank.ua/docs/logo.png",
})
.setDescription(`Текущий баланс: **${jar.balance / Math.pow(10, 2)}** грн\nТребуется на след. месяц: ~**381** грн (по курсу евро на 15.06.2023)`);
jarTransactions.length = 10; jarTransactions.length = 10;
jarTransactions.forEach(t => { jarTransactions.forEach(t => {
// TODO
const time = moment.unix(t.time); const time = moment.unix(t.time);
embed.data.fields.push([ embed.addFields([
{ {
name: `${t.description}`, name: `${t.description}`,
value: `Дата: <t:${time}:D>\nСумма: ${t.amount / Math.pow(10, 2)} грн`, value: `Дата: ${time.locale("uk-UA").format("DD MMMM YYYY, HH:mm")}\nСумма: ${t.amount / Math.pow(10, 2)} грн`,
inline: true,
}, },
]); ]);
}); });
@ -72,4 +87,4 @@ class Checkjar extends BaseCommand {
} }
} }
module.exports = Checkjar; module.exports = Checkjar;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Clear extends BaseCommand { class Clear extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,48 +12,47 @@ class Clear extends BaseCommand {
.setName("clear") .setName("clear")
.setDescription(client.translate("moderation/clear:DESCRIPTION")) .setDescription(client.translate("moderation/clear:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/clear:DESCRIPTION", null, "uk-UA"), "uk": client.translate("moderation/clear:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/clear:DESCRIPTION", null, "ru-RU"), "ru": client.translate("moderation/clear:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
.addStringOption(option => .addStringOption(option => option.setName("option")
option .setDescription(client.translate("moderation/clear:OPTION"))
.setName("option") .setDescriptionLocalizations({
.setDescription(client.translate("moderation/clear:OPTION")) "uk": client.translate("moderation/clear:OPTION", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("moderation/clear:OPTION", null, "ru-RU"),
uk: client.translate("moderation/clear:OPTION", null, "uk-UA"), })
ru: client.translate("moderation/clear:OPTION", null, "ru-RU"), .setRequired(true))
}) .addUserOption(option => option.setName("user")
.setRequired(true), .setDescription(client.translate("common:USER"))
) .setDescriptionLocalizations({
.addUserOption(option => "uk": client.translate("common:USER", null, "uk-UA"),
option "ru": client.translate("common:USER", null, "ru-RU"),
.setName("user") }))
.setDescription(client.translate("common:USER")) .addStringOption(option => option.setName("id")
.setDescriptionLocalizations({ .setDescription(client.translate("common:USER_ID"))
uk: client.translate("common:USER", null, "uk-UA"), .setDescriptionLocalizations({
ru: client.translate("common:USER", null, "ru-RU"), "uk": client.translate("common:USER_ID", null, "uk-UA"),
}), "ru": client.translate("common:USER_ID", null, "ru-RU"),
) })),
.addStringOption(option => aliases: [],
option
.setName("id")
.setDescription(client.translate("common:USER_ID"))
.setDescriptionLocalizations({
uk: client.translate("common:USER_ID", null, "uk-UA"),
ru: client.translate("common:USER_ID", null, "ru-RU"),
}),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
@ -63,10 +62,17 @@ class Clear extends BaseCommand {
user_id = interaction.options.getString("id"); user_id = interaction.options.getString("id");
if (option === "all") { if (option === "all") {
const row = new ActionRowBuilder().addComponents( const row = new ActionRowBuilder()
new ButtonBuilder().setCustomId("clear_confirm_yes").setLabel(interaction.translate("common:ACCEPT")).setStyle(ButtonStyle.Danger), .addComponents(
new ButtonBuilder().setCustomId("clear_confirm_no").setLabel(interaction.translate("common:CANCEL")).setStyle(ButtonStyle.Secondary), new ButtonBuilder()
); .setCustomId("clear_confirm_yes")
.setLabel(interaction.translate("common:ACCEPT"))
.setStyle(ButtonStyle.Danger),
new ButtonBuilder()
.setCustomId("clear_confirm_no")
.setLabel(interaction.translate("common:CANCEL"))
.setStyle(ButtonStyle.Secondary),
);
await interaction.editReply({ await interaction.editReply({
content: interaction.translate("moderation/clear:ALL_CONFIRM"), content: interaction.translate("moderation/clear:ALL_CONFIRM"),
@ -74,7 +80,7 @@ class Clear extends BaseCommand {
}); });
const filter = i => i.user.id === interaction.user.id; const filter = i => i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter, idle: 15 * 1000 }); const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (15 * 1000) });
collector.on("collect", async i => { collector.on("collect", async i => {
if (i.isButton()) { if (i.isButton()) {
@ -119,7 +125,9 @@ class Clear extends BaseCommand {
} else { } else {
if (isNaN(option) || parseInt(option) < 1) return interaction.error("misc:OPTION_NAN_ALL", null, { ephemeral: true }); if (isNaN(option) || parseInt(option) < 1) return interaction.error("misc:OPTION_NAN_ALL", null, { ephemeral: true });
let messages = await interaction.channel.messages.fetch({ limit: option }); let messages = await interaction.channel.messages.fetch({
limit: option,
});
if (user_id && member) return interaction.replyT("moderation/clear:REQUIRE_ID_USER", null, { edit: true }); if (user_id && member) return interaction.replyT("moderation/clear:REQUIRE_ID_USER", null, { edit: true });
if (user_id || member) messages = messages.filter(m => m.author.id === (user_id || member.id)); if (user_id || member) messages = messages.filter(m => m.author.id === (user_id || member.id));
@ -129,7 +137,7 @@ class Clear extends BaseCommand {
if (member || user_id) { if (member || user_id) {
interaction.replyT("moderation/clear:CLEARED_MEMBER", { interaction.replyT("moderation/clear:CLEARED_MEMBER", {
amount: `**${option}** ${client.functions.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`, amount: `**${option}** ${client.functions.getNoun(option, interaction.translate("misc:NOUNS:MESSAGES:1"), interaction.translate("misc:NOUNS:MESSAGES:2"), interaction.translate("misc:NOUNS:MESSAGES:5"))}`,
user: user_id || member.toString(), user: (member?.user.discriminator === "0" ? member?.user.username : member?.user.tag || user_id),
}, { edit: true }); }, { edit: true });
} else { } else {
interaction.replyT("moderation/clear:CLEARED", { interaction.replyT("moderation/clear:CLEARED", {
@ -140,4 +148,4 @@ class Clear extends BaseCommand {
} }
} }
module.exports = Clear; module.exports = Clear;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Clearwarns extends BaseCommand { class Clearwarns extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,30 +12,35 @@ class Clearwarns extends BaseCommand {
.setName("clearwarns") .setName("clearwarns")
.setDescription(client.translate("moderation/clearwarns:DESCRIPTION")) .setDescription(client.translate("moderation/clearwarns:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/clearwarns:DESCRIPTION", null, "uk-UA"), "uk": client.translate("moderation/clearwarns:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/clearwarns:DESCRIPTION", null, "ru-RU"), "ru": client.translate("moderation/clearwarns:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })
ru: client.translate("common:USER", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const member = interaction.options.getMember("user"); const member = interaction.options.getMember("user");
@ -46,9 +51,7 @@ class Clearwarns extends BaseCommand {
}); });
memberData.sanctions = []; memberData.sanctions = [];
memberData.save();
memberData.markModified("sanctions");
await memberData.save();
interaction.success("moderation/clearwarns:SUCCESS", { interaction.success("moderation/clearwarns:SUCCESS", {
user: member.toString(), user: member.toString(),
@ -56,4 +59,4 @@ class Clearwarns extends BaseCommand {
} }
} }
module.exports = Clearwarns; module.exports = Clearwarns;

View file

@ -1,11 +1,11 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
ms = require("ms"); ms = require("ms");
class Giveaway extends BaseCommand { class Giveaway extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,126 +13,105 @@ class Giveaway extends BaseCommand {
.setName("giveaway") .setName("giveaway")
.setDescription(client.translate("moderation/giveaway:DESCRIPTION")) .setDescription(client.translate("moderation/giveaway:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:DESCRIPTION", null, "uk-UA"), "uk": client.translate("moderation/giveaway:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/giveaway:DESCRIPTION", null, "ru-RU"), "ru": client.translate("moderation/giveaway:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("create")
subcommand .setDescription(client.translate("moderation/giveaway:CREATE"))
.setName("create") .setDescriptionLocalizations({
.setDescription(client.translate("moderation/giveaway:CREATE")) "uk": client.translate("moderation/giveaway:CREATE", null, "uk-UA"),
"ru": client.translate("moderation/giveaway:CREATE", null, "ru-RU"),
})
.addStringOption(option => option.setName("duration")
.setDescription(client.translate("common:DURATION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:CREATE", null, "uk-UA"), "uk": client.translate("common:DURATION", null, "uk-UA"),
ru: client.translate("moderation/giveaway:CREATE", null, "ru-RU"), "ru": client.translate("common:DURATION", null, "ru-RU"),
}) })
.addStringOption(option => .setRequired(true))
option .addIntegerOption(option => option.setName("winners_count")
.setName("duration") .setDescription(client.translate("moderation/giveaway:WINNERS_COUNT"))
.setDescription(client.translate("common:DURATION")) .setDescriptionLocalizations({
.setDescriptionLocalizations({ "uk": client.translate("moderation/giveaway:WINNERS_COUNT", null, "uk-UA"),
uk: client.translate("common:DURATION", null, "uk-UA"), "ru": client.translate("moderation/giveaway:WINNERS_COUNT", null, "ru-RU"),
ru: client.translate("common:DURATION", null, "ru-RU"), })
}) .setRequired(true))
.setRequired(true), .addStringOption(option => option.setName("prize")
) .setDescription(client.translate("moderation/giveaway:PRIZE"))
.addIntegerOption(option => .setDescriptionLocalizations({
option "uk": client.translate("moderation/giveaway:PRIZE", null, "uk-UA"),
.setName("winners_count") "ru": client.translate("moderation/giveaway:PRIZE", null, "ru-RU"),
.setDescription(client.translate("moderation/giveaway:WINNERS_COUNT")) })
.setDescriptionLocalizations({ .setRequired(true))
uk: client.translate("moderation/giveaway:WINNERS_COUNT", null, "uk-UA"), .addBooleanOption(option => option.setName("isdrop")
ru: client.translate("moderation/giveaway:WINNERS_COUNT", null, "ru-RU"), .setDescription(client.translate("moderation/giveaway:ISDROP"))
}) .setDescriptionLocalizations({
.setRequired(true), "uk": client.translate("moderation/giveaway:ISDROP", null, "uk-UA"),
) "ru": client.translate("moderation/giveaway:ISDROP", null, "ru-RU"),
.addStringOption(option => })
option .setRequired(true)),
.setName("prize")
.setDescription(client.translate("moderation/giveaway:PRIZE"))
.setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:PRIZE", null, "uk-UA"),
ru: client.translate("moderation/giveaway:PRIZE", null, "ru-RU"),
})
.setRequired(true),
)
.addBooleanOption(option =>
option
.setName("isdrop")
.setDescription(client.translate("moderation/giveaway:ISDROP"))
.setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:ISDROP", null, "uk-UA"),
ru: client.translate("moderation/giveaway:ISDROP", null, "ru-RU"),
})
.setRequired(true),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("reroll")
subcommand .setDescription(client.translate("moderation/giveaway:REROLL"))
.setName("reroll") .setDescriptionLocalizations({
.setDescription(client.translate("moderation/giveaway:REROLL")) "uk": client.translate("moderation/giveaway:REROLL", null, "uk-UA"),
"ru": client.translate("moderation/giveaway:REROLL", null, "ru-RU"),
})
.addStringOption(option => option.setName("giveaway_id")
.setDescription(client.translate("moderation/giveaway:GIVEAWAY_ID"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:REROLL", null, "uk-UA"), "uk": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:REROLL", null, "ru-RU"), "ru": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
}) })
.addStringOption(option => .setRequired(true)),
option
.setName("giveaway_id")
.setDescription(client.translate("moderation/giveaway:GIVEAWAY_ID"))
.setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
})
.setRequired(true),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("end")
subcommand .setDescription(client.translate("moderation/giveaway:END"))
.setName("end") .setDescriptionLocalizations({
.setDescription(client.translate("moderation/giveaway:END")) "uk": client.translate("moderation/giveaway:END", null, "uk-UA"),
"ru": client.translate("moderation/giveaway:END", null, "ru-RU"),
})
.addStringOption(option => option.setName("giveaway_id")
.setDescription(client.translate("moderation/giveaway:GIVEAWAY_ID"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:END", null, "uk-UA"), "uk": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:END", null, "ru-RU"), "ru": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
}) })
.addStringOption(option => .setRequired(true)),
option
.setName("giveaway_id")
.setDescription(client.translate("moderation/giveaway:GIVEAWAY_ID"))
.setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
})
.setRequired(true),
),
) )
.addSubcommand(subcommand => .addSubcommand(subcommand => subcommand.setName("delete")
subcommand .setDescription(client.translate("moderation/giveaway:DELETE"))
.setName("delete") .setDescriptionLocalizations({
.setDescription(client.translate("moderation/giveaway:DELETE")) "uk": client.translate("moderation/giveaway:DELETE", null, "uk-UA"),
"ru": client.translate("moderation/giveaway:DELETE", null, "ru-RU"),
})
.addStringOption(option => option.setName("giveaway_id")
.setDescription(client.translate("moderation/giveaway:GIVEAWAY_ID"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:DELETE", null, "uk-UA"), "uk": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:DELETE", null, "ru-RU"), "ru": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
}) })
.addStringOption(option => .setRequired(true)),
option
.setName("giveaway_id")
.setDescription(client.translate("moderation/giveaway:GIVEAWAY_ID"))
.setDescriptionLocalizations({
uk: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
})
.setRequired(true),
),
), ),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const command = interaction.options.getSubcommand(); const command = interaction.options.getSubcommand();
@ -150,49 +129,44 @@ class Giveaway extends BaseCommand {
const prize = interaction.options.getString("prize"); const prize = interaction.options.getString("prize");
const isdrop = interaction.options.getBoolean("isdrop"); const isdrop = interaction.options.getBoolean("isdrop");
client.giveawaysManager client.giveawaysManager.start(interaction.channel, {
.start(interaction.channel, { duration: ms(duration),
duration: ms(duration), winnerCount: winnersCount,
winnerCount: winnersCount, prize: prize,
prize: prize, hostedBy: interaction.user,
hostedBy: interaction.user, isDrop: isdrop,
isDrop: isdrop, messages: {
messages: { giveaway: interaction.translate("moderation/giveaway:TITLE"),
giveaway: interaction.translate("moderation/giveaway:TITLE"), giveawayEnded: interaction.translate("moderation/giveaway:ENDED"),
giveawayEnded: interaction.translate("moderation/giveaway:ENDED"), timeRemaining: interaction.translate("moderation/giveaway:TIME_REMAINING"),
timeRemaining: interaction.translate("moderation/giveaway:TIME_REMAINING"), inviteToParticipate: interaction.translate("moderation/giveaway:INVITE_PARTICIPATE"),
inviteToParticipate: interaction.translate("moderation/giveaway:INVITE_PARTICIPATE"), winMessage: interaction.translate("moderation/giveaway:WIN_MESSAGE"),
winMessage: interaction.translate("moderation/giveaway:WIN_MESSAGE"), drawing: interaction.translate("moderation/giveaway:DRAWING"),
drawing: interaction.translate("moderation/giveaway:DRAWING"), dropMessage: interaction.translate("moderation/giveaway:DROP"),
dropMessage: interaction.translate("moderation/giveaway:DROP"), embedFooter: interaction.translate("moderation/giveaway:FOOTER"),
embedFooter: interaction.translate("moderation/giveaway:FOOTER"), noWinner: interaction.translate("moderation/giveaway:NO_WINNER"),
noWinner: interaction.translate("moderation/giveaway:NO_WINNER"), winners: interaction.translate("moderation/giveaway:WINNERS"),
winners: interaction.translate("moderation/giveaway:WINNERS"), endedAt: interaction.translate("moderation/giveaway:END_AT"),
endedAt: interaction.translate("moderation/giveaway:END_AT"), hostedBy: interaction.translate("moderation/giveaway:HOSTED_BY"),
hostedBy: interaction.translate("moderation/giveaway:HOSTED_BY"), },
}, }).then(() => {
}) return interaction.success("moderation/giveaway:GIVEAWAY_CREATED", null, { ephemeral: true });
.then(() => { });
return interaction.success("moderation/giveaway:GIVEAWAY_CREATED", null, { ephemeral: true });
});
} else if (command === "reroll") { } else if (command === "reroll") {
const giveaway_id = interaction.options.getString("giveaway_id"); const giveaway_id = interaction.options.getString("giveaway_id");
client.giveawaysManager client.giveawaysManager.reroll(giveaway_id, {
.reroll(giveaway_id, { messages: {
messages: { congrat: interaction.translate("moderation/giveaway:REROLL_CONGRAT"),
congrat: interaction.translate("moderation/giveaway:REROLL_CONGRAT"), error: interaction.translate("moderation/giveaway:REROLL_ERROR"),
error: interaction.translate("moderation/giveaway:REROLL_ERROR"), },
}, }).then(() => {
}) return interaction.success("moderation/giveaway:GIVEAWAY_REROLLED");
.then(() => { }).catch(() => {
return interaction.success("moderation/giveaway:GIVEAWAY_REROLLED"); return interaction.error("moderation/giveaway:NOT_FOUND_ENDED", {
}) messageId: giveaway_id,
.catch(() => { }, { ephemeral: true });
return interaction.error("moderation/giveaway:NOT_FOUND_ENDED", { });
messageId: giveaway_id,
}, { ephemeral: true });
});
} else if (command === "end") { } else if (command === "end") {
const giveaway_id = interaction.options.getString("giveaway_id"); const giveaway_id = interaction.options.getString("giveaway_id");
@ -207,18 +181,15 @@ class Giveaway extends BaseCommand {
} else if (command === "delete") { } else if (command === "delete") {
const giveaway_id = interaction.options.getString("giveaway_id"); const giveaway_id = interaction.options.getString("giveaway_id");
client.giveawaysManager client.giveawaysManager.delete(giveaway_id).then(() => {
.delete(giveaway_id) return interaction.success("moderation/giveaway:GIVEAWAY_DELETED");
.then(() => { }).catch(() => {
return interaction.success("moderation/giveaway:GIVEAWAY_DELETED"); return interaction.error("moderation/giveaway:NOT_FOUND", {
}) messageId: giveaway_id,
.catch(() => { }, { ephemeral: true });
return interaction.error("moderation/giveaway:NOT_FOUND", { });
messageId: giveaway_id,
}, { ephemeral: true });
});
} }
} }
} }
module.exports = Giveaway; module.exports = Giveaway;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Poll extends BaseCommand { class Poll extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,40 +12,59 @@ class Poll extends BaseCommand {
.setName("poll") .setName("poll")
.setDescription(client.translate("moderation/poll:DESCRIPTION")) .setDescription(client.translate("moderation/poll:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/poll:DESCRIPTION", null, "uk-UA"), "uk": client.translate("moderation/poll:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/poll:DESCRIPTION", null, "ru-RU"), "ru": client.translate("moderation/poll:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
.addStringOption(option => .addStringOption(option => option.setName("question")
option .setDescription(client.translate("moderation/poll:QUESTION"))
.setName("question") .setDescriptionLocalizations({
.setDescription(client.translate("moderation/poll:QUESTION")) "uk": client.translate("moderation/poll:QUESTION", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("moderation/poll:QUESTION", null, "ru-RU"),
uk: client.translate("moderation/poll:QUESTION", null, "uk-UA"), })
ru: client.translate("moderation/poll:QUESTION", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const question = interaction.options.getString("question"); const question = interaction.options.getString("question");
const row = new ActionRowBuilder().addComponents( const row = new ActionRowBuilder()
new ButtonBuilder().setCustomId("poll_everyone").setLabel("@everyone").setStyle(ButtonStyle.Primary), .addComponents(
new ButtonBuilder().setCustomId("poll_here").setLabel("@here").setStyle(ButtonStyle.Primary), new ButtonBuilder()
new ButtonBuilder().setCustomId("poll_nothing").setLabel(interaction.translate("moderation/poll:NOTHING")).setStyle(ButtonStyle.Primary), .setCustomId("poll_everyone")
new ButtonBuilder().setCustomId("poll_cancel").setLabel(interaction.translate("common:CANCEL")).setStyle(ButtonStyle.Danger), .setLabel("@everyone")
); .setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("poll_here")
.setLabel("@here")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("poll_nothing")
.setLabel(interaction.translate("moderation/poll:NOTHING"))
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId("poll_cancel")
.setLabel(interaction.translate("common:CANCEL"))
.setStyle(ButtonStyle.Danger),
);
await interaction.reply({ await interaction.reply({
content: interaction.translate("moderation/poll:SELECT_MENTION"), content: interaction.translate("moderation/poll:SELECT_MENTION"),
@ -55,7 +74,7 @@ class Poll extends BaseCommand {
let mention = null; let mention = null;
const filter = i => i.user.id === interaction.user.id; const filter = i => i.user.id === interaction.user.id;
const collector = interaction.channel.createMessageComponentCollector({ filter, idle: 15 * 1000 }); const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (15 * 1000) });
collector.on("collect", async i => { collector.on("collect", async i => {
if (i.isButton()) { if (i.isButton()) {
@ -87,22 +106,24 @@ class Poll extends BaseCommand {
const cool = client.emojis.cache.find(e => e.name === client.customEmojis.cool.split(":")[1]); const cool = client.emojis.cache.find(e => e.name === client.customEmojis.cool.split(":")[1]);
const notcool = client.emojis.cache.find(e => e.name === client.customEmojis.notcool.split(":")[1]); const notcool = client.emojis.cache.find(e => e.name === client.customEmojis.notcool.split(":")[1]);
const embed = client.embed({ const embed = new EmbedBuilder()
author: interaction.translate("moderation/poll:TITLE"), .setAuthor({
fields: [ name: interaction.translate("moderation/poll:TITLE"),
})
.setColor(client.config.embed.color)
.addFields([
{ {
name: "\u200B", name: "\u200b",
value: question, value: question,
}, },
{ {
name: "\u200B", name: "\u200b",
value: interaction.translate("moderation/poll:REACT", { value: interaction.translate("moderation/poll:REACT", {
success: cool.toString(), success: cool.toString(),
error: notcool.toString(), error: notcool.toString(),
}), }),
}, },
], ]);
});
return interaction.channel.send({ return interaction.channel.send({
content: mention, content: mention,
@ -116,4 +137,4 @@ class Poll extends BaseCommand {
} }
} }
module.exports = Poll; module.exports = Poll;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Unban extends BaseCommand { class Unban extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,30 +12,35 @@ class Unban extends BaseCommand {
.setName("unban") .setName("unban")
.setDescription(client.translate("moderation/unban:DESCRIPTION")) .setDescription(client.translate("moderation/unban:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/unban:DESCRIPTION", null, "uk-UA"), "uk": client.translate("moderation/unban:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/unban:DESCRIPTION", null, "ru-RU"), "ru": client.translate("moderation/unban:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
.addStringOption(option => .addStringOption(option => option.setName("user_id")
option .setDescription(client.translate("common:USER_ID"))
.setName("user_id") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER_ID")) "uk": client.translate("common:USER_ID", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER_ID", null, "ru-RU"),
uk: client.translate("common:USER_ID", null, "uk-UA"), })
ru: client.translate("common:USER_ID", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const id = interaction.options.getString("user_id"), const id = interaction.options.getString("user_id"),
@ -51,4 +56,4 @@ class Unban extends BaseCommand {
} }
} }
module.exports = Unban; module.exports = Unban;

View file

@ -1,58 +0,0 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Ban extends BaseCommand {
/**
*
* @param {import("../../base/Client")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("untimeout")
.setDescription(client.translate("moderation/untimeout:DESCRIPTION"))
.setDescriptionLocalizations({
uk: client.translate("moderation/untimeout:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/untimeout:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ModerateMembers)
.addUserOption(option =>
option
.setName("user")
.setDescription(client.translate("common:USER"))
.setDescriptionLocalizations({
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true),
),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
await interaction.deferReply();
const member = interaction.options.getMember("user"),
timedout = member.isCommunicationDisabled();
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true, edit: true });
if (member.id === interaction.member.id) return interaction.error("moderation/untimeout:YOURSELF", null, { ephemeral: true, edit: true });
if (!timedout) return interaction.error("moderation/untimeout:NOT_TIMEDOUT", null, { ephemeral: true, edit: true });
await member.timeout(null);
interaction.success("moderation/untimeout:SUCCESS", {
user: member.user.toString(),
}, { edit: true });
}
}
module.exports = Ban;

View file

@ -1,36 +1,44 @@
const { ContextMenuCommandBuilder, ModalBuilder, ActionRowBuilder, TextInputBuilder, ApplicationCommandType, PermissionsBitField, TextInputStyle } = require("discord.js"); const { ContextMenuCommandBuilder, ModalBuilder, EmbedBuilder, ActionRowBuilder, TextInputBuilder, ApplicationCommandType, PermissionFlagsBits, TextInputStyle } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class WarnContext extends BaseCommand { class Warn extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor() { constructor() {
super({ super({
command: new ContextMenuCommandBuilder() command: new ContextMenuCommandBuilder()
.setName("Give Warn") .setName("warn")
.setType(ApplicationCommandType.User) .setType(ApplicationCommandType.User)
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages), .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").UserContextMenuCommandInteraction} interaction
*/ */
async execute(client, interaction) { async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").UserContextMenuCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction, data) {
const member = interaction.targetMember, const member = interaction.targetMember,
memberPosition = member.roles.highest.position, memberPosition = member.roles.highest.position,
moderationPosition = interaction.member.roles.highest.position; moderationPosition = interaction.member.roles.highest.position;
if (member.user.bot) return interaction.error("misc:BOT_USER", null, { ephemeral: true }); 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 (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/warn:SUPERIOR", 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({ const memberData = await client.findOrCreateMember({
id: member.id, id: member.id,
@ -39,9 +47,7 @@ class WarnContext 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.discriminator === "0" ? member.user.username : member.user.tag }).normalize("NFKD"));
nickname: member.user.getUsername(),
}).normalize("NFKD"));
const reasonInput = new TextInputBuilder() const reasonInput = new TextInputBuilder()
.setCustomId("warn_reason") .setCustomId("warn_reason")
@ -55,24 +61,22 @@ class WarnContext extends BaseCommand {
await interaction.showModal(modal); await interaction.showModal(modal);
const submitted = await interaction const submitted = await interaction.awaitModalSubmit({
.awaitModalSubmit({ time: (2 * 60 * 1000),
time: 2 * 60 * 1000, filter: i => i.user.id === interaction.member.id && i.customId === "warn_modal",
filter: i => i.user.id === interaction.member.id && i.customId === "warn_modal", }).catch(() => {
}) interaction.followUp({
.catch(() => { content: interaction.translate("misc:TIMED_OUT"),
interaction.followUp({ ephemeral: true,
content: interaction.translate("misc:TIMED_OUT"),
ephemeral: true,
});
}); });
});
if (submitted) { if (submitted) {
const reason = submitted.fields.getTextInputValue("warn_reason"); const reason = submitted.fields.getTextInputValue("warn_reason");
// const sanctions = memberData.sanctions.filter(s => s.type === "warn").length; const sanctions = memberData.sanctions.filter(s => s.type === "warn").length;
// const banCount = data.guildData.plugins.warnsSanctions.ban; const banCount = data.guildData.plugins.warnsSanctions.ban;
// const kickCount = data.guildData.plugins.warnsSanctions.kick; const kickCount = data.guildData.plugins.warnsSanctions.kick;
const caseInfo = { const caseInfo = {
moderator: interaction.member.id, moderator: interaction.member.id,
@ -81,32 +85,29 @@ class WarnContext extends BaseCommand {
reason, reason,
}; };
const embed = client.embed({ const embed = new EmbedBuilder()
author: interaction.translate("moderation/warn:WARN"), .addFields([
fields: [
{ {
name: interaction.translate("common:USER"), name: interaction.translate("common:USER"),
value: member.user.toString(), value: `\`${member.user.discriminator === "0" ? member.user.username : member.user.tag}\` (${member.user.toString()})`,
}, },
{ {
name: interaction.translate("common:MODERATOR"), name: interaction.translate("common:MODERATOR"),
value: interaction.user.toString(), value: `\`${interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag}\` (${interaction.user.toString()})`,
}, },
{ {
name: interaction.translate("common:REASON"), name: interaction.translate("common:REASON"),
value: reason, value: reason,
inline: true, inline: true,
}, },
], ]);
});
/*
if (banCount) { if (banCount) {
if (sanctions >= banCount) { if (sanctions >= banCount) {
member.send({ member.send({
content: interaction.translate("moderation/ban:BANNED_DM", { content: interaction.translate("moderation/ban:BANNED_DM", {
user: member.user, user: member.user,
moderator: interaction.user.getUsername(), moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
server: interaction.guild.name, server: interaction.guild.name,
reason, reason,
}), }),
@ -121,10 +122,9 @@ class WarnContext extends BaseCommand {
.setColor(client.config.embed.color); .setColor(client.config.embed.color);
interaction.guild.members.ban(member).catch(() => {}); interaction.guild.members.ban(member).catch(() => {});
interaction.followUp({ interaction.followUp({
content: interaction.translate("moderation/setwarns:AUTO_BAN", { content: interaction.translate("moderation/setwarns:AUTO_BAN", {
user: member.user.getUsername(), user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
count: `${banCount} ${client.functions.getNoun(banCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`, count: `${banCount} ${client.functions.getNoun(banCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
}), }),
}); });
@ -136,7 +136,7 @@ class WarnContext extends BaseCommand {
member.send({ member.send({
content: interaction.translate("moderation/kick:KICKED_DM", { content: interaction.translate("moderation/kick:KICKED_DM", {
user: member.user, user: member.user,
moderator: interaction.user.getUsername(), moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
server: interaction.guild.name, server: interaction.guild.name,
reason, reason,
}), }),
@ -151,38 +151,35 @@ class WarnContext extends BaseCommand {
.setColor(client.config.embed.color); .setColor(client.config.embed.color);
member.kick().catch(() => {}); member.kick().catch(() => {});
interaction.followUp({ interaction.followUp({
content: interaction.translate("moderation/setwarns:AUTO_KICK", { content: interaction.translate("moderation/setwarns:AUTO_KICK", {
user: member.user.getUsername(), user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
count: `${kickCount} ${client.functions.getNoun(kickCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`, count: `${kickCount} ${client.functions.getNoun(kickCount, interaction.translate("misc:NOUNS:WARNS:1"), interaction.translate("misc:NOUNS:WARNS:2"), interaction.translate("misc:NOUNS:WARNS:5"))}`,
}), }),
}); });
} }
} */
try {
await member.send({
content: interaction.translate("moderation/warn:WARNED_DM", {
user: member.toString(),
server: interaction.guild.name,
moderator: interaction.user.toString(),
reason,
}),
});
} catch (e) {
interaction.followUp({ content: interaction.translate("misc:CANT_DM"), ephemeral: true });
} }
member.send({
content: interaction.translate("moderation/warn:WARNED_DM", {
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
server: interaction.guild.name,
moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
reason,
}),
});
embed
.setAuthor({
name: interaction.translate("moderation/warn:WARN"),
})
.setColor(client.config.embed.color);
memberData.sanctions.push(caseInfo); memberData.sanctions.push(caseInfo);
memberData.save();
memberData.markModified("sanctions"); if (data.guildData.plugins.modlogs) {
await memberData.save(); const channel = interaction.guild.channels.cache.get(data.guildData.plugins.modlogs);
const guildData = interaction.data.guild;
if (guildData.plugins.modlogs) {
const channel = interaction.guild.channels.cache.get(guildData.plugins.modlogs);
if (!channel) return; if (!channel) return;
channel.send({ channel.send({
@ -200,4 +197,4 @@ class WarnContext extends BaseCommand {
} }
} }
module.exports = WarnContext; module.exports = Warn;

View file

@ -1,10 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"); const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Warns extends BaseCommand { class Warns extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,30 +12,35 @@ class Warns extends BaseCommand {
.setName("warns") .setName("warns")
.setDescription(client.translate("moderation/warns:DESCRIPTION")) .setDescription(client.translate("moderation/warns:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("moderation/warns:DESCRIPTION", null, "uk-UA"), "uk": client.translate("moderation/warns:DESCRIPTION", null, "uk-UA"),
ru: client.translate("moderation/warns:DESCRIPTION", null, "ru-RU"), "ru": client.translate("moderation/warns:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages) .setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
.addUserOption(option => .addUserOption(option => option.setName("user")
option .setDescription(client.translate("common:USER"))
.setName("user") .setDescriptionLocalizations({
.setDescription(client.translate("common:USER")) "uk": client.translate("common:USER", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:USER", null, "ru-RU"),
uk: client.translate("common:USER", null, "uk-UA"), })
ru: client.translate("common:USER", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const member = interaction.options.getMember("user"); const member = interaction.options.getMember("user");
@ -46,37 +51,43 @@ class Warns extends BaseCommand {
guildId: interaction.guildId, guildId: interaction.guildId,
}); });
const embed = client.embed({ const embed = new EmbedBuilder()
author: { .setAuthor({
name: interaction.translate("moderation/warns:SANCTIONS_OF", { name: interaction.translate("moderation/warns:SANCTIONS_OF", {
member: member.user.getUsername(), member: member.nickname || member.user.username,
}), }),
iconURL: member.displayAvatarURL(), iconURL: member.displayAvatarURL({
}, extension: "png",
}); size: 512,
}),
if (memberData.sanctions.length === 0) { })
embed.data.description = interaction.translate("moderation/warns:NO_SANCTIONS", { .setColor(client.config.embed.color)
member: member.user.getUsername(), .setFooter({
text: client.config.embed.footer,
}); });
if (memberData.sanctions.length === 0) {
embed.setDescription(interaction.translate("moderation/warns:NO_SANCTIONS", {
member: member.nickname || member.user.username,
}));
return interaction.reply({ return interaction.reply({
embeds: [embed], embeds: [embed],
}); });
} else { } else {
memberData.sanctions.forEach(sanction => { memberData.sanctions.forEach(sanction => {
embed.data.fields.push({ embed.addFields([
name: sanction.type, {
value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`, name: sanction.type,
inline: true, value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`,
}); inline: true,
},
]);
}); });
} }
interaction.reply({ interaction.reply({
embeds: [embed], embeds: [embed],
}); });
} }
} }
module.exports = Warns; module.exports = Warns;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Back extends BaseCommand { class Back extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,19 +12,27 @@ class Back extends BaseCommand {
.setName("back") .setName("back")
.setDescription(client.translate("music/back:DESCRIPTION")) .setDescription(client.translate("music/back:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/back:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/back:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/back:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/back:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
@ -39,4 +47,4 @@ class Back extends BaseCommand {
} }
} }
module.exports = Back; module.exports = Back;

View file

@ -6,7 +6,7 @@ const BaseCommand = require("../../base/BaseCommand"),
class Clips extends BaseCommand { class Clips extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -14,30 +14,35 @@ class Clips extends BaseCommand {
.setName("clips") .setName("clips")
.setDescription(client.translate("music/clips:DESCRIPTION")) .setDescription(client.translate("music/clips:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/clips:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/clips:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/clips:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/clips:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addStringOption(option => .addStringOption(option => option.setName("query")
option .setDescription(client.translate("music/clips:QUERY"))
.setName("query") .setDescriptionLocalizations({
.setDescription(client.translate("music/clips:QUERY")) "uk": client.translate("music/clips:QUERY", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("music/clips:QUERY", null, "ru-RU"),
uk: client.translate("music/clips:QUERY", null, "uk-UA"), })
ru: client.translate("music/clips:QUERY", null, "ru-RU"), .setRequired(true)
}) .setAutocomplete(true)),
.setRequired(true) aliases: [],
.setAutocomplete(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
@ -51,7 +56,11 @@ class Clips extends BaseCommand {
client.player.play(interaction.member.voice.channel, query, { client.player.play(interaction.member.voice.channel, query, {
nodeOptions: { nodeOptions: {
metadata: interaction, metadata: {
client,
channel: interaction.channel,
requestedBy: interaction.user,
},
}, },
searchEngine: QueryType.FILE, searchEngine: QueryType.FILE,
selfDeaf: true, selfDeaf: true,
@ -70,7 +79,7 @@ class Clips extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").AutocompleteInteraction} interaction * @param {import("discord.js").AutocompleteInteraction} interaction
* @returns * @returns
*/ */
@ -79,13 +88,13 @@ class Clips extends BaseCommand {
files = fs.readdirSync("./clips"), files = fs.readdirSync("./clips"),
results = files.filter(f => f.includes(query)); results = files.filter(f => f.includes(query));
return await interaction.respond( return interaction.respond(
results.slice(0, 25).map(file => ({ results.slice(0, 25).map(file => ({
name: file.substring(0, file.length - 4), name: file.substring(0, file.length - 4),
value: `./clips/${file}`, value: `./clips/${file}`,
})), }),
); ));
} }
} }
module.exports = Clips; module.exports = Clips;

View file

@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Loop extends BaseCommand { class Loop extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,35 +13,40 @@ class Loop extends BaseCommand {
.setName("loop") .setName("loop")
.setDescription(client.translate("music/loop:DESCRIPTION")) .setDescription(client.translate("music/loop:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/loop:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/loop:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/loop:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/loop:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addStringOption(option => .addStringOption(option => option.setName("option")
option .setDescription(client.translate("music/loop:OPTION"))
.setName("option") .setDescriptionLocalizations({
.setDescription(client.translate("music/loop:OPTION")) "uk": client.translate("music/loop:OPTION", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("music/loop:OPTION", null, "ru-RU"),
uk: client.translate("music/loop:OPTION", null, "uk-UA"), })
ru: client.translate("music/loop:OPTION", null, "ru-RU"), .setRequired(true)
}) .setChoices(
.setRequired(true) { name: client.translate("music/loop:AUTOPLAY"), value: "3" },
.setChoices( { name: client.translate("music/loop:QUEUE"), value: "2" },
{ name: client.translate("music/loop:AUTOPLAY"), value: "3" }, { name: client.translate("music/loop:TRACK"), value: "1" },
{ name: client.translate("music/loop:QUEUE"), value: "2" }, { name: client.translate("music/loop:DISABLE"), value: "0" },
{ name: client.translate("music/loop:TRACK"), value: "1" }, )),
{ name: client.translate("music/loop:DISABLE"), value: "0" }, aliases: [],
),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
@ -50,20 +55,19 @@ class Loop extends BaseCommand {
const queue = client.player.nodes.get(interaction.guildId); const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true }); if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true });
const translated = {
"3": interaction.translate("music/loop:AUTOPLAY_ENABLED"),
"2": interaction.translate("music/loop:QUEUE_ENABLED"),
"1": interaction.translate("music/loop:TRACK_ENABLED"),
"0": interaction.translate("music/loop:LOOP_DISABLED"),
};
const type = interaction.options.getString("option"), const type = interaction.options.getString("option"),
mode = type === "3" ? QueueRepeatMode.AUTOPLAY : type === "2" ? QueueRepeatMode.QUEUE : type === "1" ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF; mode = type === "3" ? QueueRepeatMode.AUTOPLAY :
type === "2" ? QueueRepeatMode.QUEUE :
type === "1" ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF;
queue.setRepeatMode(mode); queue.setRepeatMode(mode);
interaction.reply({ content: translated[type] }); interaction.success(`music/loop:${
type === "3" ? "AUTOPLAY_ENABLED" :
type === "2" ? "QUEUE_ENABLED" :
type === "1" ? "TRACK_ENABLED" : "LOOP_DISABLED"
}`);
} }
} }
module.exports = Loop; module.exports = Loop;

View file

@ -1,11 +1,11 @@
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, StringSelectMenuOptionBuilder } = require("discord.js"), const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"),
{ QueueRepeatMode } = require("discord-player"); { QueueRepeatMode } = require("discord-player");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Nowplaying extends BaseCommand { class Nowplaying extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,183 +13,25 @@ class Nowplaying extends BaseCommand {
.setName("nowplaying") .setName("nowplaying")
.setDescription(client.translate("music/nowplaying:DESCRIPTION")) .setDescription(client.translate("music/nowplaying:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/nowplaying:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/nowplaying:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/nowplaying:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/nowplaying:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
async onLoad(client) { async onLoad() {
client.on("interactionCreate", async interaction => { //...
if (!interaction.isButton()) return;
if (interaction.customId.startsWith("nowp_")) {
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL");
const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
const row1 = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId("nowp_prev_track").setStyle(ButtonStyle.Primary).setEmoji("⬅️"),
new ButtonBuilder().setCustomId("nowp_stop").setStyle(ButtonStyle.Danger).setEmoji("⏹️"),
new ButtonBuilder().setCustomId("nowp_add_track").setStyle(ButtonStyle.Success).setEmoji("▶️"),
new ButtonBuilder().setCustomId("nowp_next_track").setStyle(ButtonStyle.Primary).setEmoji("➡️"),
new ButtonBuilder().setCustomId("nowp_loop").setStyle(ButtonStyle.Secondary).setEmoji("🔁"),
);
const row2 = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId("nowp_queue").setStyle(ButtonStyle.Secondary).setEmoji(""),
);
if (interaction.customId === "nowp_prev_track") {
await interaction.deferUpdate();
if (queue.history.isEmpty()) return interaction.followUp({ content: interaction.translate("music/back:NO_PREV_SONG", null, "error"), ephemeral: true });
queue.history.back();
await interaction.followUp({ content: interaction.translate("music/back:SUCCESS"), ephemeral: true });
const embed = await updateEmbed(interaction, queue);
interaction.editReply({
embeds: [embed],
});
} else if (interaction.customId === "nowp_loop") {
await interaction.deferUpdate();
const selectMenu = new StringSelectMenuBuilder()
.setCustomId("nowp_select")
.setPlaceholder(interaction.translate("common:NOTHING_SELECTED"))
.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(interaction.translate("music/loop:AUTOPLAY"))
.setValue("3"),
new StringSelectMenuOptionBuilder()
.setLabel(interaction.translate("music/loop:QUEUE"))
.setValue("2"),
new StringSelectMenuOptionBuilder()
.setLabel(interaction.translate("music/loop:TRACK"))
.setValue("1"),
new StringSelectMenuOptionBuilder()
.setLabel(interaction.translate("music/loop:DISABLE"))
.setValue("0"),
);
const selectRow = new ActionRowBuilder().addComponents(selectMenu),
msg = await interaction.followUp({
components: [selectRow],
ephemeral: true,
});
const filter = i => i.user.id === interaction.user.id,
collected = await msg.awaitMessageComponent({ filter, time: 10 * 1000 }),
mode = collected.values[0] === "3" ? QueueRepeatMode.AUTOPLAY : collected.values[0] === "2" ? QueueRepeatMode.QUEUE : collected.values[0] === "1" ? QueueRepeatMode.TRACK : QueueRepeatMode.OFF,
translated = {
"3": interaction.translate("music/loop:AUTOPLAY_ENABLED"),
"2": interaction.translate("music/loop:QUEUE_ENABLED"),
"1": interaction.translate("music/loop:TRACK_ENABLED"),
"0": interaction.translate("music/loop:LOOP_DISABLED"),
};
await collected.deferUpdate();
queue.setRepeatMode(mode);
await interaction.followUp({ content: translated[collected.values[0]] });
const embed = await updateEmbed(interaction, queue);
interaction.editReply({
embeds: [embed],
});
} else if (interaction.customId === "nowp_add_track") {
await interaction.deferUpdate();
await interaction.followUp({
content: interaction.translate("music/nowplaying:LINK"),
ephemeral: true,
});
const filter = m => m.author.id === interaction.user.id && m.content.startsWith("http"),
collect = await interaction.channel.awaitMessages({ filter, time: 10 * 1000, max: 1 });
if (collect.size < 1) return;
const collected = collect.first(),
query = collected.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g)[0],
searchResult = await client.player.search(query, {
requestedBy: interaction.user,
});
if (collected.deletable) collected.delete();
if (!searchResult.hasTracks()) return interaction.error("music/play:NO_RESULT", { query: query }, { edit: true });
else queue.addTrack(searchResult);
await interaction.followUp({
content: interaction.translate("music/play:ADDED_QUEUE", {
songName: searchResult.hasPlaylist() ? searchResult.playlist.title : searchResult.tracks[0].title,
}),
});
const embed = await updateEmbed(interaction, queue);
interaction.editReply({
embeds: [embed],
});
} else if (interaction.customId === "nowp_next_track") {
await interaction.deferUpdate();
queue.node.skip();
await interaction.followUp({ content: interaction.translate("music/skip:SUCCESS"), ephemeral: true });
const embed = await updateEmbed(interaction, queue);
interaction.editReply({
embeds: [embed],
});
} else if (interaction.customId === "nowp_queue") {
await interaction.deferUpdate();
client.commands.get("queue").execute(client, interaction);
} else if (interaction.customId === "nowp_stop") {
await interaction.deferUpdate();
queue.delete();
await interaction.followUp({ content: interaction.translate("music/stop:SUCCESS") });
row1.components.forEach(component => {
component.setDisabled(true);
});
row2.components.forEach(component => {
component.setDisabled(true);
});
return interaction.editReply({
components: [row1, row2],
});
}
}
});
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data * @param {Object} data
*/ */
@ -198,93 +40,59 @@ class Nowplaying extends BaseCommand {
const queue = client.player.nodes.get(interaction.guildId); const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true }); if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true });
const progressBar = queue.node.createProgressBar(),
track = queue.currentTrack;
const row1 = new ActionRowBuilder().addComponents( const embed = new EmbedBuilder()
new ButtonBuilder().setCustomId("nowp_prev_track").setStyle(ButtonStyle.Primary).setEmoji("⬅️"), .setAuthor({
new ButtonBuilder().setCustomId("nowp_stop").setStyle(ButtonStyle.Danger).setEmoji("⏹️"), name: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
new ButtonBuilder().setCustomId("nowp_add_track").setStyle(ButtonStyle.Success).setEmoji("▶️"), })
new ButtonBuilder().setCustomId("nowp_next_track").setStyle(ButtonStyle.Primary).setEmoji("➡️"), .setThumbnail(track.thumbnail)
new ButtonBuilder().setCustomId("nowp_loop").setStyle(ButtonStyle.Secondary).setEmoji("🔁"), .addFields([
); {
name: interaction.translate("music/nowplaying:T_TITLE"),
value: `[${track.title}](${track.url})`,
inline: true,
},
{
name: interaction.translate("music/nowplaying:T_AUTHOR"),
value: track.author || interaction.translate("common:UNKNOWN"),
inline: true,
},
{ name: "\u200B", value: "\u200B", inline: true },
{
name: interaction.translate("common:VIEWS"),
value: track.raw.live ? "" : new Intl.NumberFormat(interaction.client.languages.find(language => language.name === interaction.guild.data.language).moment, { notation: "standard" }).format(track.raw.views),
inline: true,
},
{
name: interaction.translate("music/queue:ADDED"),
value: track.requestedBy.toString(),
inline: true,
},
{
name: interaction.translate("music/nowplaying:T_DURATION"),
value: progressBar,
},
{
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("common:DISABLED")
}\``,
},
])
.setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
})
.setTimestamp();
const row2 = new ActionRowBuilder().addComponents( interaction.editReply({
new ButtonBuilder().setCustomId("nowp_queue").setStyle(ButtonStyle.Secondary).setEmoji(""),
);
const embed = await updateEmbed(interaction, queue);
const message = await interaction.editReply({
embeds: [embed], embeds: [embed],
components: [row1, row2],
}); });
const i = setInterval(async function () {
if (message && message.editable && queue.isPlaying()) {
const e = await updateEmbed(interaction, queue);
message.edit({
embeds: [e],
components: [row1, row2],
});
} else clearInterval(i);
}, 60 * 1000);
} }
} }
/** module.exports = Nowplaying;
*
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {import("discord-player").GuildQueue} queue
* @returns
*/
async function updateEmbed(interaction, queue) {
const progressBar = queue.node.createProgressBar(),
track = queue.currentTrack,
mode = queue.repeatMode === QueueRepeatMode.AUTOPLAY ? "3" : queue.repeatMode === QueueRepeatMode.QUEUE ? "2" : queue.repeatMode === QueueRepeatMode.TRACK ? "1" : "0",
translated = {
"3": interaction.translate("music/loop:AUTOPLAY"),
"2": interaction.translate("music/loop:QUEUE"),
"1": interaction.translate("music/loop:TRACK"),
"0": interaction.translate("common:DISABLED"),
};
const embed = interaction.client.embed({
author: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
thumbnail: track.thumbnail || null,
fields: [
{
name: interaction.translate("music/nowplaying:T_TITLE"),
value: `[${track.title}](${track.url})`,
inline: true,
},
{
name: interaction.translate("music/nowplaying:T_AUTHOR"),
value: track.author || interaction.translate("common:UNKNOWN"),
inline: true,
},
{ name: "\u200B", value: "\u200B", inline: true },
{
name: interaction.translate("common:VIEWS"),
value: track.raw.live ? "Live" : new Intl.NumberFormat(interaction.client.defaultLanguage.moment, { notation: "standard" }).format(track.raw.views),
inline: true,
},
{
name: interaction.translate("music/queue:ADDED"),
value: track.requestedBy.toString(),
inline: true,
},
{
name: interaction.translate("music/nowplaying:T_DURATION"),
value: progressBar,
},
{
name: "\u200B",
value: `${interaction.translate("music/nowplaying:REPEAT")}: \`${translated[mode]}\``,
},
],
});
return embed;
}
module.exports = Nowplaying;

View file

@ -1,71 +0,0 @@
const { ContextMenuCommandBuilder, ApplicationCommandType, PermissionsBitField } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class PlayContext extends BaseCommand {
/**
*
* @param {import("../../base/Client")} client
*/
constructor() {
super({
command: new ContextMenuCommandBuilder()
.setName("Add to Queue")
.setType(ApplicationCommandType.Message)
.setDMPermission(false),
dirname: __dirname,
ownerOnly: false,
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").MessageContextMenuCommandInteraction} interaction
*/
async execute(client, interaction) {
await interaction.deferReply();
const links = interaction.targetMessage.content.match(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/g);
if (!links) return interaction.error("music/play:NO_LINK", null, { edit: true });
const query = links[0],
voice = interaction.member.voice.channel;
if (!voice) return interaction.error("music/play:NO_VOICE_CHANNEL", null, { edit: true });
const perms = voice.permissionsFor(client.user);
if (!perms.has(PermissionsBitField.Flags.Connect) || !perms.has(PermissionsBitField.Flags.Speak)) return interaction.error("music/play:VOICE_CHANNEL_CONNECT", null, { edit: true });
const searchResult = await client.player.search(query, {
requestedBy: interaction.user,
});
if (!searchResult.hasTracks()) return interaction.error("music/play:NO_RESULT", { query }, { edit: true });
else {
const { queue } = await client.player.play(interaction.member.voice.channel, searchResult, {
nodeOptions: {
metadata: interaction,
},
selfDeaf: true,
leaveOnEnd: false,
leaveOnStop: true,
skipOnNoStream: true,
maxSize: 200,
maxHistorySize: 50,
});
interaction.editReply({
content: interaction.translate("music/play:ADDED_QUEUE", {
songName: searchResult.hasPlaylist() ? searchResult.playlist.title : searchResult.tracks[0].title,
}),
});
if (client.player.nodes.get(interaction.guildId).currentTrack.url === query && query.match(/&t=[[0-9]+/g) !== null) {
const time = query.match(/&t=[[0-9]+/g)[0].split("=")[1];
queue.node.seek(time * 1000);
}
}
}
}
module.exports = PlayContext;

View file

@ -1,11 +1,10 @@
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"), const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
{ QueryType } = require("discord-player");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Play extends BaseCommand { class Play extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,30 +12,35 @@ class Play extends BaseCommand {
.setName("play") .setName("play")
.setDescription(client.translate("music/play:DESCRIPTION")) .setDescription(client.translate("music/play:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/play:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/play:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/play:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/play:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addStringOption(option => .addStringOption(option => option.setName("query")
option .setDescription(client.translate("music/play:QUERY"))
.setName("query") .setDescriptionLocalizations({
.setDescription(client.translate("music/play:QUERY")) "uk": client.translate("music/play:QUERY", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("music/play:QUERY", null, "ru-RU"),
uk: client.translate("music/play:QUERY", null, "uk-UA"), })
ru: client.translate("music/play:QUERY", null, "ru-RU"), .setRequired(true)
}) .setAutocomplete(true)),
.setRequired(true) aliases: [],
.setAutocomplete(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply(); await interaction.deferReply();
@ -54,66 +58,48 @@ class Play extends BaseCommand {
if (!searchResult.hasTracks()) return interaction.error("music/play:NO_RESULT", { query }, { edit: true }); if (!searchResult.hasTracks()) return interaction.error("music/play:NO_RESULT", { query }, { edit: true });
else { else {
await client.player.play(interaction.member.voice.channel, searchResult, { client.player.play(interaction.member.voice.channel, searchResult, {
nodeOptions: { nodeOptions: {
metadata: interaction, metadata: {
client,
channel: interaction.channel,
requestedBy: interaction.user,
},
}, },
selfDeaf: true, selfDeaf: true,
leaveOnEnd: false, leaveOnEnd: false,
leaveOnStop: true, leaveOnStop: true,
skipOnNoStream: true, skipOnNoStream: true,
maxSize: 200, bufferingTimeout: 1000,
maxHistorySize: 50,
});
interaction.editReply({
content: interaction.translate("music/play:ADDED_QUEUE", {
songName: searchResult.hasPlaylist() ? searchResult.playlist.title : `${searchResult.tracks[0].title} - ${searchResult.tracks[0].author}`,
}),
}); });
} }
interaction.editReply({
content: interaction.translate("music/play:ADDED_QUEUE", {
songName: searchResult.hasPlaylist() ? searchResult.playlist.title : searchResult.tracks[0].title,
}),
});
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").AutocompleteInteraction} interaction * @param {import("discord.js").AutocompleteInteraction} interaction
* @returns * @returns
*/ */
async autocompleteRun(client, interaction) { async autocompleteRun(client, interaction) {
const query = interaction.options.getString("query"); const query = interaction.options.getString("query");
if (query.includes("http") || query === "") return;
if (query === "") return; const results = await client.player.search(query);
if (query.startsWith("http"))
return interaction.respond([
{
name: "Current link",
value: query,
},
]);
const youtubeResults = await client.player.search(query, { searchEngine: QueryType.YOUTUBE }); return interaction.respond(
const spotifyResults = await client.player.search(query, { searchEngine: QueryType.SPOTIFY_SEARCH }); results.tracks.slice(0, 10).map(track => ({
const tracks = []; name: (`${track.author} - ${track.title}`.length >= 100 & `${track.author} - ${track.title}`.slice(0, 90) + "...") || `${track.author} - ${track.title}`,
value: track.url,
youtubeResults.tracks }),
.slice(0, 5) ));
.map(t => ({
name: `YouTube: ${`${t.title} - ${t.author} (${t.duration})`.length > 75 ? `${`${t.title} - ${t.author}`.substring(0, 75)}... (${t.duration})` : `${t.title} - ${t.author} (${t.duration})`}`,
value: t.url,
}))
.forEach(t => tracks.push({ name: t.name, value: t.value }));
spotifyResults.tracks
.slice(0, 5)
.map(t => ({
name: `Spotify: ${`${t.title} - ${t.author} (${t.duration})`.length > 75 ? `${`${t.title} - ${t.author}`.substring(0, 75)}... (${t.duration})` : `${t.title} - ${t.author} (${t.duration})`}`,
value: t.url,
}))
.forEach(t => tracks.push({ name: t.name, value: t.value }));
return interaction.respond(tracks);
} }
} }
module.exports = Play; module.exports = Play;

View file

@ -1,10 +1,11 @@
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"),
{ QueueRepeatMode } = require("discord-player");
const BaseCommand = require("../../base/BaseCommand"); const BaseCommand = require("../../base/BaseCommand");
class Queue extends BaseCommand { class Queue extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,139 +13,141 @@ class Queue extends BaseCommand {
.setName("queue") .setName("queue")
.setDescription(client.translate("music/queue:DESCRIPTION")) .setDescription(client.translate("music/queue:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/queue:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/queue:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/queue:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/queue:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
async onLoad(client) { async onLoad() {
client.on("interactionCreate", async interaction => { //...
if (!interaction.isButton()) return;
if (interaction.customId.startsWith("queue_")) {
interaction.data = [];
interaction.data.guld = await client.findOrCreateGuild(interaction.guildId);
const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
const { embeds, size } = generateQueueEmbeds(interaction, queue);
let currentPage = Number(interaction.message.content.match(/\d+/g)[0]) - 1 ?? 0;
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId("queue_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"),
new ButtonBuilder().setCustomId("queue_next_page").setStyle(ButtonStyle.Primary).setEmoji("➡️"),
new ButtonBuilder().setCustomId("queue_jump_page").setStyle(ButtonStyle.Secondary).setEmoji("↗️"),
new ButtonBuilder().setCustomId("queue_stop").setStyle(ButtonStyle.Danger).setEmoji("❌"),
);
if (interaction.customId === "queue_prev_page") {
await interaction.deferUpdate();
if (currentPage !== 0) {
--currentPage;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${size}**`,
embeds: [embeds[currentPage]],
components: [row],
});
}
} else if (interaction.customId === "queue_next_page") {
await interaction.deferUpdate();
if (currentPage < size - 1) {
currentPage++;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${size}**`,
embeds: [embeds[currentPage]],
components: [row],
});
}
} else if (interaction.customId === "queue_jump_page") {
await interaction.deferUpdate();
const selectMenu = new StringSelectMenuBuilder()
.setCustomId("queue_select")
.setPlaceholder(interaction.translate("common:NOTHING_SELECTED"));
for (let i = 0; i < size; i++) {
selectMenu.addOptions(
new StringSelectMenuOptionBuilder()
.setLabel(`${i + 1}`)
.setValue(`${i}`),
);
}
const selectRow = new ActionRowBuilder().addComponents(selectMenu),
msg = await interaction.followUp({
components: [selectRow],
ephemeral: true,
});
const filter = i => i.user.id === interaction.user.id,
collected = await msg.awaitMessageComponent({ filter, time: 10 * 1000 }),
page = Number(collected.values[0]);
await collected.deferUpdate();
return interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${page + 1}**/**${size}**`,
embeds: [embeds[page]],
components: [row],
});
} else if (interaction.customId === "queue_stop") {
await interaction.deferUpdate();
row.components.forEach(component => {
component.setDisabled(true);
});
return interaction.editReply({
components: [row],
});
}
}
});
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const queue = client.player.nodes.get(interaction.guildId); const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING"); if (!queue) return interaction.error("music/play:NOT_PLAYING");
const { embeds, size } = generateQueueEmbeds(interaction, queue), let currentPage = 0;
row = new ActionRowBuilder().addComponents( let embeds = generateQueueEmbeds(interaction, queue);
new ButtonBuilder().setCustomId("queue_prev_page").setStyle(ButtonStyle.Primary).setEmoji("⬅️"),
new ButtonBuilder().setCustomId("queue_next_page").setStyle(ButtonStyle.Primary).setEmoji("➡️"), const row = new ActionRowBuilder()
new ButtonBuilder().setCustomId("queue_jump_page").setStyle(ButtonStyle.Secondary).setEmoji("↗️"), .addComponents(
new ButtonBuilder().setCustomId("queue_stop").setStyle(ButtonStyle.Danger).setEmoji("❌"), new ButtonBuilder()
.setCustomId("queue_prev_page")
.setLabel(interaction.translate("music/queue:PREV_PAGE"))
.setStyle(ButtonStyle.Primary)
.setEmoji("⬅️"),
new ButtonBuilder()
.setCustomId("queue_next_page")
.setLabel(interaction.translate("music/queue:NEXT_PAGE"))
.setStyle(ButtonStyle.Primary)
.setEmoji("➡️"),
new ButtonBuilder()
.setCustomId("queue_jump_page")
.setLabel(interaction.translate("music/queue:JUMP_PAGE"))
.setStyle(ButtonStyle.Secondary)
.setEmoji("↗️"),
new ButtonBuilder()
.setCustomId("queue_stop")
.setLabel(interaction.translate("common:CANCEL"))
.setStyle(ButtonStyle.Danger)
.setEmoji("⏹️"),
); );
if (interaction.customId) return await interaction.followUp({ await interaction.reply({
content: `${interaction.translate("common:PAGE")}: **1**/**${size}**`, content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[0]], embeds: [embeds[currentPage]],
components: [row], components: [row],
}); });
await interaction.reply({ const filter = i => i.user.id === interaction.user.id;
content: `${interaction.translate("common:PAGE")}: **1**/**${size}**`, const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (20 * 1000) });
embeds: [embeds[0]],
components: [row], collector.on("collect", async i => {
if (i.isButton()) {
if (i.customId === "queue_prev_page") {
i.deferUpdate();
if (embeds != generateQueueEmbeds(interaction, queue)) embeds = generateQueueEmbeds(interaction, queue);
if (currentPage !== 0) {
--currentPage;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[currentPage]],
components: [row],
});
}
} else if (i.customId === "queue_next_page") {
i.deferUpdate();
if (embeds != generateQueueEmbeds(interaction, queue)) embeds = generateQueueEmbeds(interaction, queue);
if (currentPage < embeds.length - 1) {
currentPage++;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[currentPage]],
components: [row],
});
}
} else if (i.customId === "queue_jump_page") {
i.deferUpdate();
if (embeds != generateQueueEmbeds(interaction, queue)) embeds = generateQueueEmbeds(interaction, queue);
const msg = await interaction.followUp({
content: interaction.translate("misc:JUMP_TO_PAGE", {
length: embeds.length,
}),
fetchReply: true,
});
const filter = res => {
return res.author.id === interaction.user.id && !isNaN(res.content);
};
interaction.channel.awaitMessages({ filter, max: 1, time: (10 * 1000) }).then(collected => {
if (embeds[collected.first().content - 1]) {
currentPage = collected.first().content - 1;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[currentPage]],
components: [row],
});
if (collected.first().deletable) collected.first().delete();
if (msg.deletable) msg.delete();
} else {
if (collected.first().deletable) collected.first().delete();
if (msg.deletable) msg.delete();
return;
}
});
} else if (i.customId === "queue_stop") {
i.deferUpdate();
collector.stop();
}
}
});
collector.on("end", () => {
row.components.forEach(component => {
component.setDisabled(true);
});
return interaction.editReply({
components: [row],
});
}); });
} }
} }
@ -156,29 +159,24 @@ class Queue extends BaseCommand {
* @returns * @returns
*/ */
function generateQueueEmbeds(interaction, queue) { function generateQueueEmbeds(interaction, queue) {
const embeds = [], const embeds = [];
currentTrack = queue.currentTrack, const currentTrack = queue.currentTrack;
translated = {
"3": interaction.translate("music/loop:AUTOPLAY"),
"2": interaction.translate("music/loop:QUEUE"),
"1": interaction.translate("music/loop:TRACK"),
"0": interaction.translate("common:DISABLED"),
};
let k = 10; let k = 10;
if (!queue.tracks.size) { if (!queue.tracks.size) {
const embed = interaction.client.embed({ const embed = new EmbedBuilder()
title: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"), .setTitle(interaction.translate("music/nowplaying:CURRENTLY_PLAYING"))
thumbnail: currentTrack.thumbnail || null, .setThumbnail(currentTrack.thumbnail)
description: `${interaction.translate("music/nowplaying:REPEAT")}: \`${translated[queue.repeatMode]}\`\n${ .setColor(interaction.client.config.embed.color)
currentTrack.url.startsWith("./clips") ? `${currentTrack.title} (clips)` : `[${currentTrack.title}](${currentTrack.url})` .setDescription(`${interaction.translate("music/nowplaying:REPEAT")}: \`${
}\n> ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}\n\n**${interaction.translate("music/queue:NEXT")}**\n${interaction.translate("music/queue:NO_QUEUE")}`, 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")
}\`\n${currentTrack.url.startsWith("./clips") ? `${currentTrack.title} (clips)` : `[${currentTrack.title}](${currentTrack.url})`}\n> ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}\n\n**${interaction.translate("music/queue:NEXT")}**\n${interaction.translate("music/queue:NO_QUEUE")}`)
.setTimestamp();
embeds.push(embed); embeds.push(embed);
return { embeds: embeds, size: embeds.length }; return embeds;
} }
for (let i = 0; i < queue.getSize(); i += 10) { for (let i = 0; i < queue.getSize(); i += 10) {
@ -188,18 +186,20 @@ function generateQueueEmbeds(interaction, queue) {
const info = current.map(track => `${++j}. ${track.url.startsWith("./clips") ? `${track.title} (clips)` : `[${track.title}](${track.url})`}\n> ${interaction.translate("music/queue:ADDED")} ${track.requestedBy}`).join("\n"); const info = current.map(track => `${++j}. ${track.url.startsWith("./clips") ? `${track.title} (clips)` : `[${track.title}](${track.url})`}\n> ${interaction.translate("music/queue:ADDED")} ${track.requestedBy}`).join("\n");
const embed = interaction.client.embed({ const embed = new EmbedBuilder()
title: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"), .setTitle(interaction.translate("music/nowplaying:CURRENTLY_PLAYING"))
thumbnail: currentTrack.thumbnail || null, .setThumbnail(currentTrack.thumbnail)
description: `${interaction.translate("music/nowplaying:REPEAT")}: \`${translated[queue.repeatMode]}\`\n${ .setColor(interaction.client.config.embed.color)
currentTrack.url.startsWith("./clips") ? `${currentTrack.title} (clips)` : `[${currentTrack.title}](${currentTrack.url})` .setDescription(`${interaction.translate("music/nowplaying:REPEAT")}: \`${
}\n * ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}\n\n**${interaction.translate("music/queue:NEXT")}**\n${info}`, 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")
}\`\n${currentTrack.url.startsWith("./clips") ? `${currentTrack.title} (clips)` : `[${currentTrack.title}](${currentTrack.url})`}\n> ${interaction.translate("music/queue:ADDED")} ${currentTrack.requestedBy}\n\n**${interaction.translate("music/queue:NEXT")}**\n${info}`)
.setTimestamp();
embeds.push(embed); embeds.push(embed);
} }
return { embeds: embeds, size: embeds.length }; return embeds;
} }
module.exports = Queue; module.exports = Queue;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Seek extends BaseCommand { class Seek extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,28 +12,33 @@ class Seek extends BaseCommand {
.setName("seek") .setName("seek")
.setDescription(client.translate("music/seek:DESCRIPTION")) .setDescription(client.translate("music/seek:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/seek:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/seek:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/seek:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/seek:DESCRIPTION", null, "ru-RU"),
}) })
.addIntegerOption(option => .addIntegerOption(option => option.setName("time")
option .setDescription(client.translate("music/seek:TIME"))
.setName("time") .setDescriptionLocalizations({
.setDescription(client.translate("music/seek:TIME")) "uk": client.translate("music/seek:TIME", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("music/seek:TIME", null, "ru-RU"),
uk: client.translate("music/seek:TIME", null, "uk-UA"), })
ru: client.translate("music/seek:TIME", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const time = interaction.options.getInteger("time"), const time = interaction.options.getInteger("time"),
@ -50,4 +55,4 @@ class Seek extends BaseCommand {
} }
} }
module.exports = Seek; module.exports = Seek;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Shuffle extends BaseCommand { class Shuffle extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,19 +12,27 @@ class Shuffle extends BaseCommand {
.setName("shuffle") .setName("shuffle")
.setDescription(client.translate("music/shuffle:DESCRIPTION")) .setDescription(client.translate("music/shuffle:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/shuffle:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/shuffle:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/shuffle:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/shuffle:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
@ -38,4 +46,4 @@ class Shuffle extends BaseCommand {
} }
} }
module.exports = Shuffle; module.exports = Shuffle;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Skip extends BaseCommand { class Skip extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,19 +12,27 @@ class Skip extends BaseCommand {
.setName("skip") .setName("skip")
.setDescription(client.translate("music/skip:DESCRIPTION")) .setDescription(client.translate("music/skip:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/skip:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/skip:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/skip:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/skip:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
@ -38,4 +46,4 @@ class Skip extends BaseCommand {
} }
} }
module.exports = Skip; module.exports = Skip;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Skipto extends BaseCommand { class Skipto extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,29 +12,34 @@ class Skipto extends BaseCommand {
.setName("skipto") .setName("skipto")
.setDescription(client.translate("music/skipto:DESCRIPTION")) .setDescription(client.translate("music/skipto:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/skipto:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/skipto:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/skipto:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/skipto:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addIntegerOption(option => .addIntegerOption(option => option.setName("position")
option .setDescription(client.translate("music/skipto:POSITION"))
.setName("position") .setDescriptionLocalizations({
.setDescription(client.translate("music/skipto:POSITION")) "uk": client.translate("music/skipto:POSITION", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("music/skipto:POSITION", null, "ru-RU"),
uk: client.translate("music/skipto:POSITION", null, "uk-UA"), })
ru: client.translate("music/skipto:POSITION", null, "ru-RU"), .setRequired(true)),
}) aliases: [],
.setRequired(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
@ -50,10 +55,10 @@ class Skipto extends BaseCommand {
queue.node.skipTo(queue.tracks.at(position - 1)); queue.node.skipTo(queue.tracks.at(position - 1));
interaction.success("music/skipto:SUCCESS", { interaction.success("music/skipto:SUCCESS", {
track: queue.tracks.at(0).title, position,
}); });
} else return interaction.error("music/skipto:ERROR", { position }); } else return interaction.error("music/skipto:ERROR", { position: position });
} }
} }
module.exports = Skipto; module.exports = Skipto;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Stop extends BaseCommand { class Stop extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,19 +12,27 @@ class Stop extends BaseCommand {
.setName("stop") .setName("stop")
.setDescription(client.translate("music/stop:DESCRIPTION")) .setDescription(client.translate("music/stop:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/stop:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/stop:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/stop:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/stop:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false), .setDMPermission(false),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
@ -38,4 +46,4 @@ class Stop extends BaseCommand {
} }
} }
module.exports = Stop; module.exports = Stop;

View file

@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
class Volume extends BaseCommand { class Volume extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -12,30 +12,35 @@ class Volume extends BaseCommand {
.setName("volume") .setName("volume")
.setDescription(client.translate("music/volume:DESCRIPTION")) .setDescription(client.translate("music/volume:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("music/volume:DESCRIPTION", null, "uk-UA"), "uk": client.translate("music/volume:DESCRIPTION", null, "uk-UA"),
ru: client.translate("music/volume:DESCRIPTION", null, "ru-RU"), "ru": client.translate("music/volume:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(false) .setDMPermission(false)
.addIntegerOption(option => .addIntegerOption(option => option.setName("int")
option .setDescription(client.translate("common:INT"))
.setName("int") .setDescriptionLocalizations({
.setDescription(client.translate("common:INT")) "uk": client.translate("common:INT", null, "uk-UA"),
.setDescriptionLocalizations({ "ru": client.translate("common:INT", null, "ru-RU"),
uk: client.translate("common:INT", null, "uk-UA"), })
ru: client.translate("common:INT", null, "ru-RU"), .setRequired(true)
}) .setAutocomplete(true)),
.setRequired(true) aliases: [],
.setAutocomplete(true),
),
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/
async onLoad() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
const voice = interaction.member.voice.channel; const voice = interaction.member.voice.channel;
@ -55,7 +60,7 @@ class Volume extends BaseCommand {
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").AutocompleteInteraction} interaction * @param {import("discord.js").AutocompleteInteraction} interaction
* @returns * @returns
*/ */
@ -63,13 +68,13 @@ class Volume extends BaseCommand {
const int = interaction.options.getInteger("int"), const int = interaction.options.getInteger("int"),
results = Array.from({ length: 100 }, (_, k) => k + 1).filter(i => i.toString().includes(int)); results = Array.from({ length: 100 }, (_, k) => k + 1).filter(i => i.toString().includes(int));
return await interaction.respond( return interaction.respond(
results.slice(0, 25).map(i => ({ results.slice(0, 25).map(i => ({
name: i, name: i,
value: i, value: i,
})), }),
); ));
} }
} }
module.exports = Volume; module.exports = Volume;

View file

@ -1,11 +1,11 @@
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder, AttachmentBuilder } = require("discord.js"); const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand"), const BaseCommand = require("../../base/BaseCommand"),
fetch = require("node-fetch"); fetch = require("node-fetch");
class NSFW extends BaseCommand { class NSFW extends BaseCommand {
/** /**
* *
* @param {import("../base/Client")} client * @param {import("../base/JaBa")} client
*/ */
constructor(client) { constructor(client) {
super({ super({
@ -13,74 +13,87 @@ class NSFW extends BaseCommand {
.setName("nsfw") .setName("nsfw")
.setDescription(client.translate("nsfw/nsfw:DESCRIPTION")) .setDescription(client.translate("nsfw/nsfw:DESCRIPTION"))
.setDescriptionLocalizations({ .setDescriptionLocalizations({
uk: client.translate("nsfw/nsfw:DESCRIPTION", null, "uk-UA"), "uk": client.translate("nsfw/nsfw:DESCRIPTION", null, "uk-UA"),
ru: client.translate("nsfw/nsfw:DESCRIPTION", null, "ru-RU"), "ru": client.translate("nsfw/nsfw:DESCRIPTION", null, "ru-RU"),
}) })
.setDMPermission(true), .setDMPermission(true),
aliases: [],
dirname: __dirname, dirname: __dirname,
ownerOnly: false, ownerOnly: false,
}); });
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
*/ */
async onLoad(client) { async onLoad() {
client.on("interactionCreate", async interaction => { //...
if (!interaction.isStringSelectMenu()) return;
if (interaction.customId === "nsfw_select") {
await interaction.deferUpdate();
interaction.data = [];
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
const tag = interaction?.values[0],
splitted = tag.split("_"),
res = await fetch(`https://nsfw-api.jababot.ru/media/${splitted[0].charAt(0).toLowerCase()}/${splitted[1].toLowerCase()}`).then(async r => await r.buffer()),
image = new AttachmentBuilder(res, { name: "image.jpeg" });
const embed = client.embed({
image: "attachment://image.jpeg",
});
await interaction.editReply({
embeds: [embed],
files: [image],
});
}
});
} }
/** /**
* *
* @param {import("../../base/Client")} client * @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction * @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/ */
async execute(client, interaction) { async execute(client, interaction) {
await interaction.deferReply({ ephemeral: true }); await interaction.deferReply({ ephemeral: true });
if (interaction.guild && !interaction.channel.nsfw) return interaction.error("misc:NSFW_COMMAND", null, { edit: true, ephemeral: true }); if (interaction.guildId && !interaction.channel.nsfw) return interaction.replyT("misc:NSFW_COMMAND", null, { edit: true });
const tags = ["Hentai_Vanila", "Hentai_Yaoi", "Hentai_Yuri", "Hentai_BDSM", "Hentai_Trap", "Real_Ass", "Real_Boobs", "Real_Pussy"] const tags = ["hentai", "ecchi", "lewdanimegirls", "hentaifemdom", "animefeets", "animebooty", "biganimetiddies", "sideoppai", "ahegao"].map(tag =>
.map(tag => JSON.parse(JSON.stringify({
JSON.parse( label: tag,
JSON.stringify({ value: tag,
label: `(${tag.split("_")[0]}) ${tag.split("_")[1]}`, })),
value: tag, );
}),
), const row = new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId("nsfw_select")
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
.addOptions(tags),
); );
const row = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder().setCustomId("nsfw_select").setPlaceholder(interaction.translate("common:NOTHING_SELECTED")).addOptions(tags.slice(0, 25))); const msg = await interaction.editReply({
await interaction.editReply({
content: interaction.translate("common:AVAILABLE_OPTIONS"), content: interaction.translate("common:AVAILABLE_OPTIONS"),
ephemeral: true, ephemeral: true,
fetchReply: true,
components: [row], components: [row],
}); });
const filter = i => i.user.id === interaction.user.id;
const collector = msg.createMessageComponentCollector({ filter, idle: (2 * 60 * 1000) });
collector.on("collect", async i => {
if (i.isStringSelectMenu() && i.customId === "nsfw_select") {
i.deferUpdate();
const tag = i?.values[0];
const res = await fetch(`https://meme-api.com/gimme/${tag}`).then(response => response.json());
const embed = new EmbedBuilder()
.setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
})
.setTitle(res.title)
.setDescription(`${interaction.translate("fun/memes:SUBREDDIT")}: **${res.subreddit}**\n${interaction.translate("common:AUTHOR")}: **${res.author}**\n${interaction.translate("fun/memes:UPS")}: **${res.ups}**`)
.setImage(res.url)
.setTimestamp();
await interaction.editReply({
embeds: [embed],
});
}
});
collector.on("end", () => {
return interaction.editReply({
components: [],
});
});
} }
} }
module.exports = NSFW; module.exports = NSFW;

View file

@ -0,0 +1,93 @@
const { SlashCommandBuilder, EmbedBuilder, ChannelType } = require("discord.js");
const BaseCommand = require("../../base/BaseCommand");
class Announcement extends BaseCommand {
/**
*
* @param {import("../base/JaBa")} client
*/
constructor(client) {
super({
command: new SlashCommandBuilder()
.setName("announcement")
.setDescription(client.translate("owner/announcement:DESCRIPTION"))
.setDescriptionLocalizations({
"uk": client.translate("owner/announcement:DESCRIPTION", null, "uk-UA"),
"ru": client.translate("owner/announcement:DESCRIPTION", null, "ru-RU"),
})
.setDMPermission(true)
.addStringOption(option => option.setName("message")
.setDescription(client.translate("common:MESSAGE"))
.setDescriptionLocalizations({
"uk": client.translate("common:MESSAGE", null, "uk-UA"),
"ru": client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true))
.addBooleanOption(option => option.setName("tag")
.setDescription(client.translate("owner/announcement:TAG"))
.setDescriptionLocalizations({
"uk": client.translate("owner/announcement:TAG", null, "uk-UA"),
"ru": client.translate("owner/announcement:TAG", null, "ru-RU"),
})
.setRequired(true))
.addBooleanOption(option => option.setName("important")
.setDescription(client.translate("owner/announcement:IMPORTANT"))
.setDescriptionLocalizations({
"uk": client.translate("owner/announcement:IMPORTANT", null, "uk-UA"),
"ru": client.translate("owner/announcement:IMPORTANT", null, "ru-RU"),
})),
aliases: [],
dirname: __dirname,
ownerOnly: true,
});
}
/**
*
* @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({ ephemeral: true });
const text = interaction.options.getString("message"),
important = interaction.options.getBoolean("important");
if (text.length > 1000) return interaction.error("owner/announcement:TOO_LONG");
const embed = new EmbedBuilder()
.setAuthor({
name: interaction.translate("owner/announcement:TITLE"),
})
.setDescription(text)
.setColor(client.config.embed.color)
.setFooter({
text: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
})
.setTimestamp();
(await client.guilds.fetch()).forEach(async guild => {
if (guild.id === "568120814776614924") return;
guild = await guild.fetch();
const channel = important ? (guild?.data?.plugins.news ? guild.channels.cache.get(guild?.data?.plugins.news) : guild.channels.cache.find(c => c.type === ChannelType.GuildText)) : guild.channels.cache.get(guild?.data?.plugins.news);
channel.send({
content: `${interaction.options.getBoolean("tag") ? "||@everyone|| " : ""}ВАЖНОЕ ОБЪЯВЛЕНИЕ!`,
embeds: [embed],
});
});
interaction.editReply({
content: interaction.translate("owner/announcement:SENDED"),
ephemeral: true,
});
}
}
module.exports = Announcement;

Some files were not shown because too many files have changed in this diff Show more