Compare commits
206 commits
aa5d328d38
...
e6f239894f
Author | SHA1 | Date | |
---|---|---|---|
e6f239894f | |||
9b4b150643 | |||
dcdaf66b76 | |||
321189f285 | |||
2cd08d3151 | |||
b0cdd9b2c9 | |||
5a7a22c558 | |||
3896ee27da | |||
7618492300 | |||
b1d1c5a0ab | |||
07658d64d2 | |||
e65d9adbe1 | |||
cf4f510e82 | |||
784f3e966a | |||
|
f76a199789 | ||
e3c4edfc2c | |||
|
39df50b877 | ||
|
5ae0d289e1 | ||
|
00d63d01b0 | ||
|
7130632844 | ||
|
91d1e37be0 | ||
|
b9d7dfa51c | ||
|
8766a10469 | ||
|
1128269023 | ||
|
6479d434a7 | ||
|
0cde8ee856 | ||
|
8afa53d9b7 | ||
|
235621afd1 | ||
|
da3ece57b4 | ||
|
589ea22619 | ||
|
1ff8784066 | ||
|
cc0fd759f7 | ||
|
427e1c6ae2 | ||
|
c96d298f14 | ||
|
e012981ef9 | ||
|
d36394898e | ||
|
91d7849902 | ||
|
1cb6a8796b | ||
|
ac636b2da3 | ||
|
8c139da4c2 | ||
|
8265e1ad8d | ||
|
79ec7b4e59 | ||
|
70a37c9ea0 | ||
|
20b438fb5d | ||
|
b82a51b6bc | ||
|
e9855591b2 | ||
|
57b4acc540 | ||
|
f33ff35e4b | ||
|
8353cf0461 | ||
|
aec6ec7c58 | ||
|
33f842088b | ||
|
e67ce7cd53 | ||
|
e5737c4f95 | ||
|
51a5e3e99b | ||
|
59b191aadc | ||
|
a8d8517876 | ||
|
67c53c520d | ||
|
ea3aebe4eb | ||
|
c9d61d0e98 | ||
|
d410aaaa24 | ||
|
a945f42802 | ||
|
87360465d1 | ||
|
b7565115c3 | ||
|
e07da7f183 | ||
|
e5ffa7b622 | ||
|
d3917faa3e | ||
|
44c6de3fa5 | ||
|
dbdc24f9b4 | ||
|
4af141772a | ||
|
7811127db6 | ||
|
c72c7f9023 | ||
|
39f34d45ee | ||
|
8414ef0b83 | ||
|
d2cb694ae8 | ||
|
3a4f854fc0 | ||
|
d47b3bf479 | ||
|
8afc01f648 | ||
|
6774804543 | ||
|
21d049dca8 | ||
|
cb7e3ffd92 | ||
|
8513fb4326 | ||
|
a9edce1b75 | ||
|
82a92f0caa | ||
|
efdab69651 | ||
|
bf3e6065c3 | ||
|
0c7e731a9c | ||
|
58844d4873 | ||
|
8e2c5bedad | ||
|
5d8dc531bb | ||
|
113f4ae3e0 | ||
|
3410fb2091 | ||
|
444a537f11 | ||
|
7a0a34cb98 | ||
|
b900207c44 | ||
|
f1366cc9ec | ||
|
f7c1245f61 | ||
|
46d4ee82ca | ||
|
f628812c1c | ||
|
3674666396 | ||
|
c9c4c62d3b | ||
|
101b3e86c6 | ||
|
8ba0e62308 | ||
|
01f64d474c | ||
|
051a033545 | ||
|
7019dc3d98 | ||
|
3000f7277b | ||
|
abd5ce6146 | ||
|
ecc9729d4b | ||
|
658499b47e | ||
|
eb84a3e664 | ||
|
92f64e4d94 | ||
|
19a58a9748 | ||
|
c620e492c9 | ||
|
89ce374f37 | ||
|
7b9549f883 | ||
|
04bb802cc5 | ||
|
83414e817a | ||
|
b6ee119e3d | ||
|
be634fa563 | ||
|
ceb2aebc5e | ||
|
e33eb197f4 | ||
|
035c4fed34 | ||
|
4b4e7cab16 | ||
|
42d70b3dd7 | ||
|
0d5ddc5fca | ||
|
222fa65371 | ||
|
e10ca0ae74 | ||
|
48d5754727 | ||
|
92d5ad0e71 | ||
|
c16ab0d6a5 | ||
|
e5dcf03f95 | ||
|
d61d8e28df | ||
|
0c8ad6ce27 | ||
|
e8a7d9670f | ||
|
eb934a37c3 | ||
|
ce30dae7fa | ||
|
f2fb1c57bf | ||
|
35def3cf7c | ||
|
7d0680d5aa | ||
|
e89e53ef58 | ||
|
77d1101808 | ||
|
11284a1996 | ||
|
cdc3f3fd3c | ||
|
a2640556cc | ||
|
1574ac78d9 | ||
|
2e119b9219 | ||
|
2ca991cb39 | ||
|
d95e3a6ec5 | ||
|
c22ec58fe1 | ||
|
7103692052 | ||
|
0ac8ecddac | ||
|
02e31e8d9a | ||
|
4d9ed056a7 | ||
|
741fd8d3d5 | ||
|
e4e5e6b03f | ||
|
a185f50dba | ||
|
78cfdb92a8 | ||
|
cea32c0deb | ||
|
00b37379f5 | ||
|
c088c9f414 | ||
|
053bf14ae5 | ||
|
aaa0d01c54 | ||
|
c3dca64be4 | ||
|
0fb732b1d0 | ||
|
aa2a18d529 | ||
|
d28b604f89 | ||
|
45c7b93cf0 | ||
|
2ab201e1c1 | ||
|
ac641f9c28 | ||
|
9f0d8007e8 | ||
|
5219a47b91 | ||
|
2d53c61608 | ||
|
b87d63c327 | ||
|
0e204528d0 | ||
|
776be20851 | ||
|
f56975d1a8 | ||
|
ec79480bcb | ||
|
76e8d16eb1 | ||
|
55a4734926 | ||
|
97f4ef5590 | ||
|
006342a9da | ||
|
030f725777 | ||
|
3aca11ebb3 | ||
|
7174722160 | ||
|
f1eca51313 | ||
|
8fe40285e8 | ||
|
5009261839 | ||
|
740bc9501c | ||
|
4f1774af84 | ||
|
d6758e9112 | ||
|
885d4ec3cc | ||
|
64ad5bf56f | ||
|
93c1db265e | ||
|
e91d0725d1 | ||
|
97898d88b1 | ||
|
8b304539ee | ||
|
14059cab22 | ||
|
0a899d1627 | ||
|
da2a27bc85 | ||
|
7ace802d3e | ||
|
939252c072 | ||
|
b7e7ad6c40 | ||
|
ebfa1b9ae1 | ||
|
d325e40e49 | ||
|
8edc8ffc88 | ||
|
fa62deb39b |
27
.gitignore
vendored
|
@ -1,28 +1,21 @@
|
|||
# Trash
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Bot Configuration
|
||||
/config.js
|
||||
|
||||
# DB
|
||||
/giveaways.json
|
||||
|
||||
# commands.md
|
||||
**/commands.md
|
||||
|
||||
# Data
|
||||
/.data
|
||||
|
||||
# Clips
|
||||
/clips
|
||||
|
||||
# Mac OS files
|
||||
.DS_Store
|
||||
|
||||
# IDE
|
||||
.vscode
|
||||
/clips/*
|
||||
|
||||
# Node
|
||||
package-lock.json
|
||||
node_modules
|
||||
yarn.lock
|
||||
|
||||
# Backups
|
||||
/.backup
|
||||
# Dashboard DB
|
||||
/json.sqlite
|
||||
|
||||
# Cookies
|
||||
cookies.json
|
4
.gitmodules
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
[submodule "dashboard/dashboard-core"]
|
||||
path = dashboard/dashboard-core
|
||||
url = https://git.jonnybro.ru/jonny_bro/dashboard-core
|
||||
branch = main
|
11
.prettierrc
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"arrowParens": "avoid",
|
||||
"bracketSpacing": true,
|
||||
"endOfLine": "lf",
|
||||
"printWidth": 250,
|
||||
"semi": true,
|
||||
"tabWidth": 4,
|
||||
"trailingComma": "all",
|
||||
"useTabs": true,
|
||||
"parser": "babel"
|
||||
}
|
111
README.md
|
@ -1,66 +1,71 @@
|
|||
<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">
|
||||
<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">
|
||||
|
||||
# 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
|
||||
|
||||
## Функционал
|
||||
### Готовый бот
|
||||
JaBa предлагает:
|
||||
* **/** Поддержка слэш-команд
|
||||
* ✉️ Поддержка команд в личных сообщениях
|
||||
* 🇷🇺 Поддержка локализации (любое кол-во языков)
|
||||
* ⚙️ Панель управления для настройки разнообразных параметров бота, для каждого сервера отдельно<br>
|
||||
[![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)
|
||||
[![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).
|
||||
|
||||
### Множество команд
|
||||
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** команды!
|
||||
## Functionality
|
||||
|
||||
[Список изменений](/dashboard/public/docs/updates.md)<br>
|
||||
[Полный список команд](http://jababot.duckdns.org:8080/docs)
|
||||
JaBa offers:
|
||||
|
||||
### *Относительно* мощная панель управления
|
||||
У JaBa есть своя панель управления с доступом к настройке параметров сервера и просмотру таблицы лидеров! Панель работает на Express и EJS!
|
||||
<!-- <img align="left" style="float: centrer; margin: 0 10px 0 0;" src="https://zupimages.net/up/19/31/c3ya.png" height="200" width="350"/>
|
||||
<img align="center" style="float: left; margin: 0 10px 0 0;" src="https://zupimages.net/up/19/31/vnq5.png" height="200" width="350"/>
|
||||
<img align="center" style="float: centrer; margin: 0 10px 0 0;" src="https://zupimages.net/up/19/31/htga.png" height="200" width="350"/> -->
|
||||
* Slash and Context commands.
|
||||
* Supports commands in DMs.
|
||||
* Localization support (any language; English, Russian and Ukrainian for now).
|
||||
* Dashboard for changing various settings.
|
||||
* Basic messages monitoring (updating and deletion).
|
||||
|
||||
Вы можете **настраивать параметры** каждого сервера где есть JaBa (вы должны иметь права администратора), **просматривать таблицу лидеров**, **управлять своим профилем**!
|
||||
> Код панели находится в папке dashboard!
|
||||
## Commands
|
||||
|
||||
## Установка
|
||||
### Приглашение бота
|
||||
Вы можете пригласить JaBa на свой сервер, для этого вам нужно написать @Jonny_Bro#4226 в Discord или найти @JaBa#9042 на другом сервере.
|
||||
Я решил сделать так, чтобы не было проблем с YouTube!<br><br>
|
||||
### Хост своей версии
|
||||
Вы можете модифицировать код JaBa и запустить его на своей машине!<br>
|
||||
Для этого следуйте [данной инструкции](https://github.com/JonnyBro/JaBa/wiki/Установка-JaBa-на-своей-машине)!
|
||||
JaBa does many thing, here is **8 main categories**:
|
||||
|
||||
## Ссылки
|
||||
* [Список команд и список изменений](http://jababot.duckdns.org/docs)
|
||||
* [Инструкция по установке](https://github.com/JonnyBro/JaBa/wiki/Установка-JaBa-на-своей-машине)
|
||||
* [Discord](https://discord.gg/Ptkj2n9nzZ)
|
||||
* [Github](https://github.com/JonnyBro/JaBa/)
|
||||
* [Панель управления](http://jababot.duckdns.org)
|
||||
* **Administration**: `automod`, `autorole`, `config`, `goodbye`, `selectroles`, `stealemoji` and **3** more!
|
||||
* **Moderation**: `clear`, `giveaway`, `poll`, `warn` and **4** more!
|
||||
* **Music**: `play`, `skip`, `queue`, `nowplaying`, `shuffle` and **8** more!
|
||||
* **Economy**: `profile`, `work`, `achievements`, `slots`, `tictactoe`, `leaderboard` and **9** more!
|
||||
* **Fun**: `8ball`, `crab`, `lmgtfy`, `lovecalc`, `memes` and **2** more!
|
||||
* **General**: `afk`, `avatar`, `boosters`, `minecraft`, `remindme`, `shorturl`, `serverinfo`, `userinfo`, `whois` and **7** more!
|
||||
* **NSFW**: `nsfw` =)
|
||||
* **Bot's owner commands**: `eval`, `servers`, `reload` and **2** more!
|
||||
|
||||
## Поддержка
|
||||
Перед **созданием сообщения об ошибке или вопросе**, пожалуйста, убедитесь что оно ещё не создано: [тык](https://github.com/JonnyBro/JaBa/issues).
|
||||
Если у вас есть какие-либо вопросы, вы можете задать их на моём [Discord сервере](https://discord.gg/NPkySYKMkN).
|
||||
Если вы хотите помочь в разработке, можете создать форк и отправить запрос на вытягивание: [тык](https://github.com/JonnyBro/JaBa/pulls)!
|
||||
## *Kinda* Cool Dashboard
|
||||
|
||||
JaBa has it's own dashboard to change server's settings!
|
||||
|
||||
## 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
|
||||
- [ ] Починить панель управления 😣
|
||||
|
||||
## Лицения
|
||||
JaBa использует лицензию *GNU GPL v3.0*. Вся информация о лицензии имеется в [LICENSE](https://github.com/JonnyBro/JaBa/blob/main/LICENSE)
|
||||
* [ ] Finish and release *dashboard-core* submodule.
|
||||
|
||||
## License
|
||||
|
||||
JaBa uses *GNU GPL v3.0* license. You can find it here [LICENSE](LICENSE).
|
||||
|
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 22 KiB |
BIN
assets/img/b.png
Before Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 210 KiB |
Before Width: | Height: | Size: 21 KiB |
|
@ -7,10 +7,6 @@ class BaseCommand {
|
|||
* @type {import("discord.js").SlashCommandBuilder | import("discord.js").ContextMenuCommandBuilder | import("discord.js").ApplicationCommandData}
|
||||
*/
|
||||
this.command = options.command;
|
||||
/**
|
||||
* @type {Array<String>}
|
||||
*/
|
||||
this.aliases = options.aliases || [];
|
||||
/**
|
||||
* @type {Boolean}
|
||||
*/
|
||||
|
@ -19,8 +15,8 @@ class BaseCommand {
|
|||
/**
|
||||
* @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;
|
||||
|
|
|
@ -11,4 +11,4 @@ class BaseEvent {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = BaseEvent;
|
||||
module.exports = BaseEvent;
|
||||
|
|
376
base/Client.js
Normal file
|
@ -0,0 +1,376 @@
|
|||
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;
|
|
@ -9,35 +9,47 @@ module.exports = mongoose.model("Guild", new Schema({
|
|||
members: [{ type: Schema.Types.ObjectId, ref: "Member" }],
|
||||
|
||||
language: { type: String, default: languages.find(l => l.default).name },
|
||||
plugins: { type: Object, default: {
|
||||
welcome: {
|
||||
enabled: false,
|
||||
message: null,
|
||||
channel: null,
|
||||
withImage: null,
|
||||
plugins: {
|
||||
type: Object,
|
||||
default: {
|
||||
welcome: {
|
||||
enabled: false,
|
||||
message: 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
|
@ -1,345 +0,0 @@
|
|||
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;
|
|
@ -13,15 +13,21 @@ module.exports = mongoose.model("Member", new mongoose.Schema({
|
|||
|
||||
registeredAt: { type: Number, default: Date.now() },
|
||||
|
||||
cooldowns: { type: Object, default: {
|
||||
work: 0,
|
||||
rob: 0,
|
||||
} },
|
||||
cooldowns: {
|
||||
type: Object,
|
||||
default: {
|
||||
work: 0,
|
||||
rob: 0,
|
||||
},
|
||||
},
|
||||
|
||||
sanctions: { type: Array, default: [] },
|
||||
mute: { type: Object, default: {
|
||||
muted: false,
|
||||
case: null,
|
||||
endDate: null,
|
||||
} },
|
||||
}));
|
||||
mute: {
|
||||
type: Object,
|
||||
default: {
|
||||
muted: false,
|
||||
case: null,
|
||||
endDate: null,
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
|
117
base/User.js
|
@ -4,8 +4,7 @@ const mongoose = require("mongoose"),
|
|||
const genToken = () => {
|
||||
let token = "";
|
||||
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;
|
||||
};
|
||||
|
@ -20,61 +19,67 @@ const userSchema = new mongoose.Schema({
|
|||
|
||||
registeredAt: { type: Number, default: Date.now() },
|
||||
|
||||
achievements: { type: Object, default: {
|
||||
married: {
|
||||
achieved: false,
|
||||
progress: {
|
||||
now: 0,
|
||||
total: 1,
|
||||
achievements: {
|
||||
type: Object,
|
||||
default: {
|
||||
married: {
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
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: { type: Object, default: {
|
||||
rep: 0,
|
||||
} },
|
||||
cooldowns: {
|
||||
type: Object,
|
||||
default: {
|
||||
rep: 0,
|
||||
},
|
||||
},
|
||||
|
||||
afk: { type: String, default: null },
|
||||
reminds: { type: Array, default: [] },
|
||||
|
@ -82,7 +87,7 @@ const userSchema = new mongoose.Schema({
|
|||
apiToken: { type: String, default: genToken() },
|
||||
});
|
||||
|
||||
userSchema.method("getAchievements", async function() {
|
||||
userSchema.method("getAchievements", async function () {
|
||||
const canvas = Canvas.createCanvas(1800, 250),
|
||||
ctx = canvas.getContext("2d");
|
||||
|
||||
|
@ -105,4 +110,4 @@ userSchema.method("getAchievements", async function() {
|
|||
return canvas.toBuffer();
|
||||
});
|
||||
|
||||
module.exports = mongoose.model("User", userSchema);
|
||||
module.exports = mongoose.model("User", userSchema);
|
||||
|
|
73
commands/!DISABLED/ban.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
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;
|
|
@ -5,40 +5,39 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class ImportMee6 extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
command: new SlashCommandBuilder()
|
||||
.setName("importmee6")
|
||||
.setDescription(client.translate("economy/importmee6:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({ "uk": client.translate("economy/importmee6:DESCRIPTION", null, "uk-UA") })
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("economy/importmee6:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/importmee6:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const level = (await Mee6Api.getUserXp(interaction.guildId, interaction.member)).level;
|
||||
|
||||
data.memberData.level = level;
|
||||
await data.memberData.save();
|
||||
interaction.data.member.level = level;
|
||||
interaction.data.member.exp = 0;
|
||||
|
||||
interaction.data.member.markModified("level");
|
||||
interaction.data.member.markModified("exp");
|
||||
await interaction.data.member.save();
|
||||
|
||||
interaction.editReply({
|
||||
content: interaction.translate("owner/debug:SUCCESS_LEVEL", {
|
||||
|
@ -49,4 +48,4 @@ class ImportMee6 extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = ImportMee6;
|
||||
module.exports = ImportMee6;
|
||||
|
|
73
commands/!DISABLED/kick.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
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;
|
|
@ -1,11 +1,11 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
fetch = require("node-fetch");
|
||||
|
||||
class Memes extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,84 +13,67 @@ class Memes extends BaseCommand {
|
|||
.setName("memes")
|
||||
.setDescription(client.translate("fun/memes:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/memes:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/memes:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("fun/memes:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/memes:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
async onLoad(client) {
|
||||
client.on("interactionCreate", async interaction => {
|
||||
if (!interaction.isStringSelectMenu()) return;
|
||||
|
||||
const tags = ["funny", "memes", "dankmemes", "me_irl", "wholesomememes"].map(tag =>
|
||||
JSON.parse(JSON.stringify({
|
||||
label: tag,
|
||||
value: tag,
|
||||
})),
|
||||
);
|
||||
if (interaction.customId === "memes_select") {
|
||||
interaction.deferUpdate();
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new StringSelectMenuBuilder()
|
||||
.setCustomId("memes_select")
|
||||
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
|
||||
.addOptions(tags),
|
||||
);
|
||||
interaction.guild.data = await client.findOrCreateGuild(interaction.guildId);
|
||||
|
||||
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 tag = interaction.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();
|
||||
const embed = client.embed({
|
||||
title: res.title,
|
||||
description: `${interaction.translate("fun/memes:SUBREDDIT")}: **${res.subreddit}**\n${interaction.translate("common:AUTHOR")}: **${res.author}**\n${interaction.translate("fun/memes:UPS")}: **${res.ups}**`,
|
||||
image: res.url,
|
||||
});
|
||||
|
||||
await interaction.editReply({
|
||||
embeds: [embed],
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
collector.on("end", () => {
|
||||
return interaction.editReply({
|
||||
components: [],
|
||||
});
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/Client")} client
|
||||
* @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;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Staff extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,52 +12,47 @@ class Staff extends BaseCommand {
|
|||
.setName("staff")
|
||||
.setDescription(client.translate("general/staff:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/staff:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/staff:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/staff:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/staff:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.guild.members.fetch();
|
||||
|
||||
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 embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("general/staff:TITLE", {
|
||||
guild: interaction.guild.name,
|
||||
}),
|
||||
})
|
||||
.addFields([
|
||||
iconURL: interaction.guild.iconURL(),
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("general/staff:ADMINS"),
|
||||
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")),
|
||||
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"),
|
||||
},
|
||||
{
|
||||
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({
|
||||
embeds: [embed],
|
||||
|
@ -65,4 +60,4 @@ class Staff extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Staff;
|
||||
module.exports = Staff;
|
||||
|
|
73
commands/Administration/addemoji.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
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;
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits, ChannelType } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField, ChannelType } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Automod extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,77 +12,87 @@ class Automod extends BaseCommand {
|
|||
.setName("automod")
|
||||
.setDescription(client.translate("administration/automod:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/automod:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/automod:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/automod:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/automod:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addBooleanOption(option => option.setName("state")
|
||||
.setDescription(client.translate("common:STATE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:STATE", null, "uk-UA"),
|
||||
"ru": client.translate("common:STATE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true))
|
||||
.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)),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("toggle")
|
||||
.setDescription(client.translate("administration/automod:TOGGLE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("administration/automod:TOGGLE", null, "uk-UA"),
|
||||
ru: client.translate("administration/automod:TOGGLE", null, "ru-RU"),
|
||||
})
|
||||
.addBooleanOption(option =>
|
||||
option
|
||||
.setName("state")
|
||||
.setDescription(client.translate("common:STATE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:STATE", null, "uk-UA"),
|
||||
ru: client.translate("common:STATE", null, "ru-RU"),
|
||||
})
|
||||
.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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const state = interaction.options.getBoolean("state"),
|
||||
channel = interaction.options.getChannel("channel");
|
||||
|
||||
if (state) {
|
||||
data.guildData.plugins.automod = {
|
||||
enabled: true,
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const { data } = interaction,
|
||||
state = interaction.options.getBoolean("state"),
|
||||
channel = interaction.options.getChannel("channel"),
|
||||
command = interaction.options.getSubcommand();
|
||||
|
||||
if (command === "toggle") {
|
||||
data.guild.plugins.automod = {
|
||||
enabled: state,
|
||||
ignored: [],
|
||||
};
|
||||
data.guildData.markModified("plugins.automod");
|
||||
await data.guildData.save();
|
||||
|
||||
return interaction.success("administration/automod:ENABLED");
|
||||
} else {
|
||||
if (channel) {
|
||||
data.guildData.plugins.automod.ignored.push(channel);
|
||||
data.guildData.markModified("plugins.automod");
|
||||
await data.guildData.save();
|
||||
data.guild.markModified("plugins.automod");
|
||||
await data.guild.save();
|
||||
|
||||
interaction.success("administration/automod:DISABLED_CHANNEL", {
|
||||
channel: channel.toString(),
|
||||
});
|
||||
} else {
|
||||
data.guildData.plugins.automod = {
|
||||
enabled: false,
|
||||
ignored: [],
|
||||
};
|
||||
data.guildData.markModified("plugins.automod");
|
||||
await data.guildData.save();
|
||||
interaction.success(`administration/automod:${state ? "ENABLED" : "DISABLED"}`);
|
||||
} else if (command === "ignore") {
|
||||
data.guild.plugins.automod.ignored.push(channel.id);
|
||||
|
||||
interaction.success("administration/automod:DISABLED");
|
||||
}
|
||||
data.guild.markModified("plugins.automod");
|
||||
await data.guild.save();
|
||||
|
||||
interaction.success("administration/automod:DISABLED_CHANNEL", {
|
||||
channel: channel.toString(),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Automod;
|
||||
module.exports = Automod;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Autorole extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,70 +12,66 @@ class Autorole extends BaseCommand {
|
|||
.setName("autorole")
|
||||
.setDescription(client.translate("administration/autorole:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/autorole:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/autorole:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/autorole:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/autorole:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addBooleanOption(option => option.setName("state")
|
||||
.setDescription(client.translate("common:STATE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:STATE", null, "uk-UA"),
|
||||
"ru": client.translate("common:STATE", 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"),
|
||||
})),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addBooleanOption(option =>
|
||||
option
|
||||
.setName("state")
|
||||
.setDescription(client.translate("common:STATE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:STATE", null, "uk-UA"),
|
||||
ru: client.translate("common:STATE", 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"),
|
||||
}),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const state = interaction.options.getBoolean("state");
|
||||
async execute(client, interaction) {
|
||||
const guildData = interaction.data.guild,
|
||||
state = interaction.options.getBoolean("state"),
|
||||
role = interaction.options.getRole("role");
|
||||
|
||||
if (state) {
|
||||
const role = interaction.options.getRole("role");
|
||||
if (!role) return interaction.error("administration/autorole:MISSING_ROLE");
|
||||
guildData.plugins.autorole = {
|
||||
enabled: state,
|
||||
role,
|
||||
};
|
||||
|
||||
data.guildData.plugins.autorole = {
|
||||
enabled: true,
|
||||
role: role.id,
|
||||
};
|
||||
data.guildData.markModified("plugins.autorole");
|
||||
await data.guildData.save();
|
||||
if (state && role) {
|
||||
guildData.markModified("plugins.autorole");
|
||||
await guildData.save();
|
||||
|
||||
interaction.success("administration/autorole:SUCCESS_ENABLED", {
|
||||
interaction.success("administration/autorole:ENABLED", {
|
||||
role: role.toString(),
|
||||
});
|
||||
} else {
|
||||
data.guildData.plugins.autorole = {
|
||||
enabled: false,
|
||||
role: null,
|
||||
};
|
||||
data.guildData.markModified("plugins.autorole");
|
||||
await data.guildData.save();
|
||||
guildData.plugins.autorole.enabled = false;
|
||||
|
||||
interaction.success("administration/autorole:SUCCESS_DISABLED");
|
||||
guildData.markModified("plugins.autorole");
|
||||
await guildData.save();
|
||||
|
||||
interaction.success("administration/autorole:DISABLED");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Autorole;
|
||||
module.exports = Autorole;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField, ChannelType } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Config extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,144 +12,155 @@ class Config extends BaseCommand {
|
|||
.setName("config")
|
||||
.setDescription(client.translate("administration/config:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/config:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/config:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/config:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/config:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addSubcommand(subcommand => subcommand.setName("list")
|
||||
.setDescription(client.translate("administration/config:LIST"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/config:LIST", null, "uk-UA"),
|
||||
"ru": client.translate("administration/config:LIST", null, "ru-RU"),
|
||||
}),
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("list")
|
||||
.setDescription(client.translate("administration/config:LIST"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("administration/config:LIST", null, "uk-UA"),
|
||||
ru: client.translate("administration/config:LIST", null, "ru-RU"),
|
||||
}),
|
||||
)
|
||||
.addSubcommand(subcommand => subcommand.setName("set")
|
||||
.setDescription(client.translate("administration/config:SET"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("set")
|
||||
.setDescription(client.translate("administration/config:SET"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/config:SETTING", null, "uk-UA"),
|
||||
"ru": client.translate("administration/config:SETTING", null, "ru-RU"),
|
||||
uk: client.translate("administration/config:SET", null, "uk-UA"),
|
||||
ru: client.translate("administration/config:SET", 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:NEWS"), value: "news" },
|
||||
{ name: client.translate("administration/config:REPORTS"), value: "reports" },
|
||||
{ name: client.translate("administration/config:SUGGESTIONS"), value: "suggestions" },
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("setting")
|
||||
.setDescription(client.translate("administration/config:SETTING"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("administration/config:SETTING", null, "uk-UA"),
|
||||
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),
|
||||
)
|
||||
.setRequired(true))
|
||||
.addBooleanOption(option => option.setName("state")
|
||||
.setDescription(client.translate("common:STATE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:STATE", null, "uk-UA"),
|
||||
"ru": client.translate("common:STATE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true))
|
||||
.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"),
|
||||
})),
|
||||
.addBooleanOption(option =>
|
||||
option
|
||||
.setName("state")
|
||||
.setDescription(client.translate("common:STATE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:STATE", null, "uk-UA"),
|
||||
ru: client.translate("common:STATE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
)
|
||||
.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"),
|
||||
}),
|
||||
),
|
||||
),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const command = interaction.options.getSubcommand();
|
||||
async execute(client, interaction) {
|
||||
const guildData = interaction.data.guild,
|
||||
command = interaction.options.getSubcommand();
|
||||
|
||||
if (command === "list") {
|
||||
const guildData = data.guildData;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.guild.name,
|
||||
iconURL: interaction.guild.iconURL(),
|
||||
})
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
})
|
||||
.addFields([
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("administration/config:WELCOME_TITLE"),
|
||||
value: guildData.plugins.welcome.enabled ? interaction.translate("administration/config:WELCOME_CONTENT", {
|
||||
channel: `<#${guildData.plugins.welcome.channel}>`,
|
||||
withImage: guildData.plugins.welcome.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO"),
|
||||
}) : interaction.translate("common:DISABLED"),
|
||||
value: guildData.plugins.welcome.enabled
|
||||
? interaction.translate("administration/config:WELCOME_CONTENT", {
|
||||
channel: `<#${guildData.plugins.welcome.channel}>`,
|
||||
withImage: guildData.plugins.welcome.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO"),
|
||||
}) : interaction.translate("common:DISABLED"),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("administration/config:GOODBYE_TITLE"),
|
||||
value: guildData.plugins.goodbye.enabled ? interaction.translate("administration/config:GOODBYE_CONTENT", {
|
||||
channel: `<#${guildData.plugins.goodbye.channel}>`,
|
||||
withImage: guildData.plugins.goodbye.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO"),
|
||||
}) : interaction.translate("common:DISABLED"),
|
||||
value: guildData.plugins.goodbye.enabled
|
||||
? interaction.translate("administration/config:GOODBYE_CONTENT", {
|
||||
channel: `<#${guildData.plugins.goodbye.channel}>`,
|
||||
withImage: guildData.plugins.goodbye.withImage ? interaction.translate("common:YES") : interaction.translate("common:NO"),
|
||||
}) : interaction.translate("common:DISABLED"),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
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"),
|
||||
value: (guildData.plugins.warnsSanctions.kick ? interaction.translate("administration/config:KICK_CONTENT", {
|
||||
count: guildData.plugins.warnsSanctions.kick,
|
||||
}) : interaction.translate("administration/config:KICK_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")),
|
||||
value:
|
||||
(guildData.plugins.warnsSanctions.kick
|
||||
? interaction.translate("administration/config:KICK_CONTENT", {
|
||||
count: guildData.plugins.warnsSanctions.kick,
|
||||
}) : interaction.translate("administration/config:KICK_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"),
|
||||
value: guildData.plugins.automod.enabled ? interaction.translate("administration/config:AUTOMOD_CONTENT", {
|
||||
channels: guildData.plugins.automod.ignored.map(ch => ` ${ch}`),
|
||||
}) : interaction.translate("common:DISABLED"),
|
||||
value: guildData.plugins.automod.enabled
|
||||
? interaction.translate("administration/config:AUTOMOD_CONTENT", {
|
||||
channels: guildData.plugins.automod.ignored.map(ch => ` ${ch}`),
|
||||
}) : 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"),
|
||||
value: interaction.translate("administration/config:NEWS_LIST", {
|
||||
channel: guildData.plugins.news ? `<#${guildData.plugins.news}>` : `*${interaction.translate("common:NOT_DEFINED")}*`,
|
||||
}) + "\n" +
|
||||
interaction.translate("administration/config:SUGGESTIONS_LIST", {
|
||||
channel: guildData.plugins.suggestions ? `<#${guildData.plugins.suggestions}>` : `*${interaction.translate("common:NOT_DEFINED")}*`,
|
||||
}) + "\n" +
|
||||
interaction.translate("administration/config:REPORTS_LIST", {
|
||||
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")}*`,
|
||||
}),
|
||||
value:
|
||||
`${interaction.translate("administration/config:BIRTHDAYS")}: ${guildData.plugins?.birthdays ? `<#${guildData.plugins.birthdays}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` +
|
||||
`${interaction.translate("administration/config:MODLOGS")}: ${guildData.plugins?.modlogs ? `<#${guildData.plugins.modlogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` +
|
||||
`${interaction.translate("administration/config:REPORTS")}: ${guildData.plugins?.reports ? `<#${guildData.plugins.reports}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` +
|
||||
`${interaction.translate("administration/config:SUGGESTIONS")}: ${guildData.plugins?.suggestions ? `<#${guildData.plugins.suggestions}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` +
|
||||
`${interaction.translate("administration/config:TICKETSCATEGORY")}: ${guildData.plugins?.tickets?.ticketsCategory ? `<#${guildData.plugins?.tickets?.ticketsCategory}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` +
|
||||
`${interaction.translate("administration/config:TICKETLOGS")}: ${guildData.plugins?.tickets?.ticketLogs ? `<#${guildData.plugins?.tickets?.ticketLogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n` +
|
||||
`${interaction.translate("administration/config:TRANSCRIPTIONLOGS")}: ${guildData.plugins?.tickets?.transcriptionLogs ? `<#${guildData.plugins?.tickets?.transcriptionLogs}>` : `*${interaction.translate("common:NOT_DEFINED")}*`}\n`,
|
||||
},
|
||||
// {
|
||||
// name: interaction.translate("administration/config:DASHBOARD_TITLE"),
|
||||
// value: `[${interaction.translate("administration/config:DASHBOARD_CONTENT")}](${client.config.dashboard.baseURL})`
|
||||
// }
|
||||
]);
|
||||
{
|
||||
name: interaction.translate("administration/config:DASHBOARD_TITLE"),
|
||||
value: `[${interaction.translate("administration/config:DASHBOARD_CONTENT")}](${client.config.dashboard.domain})`,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
embeds: [embed],
|
||||
|
@ -170,35 +181,78 @@ class Config extends BaseCommand {
|
|||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {String} setting
|
||||
* @param {Boolean} state
|
||||
* @param {import("discord.js").GuildTextBasedChannel} channel
|
||||
* @param {import("discord.js").GuildTextBasedChannel | import("discord.js").CategoryChannel} channel
|
||||
* @returns
|
||||
*/
|
||||
async function changeSetting(interaction, setting, state, channel) {
|
||||
if (!state) {
|
||||
interaction.guild.data.plugins[setting] = null;
|
||||
interaction.guild.data.markModified(`plugins.${setting}`);
|
||||
await interaction.guild.data.save();
|
||||
const settingSplitted = setting.split("."),
|
||||
data = interaction.data.guild;
|
||||
|
||||
return interaction.reply({
|
||||
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
|
||||
ephemeral: true,
|
||||
});
|
||||
if (settingSplitted.length === 2) {
|
||||
if (data.plugins[settingSplitted[0]] === undefined) data.plugins[settingSplitted[0]] = {};
|
||||
|
||||
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 {
|
||||
if (channel) {
|
||||
interaction.guild.data.plugins[setting] = channel.id;
|
||||
interaction.guild.data.markModified(`plugins.${setting}`);
|
||||
await interaction.guild.data.save();
|
||||
if (!state) {
|
||||
data.plugins[setting] = null;
|
||||
|
||||
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()}`)}: ${interaction.guild.data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${interaction.guild.data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`}`,
|
||||
content: `${interaction.translate(`administration/config:${setting.toUpperCase()}`)}: **${interaction.translate("common:DISABLED")}**`,
|
||||
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;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Goodbye extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,70 +12,79 @@ class Goodbye extends BaseCommand {
|
|||
.setName("goodbye")
|
||||
.setDescription(client.translate("administration/goodbye:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/goodbye:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/goodbye:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/goodbye:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/goodbye:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addSubcommand(subcommand => subcommand.setName("test")
|
||||
.setDescription(client.translate("administration/goodbye:TEST"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/goodbye:TEST", null, "uk-UA"),
|
||||
"ru": client.translate("administration/goodbye:TEST", null, "ru-RU"),
|
||||
}),
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("test")
|
||||
.setDescription(client.translate("administration/goodbye:TEST"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("administration/goodbye:TEST", null, "uk-UA"),
|
||||
ru: client.translate("administration/goodbye:TEST", null, "ru-RU"),
|
||||
}),
|
||||
)
|
||||
.addSubcommand(subcommand => subcommand.setName("config")
|
||||
.setDescription(client.translate("administration/goodbye:CONFIG"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("config")
|
||||
.setDescription(client.translate("administration/goodbye:CONFIG"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:STATE", null, "uk-UA"),
|
||||
"ru": client.translate("common:STATE", null, "ru-RU"),
|
||||
uk: client.translate("administration/goodbye:CONFIG", null, "uk-UA"),
|
||||
ru: client.translate("administration/goodbye:CONFIG", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true))
|
||||
.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"),
|
||||
}))
|
||||
.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"),
|
||||
})),
|
||||
.addBooleanOption(option =>
|
||||
option
|
||||
.setName("state")
|
||||
.setDescription(client.translate("common:STATE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:STATE", null, "uk-UA"),
|
||||
ru: client.translate("common:STATE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
)
|
||||
.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"),
|
||||
}),
|
||||
)
|
||||
.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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const command = interaction.options.getSubcommand();
|
||||
async execute(client, interaction) {
|
||||
const guildData = interaction.data.guild,
|
||||
command = interaction.options.getSubcommand();
|
||||
|
||||
if (command === "test") {
|
||||
client.emit("guildMemberRemove", interaction.member);
|
||||
|
@ -85,36 +94,38 @@ class Goodbye extends BaseCommand {
|
|||
const state = interaction.options.getBoolean("state");
|
||||
|
||||
if (!state) {
|
||||
data.guildData.plugins.goodbye = {
|
||||
guildData.plugins.goodbye = {
|
||||
enabled: false,
|
||||
message: null,
|
||||
channelID: null,
|
||||
withImage: null,
|
||||
};
|
||||
data.guildData.markModified("plugins.goodbye");
|
||||
await data.guildData.save();
|
||||
|
||||
interaction.success("administration/goodbye:DISABLED");
|
||||
guildData.markModified("plugins.goodbye");
|
||||
await guildData.save();
|
||||
|
||||
interaction.success("administration/goodbye:DISABLED", null, { ephemeral: true });
|
||||
} else {
|
||||
const channel = interaction.options.getChannel("channel") || interaction.channel;
|
||||
const message = interaction.options.getString("message") || interaction.translate("administration/goodbye:DEFAULT_MESSAGE");
|
||||
const image = interaction.options.getBoolean("image") || true;
|
||||
const image = interaction.options.getBoolean("image") === true ? true : false;
|
||||
|
||||
data.guildData.plugins.goodbye = {
|
||||
guildData.plugins.goodbye = {
|
||||
enabled: true,
|
||||
channel: channel.id,
|
||||
message: message,
|
||||
withImage: image,
|
||||
};
|
||||
data.guildData.markModified("plugins.goodbye");
|
||||
await data.guildData.save();
|
||||
|
||||
guildData.markModified("plugins.goodbye");
|
||||
await guildData.save();
|
||||
|
||||
interaction.success("administration/goodbye:ENABLED", {
|
||||
channel: `<#${data.guildData.plugins.goodbye.channel}>`,
|
||||
channel: `${channel.toString()}`,
|
||||
}, { ephemeral: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Goodbye;
|
||||
module.exports = Goodbye;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Selectroles extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,67 +12,86 @@ class Selectroles extends BaseCommand {
|
|||
.setName("selectroles")
|
||||
.setDescription(client.translate("administration/selectroles:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/selectroles:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/selectroles:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/selectroles:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/selectroles:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addSubcommand(subcommand => subcommand.setName("message")
|
||||
.setDescription(client.translate("administration/selectroles:MESSAGE"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("message")
|
||||
.setDescription(client.translate("administration/selectroles:MESSAGE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:MESSAGE", null, "uk-UA"),
|
||||
"ru": client.translate("common:MESSAGE", null, "ru-RU"),
|
||||
uk: client.translate("administration/selectroles:MESSAGE", null, "uk-UA"),
|
||||
ru: client.translate("administration/selectroles:MESSAGE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
.addStringOption(option =>
|
||||
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 => subcommand.setName("addrole")
|
||||
.setDescription(client.translate("administration/selectroles:ADDROLE"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("addrole")
|
||||
.setDescription(client.translate("administration/selectroles:ADDROLE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:CHANNEL", null, "uk-UA"),
|
||||
"ru": client.translate("common:CHANNEL", null, "ru-RU"),
|
||||
uk: client.translate("administration/selectroles:ADDROLE", null, "uk-UA"),
|
||||
ru: client.translate("administration/selectroles:ADDROLE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true))
|
||||
.addStringOption(option => option.setName("message_id")
|
||||
.setDescription(client.translate("common:MESSAGE_ID"))
|
||||
.setDescriptionLocalizations({
|
||||
"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)),
|
||||
.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"),
|
||||
})
|
||||
.setRequired(true),
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("message_id")
|
||||
.setDescription(client.translate("common:MESSAGE_ID"))
|
||||
.setDescriptionLocalizations({
|
||||
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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
async onLoad(client) {
|
||||
client.on("interactionCreate", async interaction => {
|
||||
if (!interaction.isStringSelectMenu()) return;
|
||||
|
||||
if (interaction.customId === "auto_roles") {
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
|
||||
const removed = interaction.component.options.filter(option => {
|
||||
return !interaction.values.includes(option.value);
|
||||
});
|
||||
|
@ -92,11 +111,11 @@ class Selectroles extends BaseCommand {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
@ -123,33 +142,27 @@ class Selectroles extends BaseCommand {
|
|||
let row = message.components[0];
|
||||
if (!row) row = new ActionRowBuilder();
|
||||
|
||||
const option = [{
|
||||
label: role.name,
|
||||
value: role.id,
|
||||
}];
|
||||
const option = [
|
||||
{
|
||||
label: role.name,
|
||||
value: role.id,
|
||||
},
|
||||
];
|
||||
|
||||
const menu = row.components[0];
|
||||
if (menu) {
|
||||
for (const o of menu.options) {
|
||||
if (o.value === option[0].value) return interaction.error("administration/selectroles:ALREADY_IN_MENU");
|
||||
if (o.value === option[0].value) return interaction.error("administration/selectroles:ALREADY_IN_MENU", null, { edit: true });
|
||||
}
|
||||
|
||||
row = ActionRowBuilder.from(row)
|
||||
.setComponents(
|
||||
StringSelectMenuBuilder.from(menu)
|
||||
.setMinValues(0)
|
||||
.setMaxValues(menu.options.length + 1)
|
||||
.addOptions(option),
|
||||
);
|
||||
} else {
|
||||
row.addComponents(
|
||||
new StringSelectMenuBuilder()
|
||||
.setCustomId("auto_roles")
|
||||
row = ActionRowBuilder.from(row).setComponents(
|
||||
StringSelectMenuBuilder.from(menu)
|
||||
.setMinValues(0)
|
||||
.setMaxValues(1)
|
||||
.setPlaceholder(interaction.translate("common:AVAILABLE_OPTIONS"))
|
||||
.setMaxValues(menu.options.length + 1)
|
||||
.addOptions(option),
|
||||
);
|
||||
} else {
|
||||
row.addComponents(new StringSelectMenuBuilder().setCustomId("auto_roles").setMinValues(0).setMaxValues(1).setPlaceholder(interaction.translate("common:AVAILABLE_OPTIONS")).addOptions(option));
|
||||
}
|
||||
|
||||
message.edit({
|
||||
|
@ -166,4 +179,4 @@ class Selectroles extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Selectroles;
|
||||
module.exports = Selectroles;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Set extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,55 +12,56 @@ class Set extends BaseCommand {
|
|||
.setName("set")
|
||||
.setDescription(client.translate("administration/set:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/set:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/set:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/set:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/set:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addStringOption(option => option.setName("type")
|
||||
.setDescription(client.translate("owner/debug:TYPE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("owner/debug:TYPE", null, "uk-UA"),
|
||||
"ru": client.translate("owner/debug:TYPE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: client.translate("common:LEVEL"), value: "level" },
|
||||
{ name: client.translate("common:XP"), value: "xp" },
|
||||
{ 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({
|
||||
"uk": client.translate("common:USER", null, "uk-UA"),
|
||||
"ru": client.translate("common:USER", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true))
|
||||
.addIntegerOption(option => option.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)),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("type")
|
||||
.setDescription(client.translate("owner/debug:TYPE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("owner/debug:TYPE", null, "uk-UA"),
|
||||
ru: client.translate("owner/debug:TYPE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: client.translate("common:LEVEL"), value: "level" },
|
||||
{ name: client.translate("common:XP"), value: "xp" },
|
||||
{ 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({
|
||||
uk: client.translate("common:USER", null, "uk-UA"),
|
||||
ru: client.translate("common:USER", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
)
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const type = interaction.options.getString("type"),
|
||||
|
@ -78,7 +79,10 @@ class Set extends BaseCommand {
|
|||
switch (type) {
|
||||
case "level": {
|
||||
memberData.level = int;
|
||||
|
||||
memberData.markModified("level");
|
||||
await memberData.save();
|
||||
|
||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||
user: member.toString(),
|
||||
amount: int,
|
||||
|
@ -87,7 +91,10 @@ class Set extends BaseCommand {
|
|||
|
||||
case "xp": {
|
||||
memberData.exp = int;
|
||||
|
||||
memberData.markModified("exp");
|
||||
await memberData.save();
|
||||
|
||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||
user: member.toString(),
|
||||
amount: int,
|
||||
|
@ -96,7 +103,10 @@ class Set extends BaseCommand {
|
|||
|
||||
case "credits": {
|
||||
memberData.money = int;
|
||||
|
||||
memberData.markModified("money");
|
||||
await memberData.save();
|
||||
|
||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||
user: member.toString(),
|
||||
amount: int,
|
||||
|
@ -105,7 +115,10 @@ class Set extends BaseCommand {
|
|||
|
||||
case "bank": {
|
||||
memberData.bankSold = int;
|
||||
|
||||
memberData.markModified("bankSold");
|
||||
await memberData.save();
|
||||
|
||||
return interaction.success(`owner/debug:SUCCESS_${type.toUpperCase()}`, {
|
||||
user: member.toString(),
|
||||
amount: int,
|
||||
|
@ -115,4 +128,4 @@ class Set extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Set;
|
||||
module.exports = Set;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Setlang extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,47 +12,41 @@ class Setlang extends BaseCommand {
|
|||
.setName("setlang")
|
||||
.setDescription(client.translate("administration/setlang:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/setlang:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/setlang:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/setlang:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/setlang:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addStringOption(option => option.setName("language")
|
||||
.setDescription(client.translate("common:LANGUAGE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:LANGUAGE", null, "uk-UA"),
|
||||
"ru": client.translate("common:LANGUAGE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: "English", value: "en-US" },
|
||||
{ name: "Русский", value: "ru-RU" },
|
||||
{ name: "Українська", value: "uk-UA" },
|
||||
)),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("language")
|
||||
.setDescription(client.translate("common:LANGUAGE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:LANGUAGE", null, "uk-UA"),
|
||||
ru: client.translate("common:LANGUAGE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices({ name: "English", value: "en-US" }, { name: "Русский", value: "ru-RU" }, { name: "Українська", value: "uk-UA" }),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const lang = interaction.options.getString("language"),
|
||||
async execute(client, interaction) {
|
||||
const guildData = interaction.data.guild,
|
||||
lang = interaction.options.getString("language"),
|
||||
language = client.languages.find(l => l.name === lang);
|
||||
|
||||
data.guildData.language = language.name;
|
||||
await data.guildData.save();
|
||||
guildData.language = language.name;
|
||||
|
||||
guildData.markModified("language");
|
||||
await guildData.save();
|
||||
|
||||
return interaction.success("administration/setlang:SUCCESS", {
|
||||
lang: language.nativeName,
|
||||
|
@ -60,4 +54,4 @@ class Setlang extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Setlang;
|
||||
module.exports = Setlang;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, parseEmoji, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, parseEmoji, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Stealemoji extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,48 +12,44 @@ class Stealemoji extends BaseCommand {
|
|||
.setName("stealemoji")
|
||||
.setDescription(client.translate("administration/stealemoji:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/stealemoji:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/stealemoji:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/stealemoji:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/stealemoji:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addStringOption(option => option.setName("emoji")
|
||||
.setDescription(client.translate("common:EMOJI"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:EMOJI", null, "uk-UA"),
|
||||
"ru": client.translate("common:EMOJI", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("emoji")
|
||||
.setDescription(client.translate("common:EMOJI"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:EMOJI", null, "uk-UA"),
|
||||
ru: client.translate("common:EMOJI", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const parsedEmoji = parseEmoji(interaction.options.getString("emoji")),
|
||||
ext = parsedEmoji.animated ? "gif" : "png";
|
||||
const parsedEmoji = parseEmoji(interaction.options.getString("emoji"));
|
||||
|
||||
interaction.guild.emojis
|
||||
.create({
|
||||
name: parsedEmoji.name,
|
||||
attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${ext}`,
|
||||
attachment: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${parsedEmoji.animated ? "gif" : "png"}`,
|
||||
})
|
||||
.then(emoji => interaction.success("administration/stealemoji:SUCCESS", {
|
||||
emoji: emoji.name,
|
||||
}, { ephemeral: true }))
|
||||
.then(emoji =>
|
||||
interaction.success("administration/stealemoji:SUCCESS", {
|
||||
emoji: emoji.name,
|
||||
}, { ephemeral: true }),
|
||||
)
|
||||
.catch(e => {
|
||||
interaction.error("administration/stealemoji:ERROR", {
|
||||
emoji: parsedEmoji.name,
|
||||
|
@ -63,4 +59,4 @@ class Stealemoji extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Stealemoji;
|
||||
module.exports = Stealemoji;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Welcome extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,70 +12,79 @@ class Welcome extends BaseCommand {
|
|||
.setName("welcome")
|
||||
.setDescription(client.translate("administration/welcome:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/welcome:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("administration/welcome:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("administration/welcome:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("administration/welcome:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.Administrator)
|
||||
.addSubcommand(subcommand => subcommand.setName("test")
|
||||
.setDescription(client.translate("administration/goodbye:TEST"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("administration/goodbye:TEST", null, "uk-UA"),
|
||||
"ru": client.translate("administration/goodbye:TEST", null, "ru-RU"),
|
||||
}),
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("test")
|
||||
.setDescription(client.translate("administration/goodbye:TEST"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("administration/goodbye:TEST", null, "uk-UA"),
|
||||
ru: client.translate("administration/goodbye:TEST", null, "ru-RU"),
|
||||
}),
|
||||
)
|
||||
.addSubcommand(subcommand => subcommand.setName("config")
|
||||
.setDescription(client.translate("administration/goodbye:CONFIG"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("config")
|
||||
.setDescription(client.translate("administration/goodbye:CONFIG"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:STATE", null, "uk-UA"),
|
||||
"ru": client.translate("common:STATE", null, "ru-RU"),
|
||||
uk: client.translate("administration/goodbye:CONFIG", null, "uk-UA"),
|
||||
ru: client.translate("administration/goodbye:CONFIG", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true))
|
||||
.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"),
|
||||
}))
|
||||
.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"),
|
||||
})),
|
||||
.addBooleanOption(option =>
|
||||
option
|
||||
.setName("state")
|
||||
.setDescription(client.translate("common:STATE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:STATE", null, "uk-UA"),
|
||||
ru: client.translate("common:STATE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
)
|
||||
.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"),
|
||||
}),
|
||||
)
|
||||
.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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const command = interaction.options.getSubcommand();
|
||||
async execute(client, interaction) {
|
||||
const guildData = interaction.data.guild,
|
||||
command = interaction.options.getSubcommand();
|
||||
|
||||
if (command === "test") {
|
||||
client.emit("guildMemberAdd", interaction.member);
|
||||
|
@ -85,36 +94,38 @@ class Welcome extends BaseCommand {
|
|||
const state = interaction.options.getBoolean("state");
|
||||
|
||||
if (!state) {
|
||||
data.guildData.plugins.welcome = {
|
||||
guildData.plugins.welcome = {
|
||||
enabled: false,
|
||||
message: null,
|
||||
channelID: null,
|
||||
withImage: null,
|
||||
};
|
||||
data.guildData.markModified("plugins.welcome");
|
||||
await data.guildData.save();
|
||||
|
||||
interaction.success("administration/welcome:DISABLED");
|
||||
guildData.markModified("plugins.welcome");
|
||||
await guildData.save();
|
||||
|
||||
interaction.success("administration/welcome:DISABLED", null, { ephemeral: true });
|
||||
} else {
|
||||
const channel = interaction.options.getChannel("channel") || interaction.channel;
|
||||
const message = interaction.options.getString("message") || interaction.translate("administration/welcome:DEFAULT_MESSAGE");
|
||||
const image = interaction.options.getBoolean("image") || true;
|
||||
const image = interaction.options.getBoolean("image") === true ? true : false;
|
||||
|
||||
data.guildData.plugins.welcome = {
|
||||
guildData.plugins.welcome = {
|
||||
enabled: true,
|
||||
channel: channel.id,
|
||||
message: message,
|
||||
withImage: image,
|
||||
};
|
||||
data.guildData.markModified("plugins.welcome");
|
||||
await data.guildData.save();
|
||||
|
||||
guildData.markModified("plugins.welcome");
|
||||
await guildData.save();
|
||||
|
||||
interaction.success("administration/welcome:ENABLED", {
|
||||
channel: `<#${data.guildData.plugins.welcome.channel}>`,
|
||||
channel: `${channel.toString()}`,
|
||||
}, { ephemeral: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Welcome;
|
||||
module.exports = Welcome;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Achievements extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,109 +12,99 @@ class Achievements extends BaseCommand {
|
|||
.setName("achievements")
|
||||
.setDescription(client.translate("economy/achievements:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/achievements:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/achievements:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/achievements:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/achievements:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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"),
|
||||
})),
|
||||
aliases: [],
|
||||
.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"),
|
||||
}),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
const user = interaction.options.getUser("user") || interaction.member;
|
||||
if (user.bot) return interaction.error("economy/profile:BOT_USER");
|
||||
|
||||
const userData = (user.id === interaction.user.id ? data.userData : await client.findOrCreateUser({
|
||||
id: user.id,
|
||||
}));
|
||||
const userData = user.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(user.id);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("economy/achievements:TITLE"),
|
||||
})
|
||||
.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)),
|
||||
}),
|
||||
iconURL: user.displayAvatarURL(),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:CLAIM_SALARY"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.work.progress.now,
|
||||
total: userData.achievements.work.progress.total,
|
||||
percent: Math.round(100 * (userData.achievements.work.progress.now / userData.achievements.work.progress.total)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:MARRY"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.married.progress.now,
|
||||
total: userData.achievements.married.progress.total,
|
||||
percent: Math.round(100 * (userData.achievements.married.progress.now / userData.achievements.married.progress.total)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:SLOTS"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.slots.progress.now,
|
||||
total: userData.achievements.slots.progress.total,
|
||||
percent: Math.round(100 * (userData.achievements.slots.progress.now / userData.achievements.slots.progress.total)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:TIP"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.tip.progress.now,
|
||||
total: userData.achievements.tip.progress.total,
|
||||
percent: Math.round(100 * (userData.achievements.tip.progress.now / userData.achievements.tip.progress.total)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:REP"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.rep.progress.now,
|
||||
total: userData.achievements.rep.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)),
|
||||
}),
|
||||
},
|
||||
]);
|
||||
fields: [
|
||||
{
|
||||
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)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:CLAIM_SALARY"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.work.progress.now,
|
||||
total: userData.achievements.work.progress.total,
|
||||
percent: Math.round(100 * (userData.achievements.work.progress.now / userData.achievements.work.progress.total)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:MARRY"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.married.progress.now,
|
||||
total: userData.achievements.married.progress.total,
|
||||
percent: Math.round(100 * (userData.achievements.married.progress.now / userData.achievements.married.progress.total)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:SLOTS"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.slots.progress.now,
|
||||
total: userData.achievements.slots.progress.total,
|
||||
percent: Math.round(100 * (userData.achievements.slots.progress.now / userData.achievements.slots.progress.total)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:TIP"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.tip.progress.now,
|
||||
total: userData.achievements.tip.progress.total,
|
||||
percent: Math.round(100 * (userData.achievements.tip.progress.now / userData.achievements.tip.progress.total)),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/achievements:REP"),
|
||||
value: interaction.translate("economy/achievements:PROGRESS", {
|
||||
now: userData.achievements.rep.progress.now,
|
||||
total: userData.achievements.rep.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({
|
||||
embeds: [embed],
|
||||
|
@ -122,4 +112,4 @@ class Achievements extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Achievements;
|
||||
module.exports = Achievements;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Bank extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,57 +12,60 @@ class Bank extends BaseCommand {
|
|||
.setName("bank")
|
||||
.setDescription(client.translate("economy/bank:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/bank:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/bank:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/bank:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/bank:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addStringOption(option => option.setName("option")
|
||||
.setDescription(client.translate("economy/bank:OPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/bank:OPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/bank:OPTION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: client.translate("economy/bank:DEPOSIT"), value: "deposit" },
|
||||
{ name: client.translate("economy/bank:WITHDRAW"), value: "withdraw" },
|
||||
))
|
||||
.addStringOption(option => option.setName("credits")
|
||||
.setDescription(client.translate("misc:OPTION_NAN_ALL"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("misc:OPTION_NAN_ALL", null, "uk-UA"),
|
||||
"ru": client.translate("misc:OPTION_NAN_ALL", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("option")
|
||||
.setDescription(client.translate("economy/bank:OPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("economy/bank:OPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/bank:OPTION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices({ name: client.translate("economy/bank:DEPOSIT"), value: "deposit" }, { name: client.translate("economy/bank:WITHDRAW"), value: "withdraw" }),
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("credits")
|
||||
.setDescription(client.translate("misc:OPTION_NAN_ALL"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("misc:OPTION_NAN_ALL", null, "uk-UA"),
|
||||
ru: client.translate("misc:OPTION_NAN_ALL", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const choice = interaction.options.getString("option");
|
||||
async execute(client, interaction) {
|
||||
const memberData = interaction.data.member,
|
||||
choice = interaction.options.getString("option");
|
||||
|
||||
if (choice === "deposit") {
|
||||
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 (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"))}` });
|
||||
const credits = interaction.options.getString("credits").toLowerCase() === "all" ? memberData.money : interaction.options.getString("credits");
|
||||
|
||||
data.memberData.money -= credits;
|
||||
data.memberData.bankSold += credits;
|
||||
await data.memberData.save();
|
||||
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
|
||||
if (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"))}`,
|
||||
});
|
||||
|
||||
memberData.money -= credits;
|
||||
memberData.bankSold += credits;
|
||||
|
||||
memberData.markModified("money");
|
||||
memberData.markModified("bankSold");
|
||||
await memberData.save();
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/transactions:BANK"),
|
||||
|
@ -70,15 +73,19 @@ class Bank extends BaseCommand {
|
|||
date: Date.now(),
|
||||
type: "send",
|
||||
};
|
||||
data.memberData.transactions.push(info);
|
||||
memberData.transactions.push(info);
|
||||
|
||||
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"))}`,
|
||||
});
|
||||
} else {
|
||||
const credits = interaction.options.getString("credits") === "all" ? data.memberData.bankSold : interaction.options.getString("credits");
|
||||
const credits = interaction.options.getString("credits") === "all" ? memberData.bankSold : interaction.options.getString("credits");
|
||||
|
||||
if (isNaN(credits) || credits < 1) return interaction.error("misc:OPTION_NAN_ALL");
|
||||
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"))}` });
|
||||
if (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"))}`,
|
||||
});
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/transactions:BANK"),
|
||||
|
@ -87,11 +94,14 @@ class Bank extends BaseCommand {
|
|||
type: "got",
|
||||
};
|
||||
|
||||
data.memberData.transactions.push(info);
|
||||
memberData.transactions.push(info);
|
||||
|
||||
data.memberData.money += credits;
|
||||
data.memberData.bankSold -= credits;
|
||||
await data.memberData.save();
|
||||
memberData.money += credits;
|
||||
memberData.bankSold -= credits;
|
||||
|
||||
memberData.markModified("money");
|
||||
memberData.markModified("bankSold");
|
||||
await memberData.save();
|
||||
|
||||
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"))}`,
|
||||
|
@ -100,4 +110,4 @@ class Bank extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Bank;
|
||||
module.exports = Bank;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Birthdate extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,80 +12,85 @@ class Birthdate extends BaseCommand {
|
|||
.setName("birthdate")
|
||||
.setDescription(client.translate("economy/birthdate:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/birthdate:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/birthdate:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/birthdate:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/birthdate:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addIntegerOption(option => option.setName("day")
|
||||
.setDescription(client.translate("economy/birthdate:DAY"))
|
||||
.setDescriptionLocalizations({
|
||||
"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")
|
||||
.setDescription(client.translate("economy/birthdate:MONTH"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/birthdate:MONTH", null, "uk-UA"),
|
||||
"ru": client.translate("economy/birthdate:MONTH", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: client.translate("economy/birthdate:JANUARY"), value: 1 },
|
||||
{ name: client.translate("economy/birthdate:FEBRUARY"), value: 2 },
|
||||
{ name: client.translate("economy/birthdate:MARCH"), value: 3 },
|
||||
{ name: client.translate("economy/birthdate:APRIL"), value: 4 },
|
||||
{ name: client.translate("economy/birthdate:MAY"), value: 5 },
|
||||
{ name: client.translate("economy/birthdate:JUNE"), value: 6 },
|
||||
{ name: client.translate("economy/birthdate:JULY"), value: 7 },
|
||||
{ name: client.translate("economy/birthdate:AUGUST"), value: 8 },
|
||||
{ name: client.translate("economy/birthdate:SEPTEMBER"), value: 9 },
|
||||
{ name: client.translate("economy/birthdate:OCTOBER"), value: 10 },
|
||||
{ name: client.translate("economy/birthdate:NOVEMBER"), value: 11 },
|
||||
{ name: client.translate("economy/birthdate:DECEMBER"), value: 12 },
|
||||
))
|
||||
.addIntegerOption(option => option.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)),
|
||||
aliases: [],
|
||||
.setDMPermission(true)
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("day")
|
||||
.setDescription(client.translate("economy/birthdate:DAY"))
|
||||
.setDescriptionLocalizations({
|
||||
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")
|
||||
.setDescription(client.translate("economy/birthdate:MONTH"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("economy/birthdate:MONTH", null, "uk-UA"),
|
||||
ru: client.translate("economy/birthdate:MONTH", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: client.translate("economy/birthdate:JANUARY"), value: 1 },
|
||||
{ name: client.translate("economy/birthdate:FEBRUARY"), value: 2 },
|
||||
{ name: client.translate("economy/birthdate:MARCH"), value: 3 },
|
||||
{ name: client.translate("economy/birthdate:APRIL"), value: 4 },
|
||||
{ name: client.translate("economy/birthdate:MAY"), value: 5 },
|
||||
{ name: client.translate("economy/birthdate:JUNE"), value: 6 },
|
||||
{ name: client.translate("economy/birthdate:JULY"), value: 7 },
|
||||
{ name: client.translate("economy/birthdate:AUGUST"), value: 8 },
|
||||
{ name: client.translate("economy/birthdate:SEPTEMBER"), value: 9 },
|
||||
{ name: client.translate("economy/birthdate:OCTOBER"), value: 10 },
|
||||
{ name: client.translate("economy/birthdate:NOVEMBER"), value: 11 },
|
||||
{ name: client.translate("economy/birthdate:DECEMBER"), value: 12 },
|
||||
),
|
||||
)
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const day = interaction.options.getInteger("day"),
|
||||
async execute(client, interaction) {
|
||||
const userData = interaction.data.user,
|
||||
day = interaction.options.getInteger("day"),
|
||||
month = interaction.options.getInteger("month"),
|
||||
year = interaction.options.getInteger("year"),
|
||||
d = new Date(year, month - 1, day);
|
||||
date = new Date(year, month - 1, day),
|
||||
d = Math.floor(date.getTime() / 1000);
|
||||
|
||||
if (!(day == d.getDate() && month - 1 == d.getMonth() && year == d.getFullYear())) return interaction.error("economy/birthdate:INVALID_DATE");
|
||||
if (d.getTime() > Date.now()) return interaction.error("economy/birthdate:DATE_TOO_HIGH");
|
||||
if (d.getTime() < (Date.now() - 2.523e+12)) return interaction.error("economy/birthdate:DATE_TOO_LOW");
|
||||
if (!(day == date.getDate() && month - 1 == date.getMonth() && year == date.getFullYear())) return interaction.error("economy/birthdate:INVALID_DATE");
|
||||
if (date.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");
|
||||
|
||||
data.userData.birthdate = d;
|
||||
await data.userData.save();
|
||||
userData.birthdate = d;
|
||||
|
||||
userData.markModified("birthdate");
|
||||
await userData.save();
|
||||
|
||||
interaction.success("economy/birthdate:SUCCESS", {
|
||||
date: client.functions.printDate(client, d),
|
||||
date: `<t:${d}:D>`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Birthdate;
|
||||
module.exports = Birthdate;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Divorce extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,51 +12,49 @@ class Divorce extends BaseCommand {
|
|||
.setName("divorce")
|
||||
.setDescription(client.translate("economy/divorce:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/divorce:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/divorce:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/divorce:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/divorce:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} 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);
|
||||
async execute(client, interaction) {
|
||||
const userData = interaction.data.user;
|
||||
|
||||
data.userData.lover = null;
|
||||
await data.userData.save();
|
||||
if (!userData.lover) return interaction.error("economy/divorce:NOT_MARRIED");
|
||||
const user = client.users.cache.get(userData.lover) || await client.users.fetch(userData.lover);
|
||||
|
||||
const oldLover = await client.findOrCreateUser({
|
||||
id: user.id,
|
||||
});
|
||||
userData.lover = null;
|
||||
|
||||
userData.markModified("lover");
|
||||
await userData.save();
|
||||
|
||||
const oldLover = await client.findOrCreateUser(user.id);
|
||||
oldLover.lover = null;
|
||||
|
||||
oldLover.markModified("lover");
|
||||
await oldLover.save();
|
||||
|
||||
interaction.success("economy/divorce:DIVORCED", {
|
||||
user: user.toString(),
|
||||
});
|
||||
|
||||
user.send({
|
||||
content: interaction.translate("economy/divorce:DIVORCED_U", {
|
||||
user: interaction.member.toString(),
|
||||
}),
|
||||
});
|
||||
try {
|
||||
user.send({
|
||||
content: interaction.translate("economy/divorce:DIVORCED_U", {
|
||||
user: interaction.member.toString(),
|
||||
}),
|
||||
});
|
||||
} catch (e) { /**/ }
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Divorce;
|
||||
module.exports = Divorce;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Leaderboard extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,55 +12,56 @@ class Leaderboard extends BaseCommand {
|
|||
.setName("leaderboard")
|
||||
.setDescription(client.translate("economy/leaderboard:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/leaderboard:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/leaderboard:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/leaderboard:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/leaderboard:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addStringOption(option => option.setName("type")
|
||||
.setDescription(client.translate("owner/debug:TYPE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("owner/debug:TYPE", null, "uk-UA"),
|
||||
"ru": client.translate("owner/debug:TYPE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: client.translate("common:LEVEL"), value: "level" },
|
||||
{ name: client.translate("common:MONEY"), value: "money" },
|
||||
{ name: client.translate("common:REP"), value: "rep" },
|
||||
)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("type")
|
||||
.setDescription(client.translate("owner/debug:TYPE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("owner/debug:TYPE", null, "uk-UA"),
|
||||
ru: client.translate("owner/debug:TYPE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices({ name: client.translate("common:LEVEL"), value: "level" }, { name: client.translate("common:MONEY"), value: "money" }, { name: client.translate("common:REP"), value: "rep" }),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const type = interaction.options.getString("type");
|
||||
const isOnMobile = JSON.stringify(Object.keys(interaction.member.presence.clientStatus)) === JSON.stringify(["mobile"]);
|
||||
if (isOnMobile) interaction.followUp({
|
||||
content: interaction.translate("economy/leaderboard:MOBILE"),
|
||||
ephemeral: true,
|
||||
if (isOnMobile)
|
||||
interaction.followUp({
|
||||
content: interaction.translate("economy/leaderboard:MOBILE"),
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("economy/leaderboard:TABLE", {
|
||||
name: interaction.guild.name,
|
||||
}),
|
||||
iconURL: interaction.guild.iconURL(),
|
||||
},
|
||||
});
|
||||
|
||||
if (type === "money") {
|
||||
const membersLeaderboard = [],
|
||||
membersData = await client.membersData.find({ guildID: interaction.guildId }).lean();
|
||||
|
||||
client.functions.asyncForEach(membersData, member => {
|
||||
await client.functions.asyncForEach(membersData, member => {
|
||||
membersLeaderboard.push({
|
||||
id: member.id,
|
||||
money: member.money + member.bankSold,
|
||||
|
@ -78,23 +79,18 @@ class Leaderboard extends BaseCommand {
|
|||
money += `${data.money}\n`;
|
||||
}
|
||||
|
||||
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({
|
||||
embed.data.fields = [
|
||||
{
|
||||
name: interaction.translate("common:USER"),
|
||||
value: userNames,
|
||||
inline: true,
|
||||
}, {
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:CREDITS"),
|
||||
value: money,
|
||||
inline: true,
|
||||
});
|
||||
},
|
||||
];
|
||||
|
||||
interaction.editReply({
|
||||
embeds: [embed],
|
||||
|
@ -103,7 +99,7 @@ class Leaderboard extends BaseCommand {
|
|||
const membersLeaderboard = [],
|
||||
membersData = await client.membersData.find({ guildID: interaction.guildId }).lean();
|
||||
|
||||
client.functions.asyncForEach(membersData, async member => {
|
||||
await client.functions.asyncForEach(membersData, async member => {
|
||||
membersLeaderboard.push({
|
||||
id: member.id,
|
||||
level: member.level,
|
||||
|
@ -124,31 +120,23 @@ class Leaderboard extends BaseCommand {
|
|||
xp.push(`${data.xp} / ${5 * (data.level * data.level) + 80 * data.level + 100}`);
|
||||
}
|
||||
|
||||
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"),
|
||||
value: userNames.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,
|
||||
},
|
||||
]);
|
||||
embed.data.fields = [
|
||||
{
|
||||
name: interaction.translate("common:USER"),
|
||||
value: userNames.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({
|
||||
embeds: [embed],
|
||||
|
@ -157,7 +145,7 @@ class Leaderboard extends BaseCommand {
|
|||
const usersLeaderboard = [],
|
||||
usersData = await client.usersData.find({ rep: { $gt: 0 } }).lean();
|
||||
|
||||
client.functions.asyncForEach(usersData, async user => {
|
||||
await client.functions.asyncForEach(usersData, async user => {
|
||||
usersLeaderboard.push({
|
||||
id: user.id,
|
||||
rep: user.rep,
|
||||
|
@ -175,23 +163,18 @@ class Leaderboard extends BaseCommand {
|
|||
rep += `${data.rep}\n`;
|
||||
}
|
||||
|
||||
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({
|
||||
embed.data.fields = [
|
||||
{
|
||||
name: interaction.translate("common:USER"),
|
||||
value: userNames,
|
||||
inline: true,
|
||||
}, {
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:REP"),
|
||||
value: rep,
|
||||
inline: true,
|
||||
});
|
||||
},
|
||||
];
|
||||
|
||||
interaction.editReply({
|
||||
embeds: [embed],
|
||||
|
@ -200,4 +183,4 @@ class Leaderboard extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Leaderboard;
|
||||
module.exports = Leaderboard;
|
||||
|
|
|
@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class Marry extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,68 +13,67 @@ class Marry extends BaseCommand {
|
|||
.setName("marry")
|
||||
.setDescription(client.translate("economy/marry:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/marry:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/marry:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/marry:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/marry:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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)),
|
||||
aliases: [],
|
||||
.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/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} 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");
|
||||
async execute(client, interaction) {
|
||||
const userData = interaction.data.user;
|
||||
|
||||
if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED");
|
||||
|
||||
const member = interaction.options.getMember("user");
|
||||
if (member.user.bot) return interaction.error("economy/marry:BOT_USER");
|
||||
if (member.id === interaction.member.id) return interaction.error("economy/marry:YOURSELF");
|
||||
|
||||
const userData = await client.findOrCreateUser({
|
||||
id: member.id,
|
||||
});
|
||||
if (userData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() });
|
||||
const otherUserData = await client.findOrCreateUser(member.id);
|
||||
if (otherUserData.lover) return interaction.error("economy/marry:ALREADY_MARRIED_USER", { user: member.toString() });
|
||||
|
||||
for (const requester in pendings) {
|
||||
const receiver = pendings[requester];
|
||||
|
||||
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", {
|
||||
user: user.toString,
|
||||
});
|
||||
} 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", {
|
||||
user: user.toString(),
|
||||
});
|
||||
} 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", {
|
||||
firstUser: member.toString(),
|
||||
secondUser: user.toString(),
|
||||
});
|
||||
} 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", {
|
||||
firstUser: member.toString(),
|
||||
secondUser: user.toString(),
|
||||
|
@ -84,17 +83,10 @@ class Marry extends BaseCommand {
|
|||
|
||||
pendings[interaction.member.id] = member.id;
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
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),
|
||||
);
|
||||
const row = new ActionRowBuilder().addComponents(
|
||||
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({
|
||||
content: interaction.translate("economy/marry:REQUEST", {
|
||||
|
@ -105,7 +97,7 @@ class Marry extends BaseCommand {
|
|||
});
|
||||
|
||||
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 => {
|
||||
if (i.isButton()) {
|
||||
|
@ -127,35 +119,42 @@ class Marry extends BaseCommand {
|
|||
}
|
||||
|
||||
if (reason) {
|
||||
data.userData.lover = member.id;
|
||||
await data.userData.save();
|
||||
userData.lover = interaction.member.id;
|
||||
userData.lover = member.id;
|
||||
otherUserData.lover = interaction.member.id;
|
||||
|
||||
userData.markModified("lover");
|
||||
otherUserData.markModified("lover");
|
||||
await userData.save();
|
||||
await otherUserData.save();
|
||||
|
||||
const messageOptions = {
|
||||
content: `${member.toString()} :heart: ${interaction.member.toString()}`,
|
||||
files: [{
|
||||
name: "achievement_unlocked3.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked3.png",
|
||||
}],
|
||||
files: [
|
||||
{
|
||||
name: "achievement_unlocked3.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked3.png",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
let sent = false;
|
||||
if (!userData.achievements.married.achieved) {
|
||||
if (!otherUserData.achievements.married.achieved) {
|
||||
interaction.followUp(messageOptions);
|
||||
sent = true;
|
||||
userData.achievements.married.achieved = true;
|
||||
userData.achievements.married.progress.now = 1;
|
||||
userData.markModified("achievements.married");
|
||||
await userData.save();
|
||||
otherUserData.achievements.married.achieved = true;
|
||||
otherUserData.achievements.married.progress.now = 1;
|
||||
|
||||
otherUserData.markModified("achievements");
|
||||
await otherUserData.save();
|
||||
}
|
||||
|
||||
if (!data.userData.achievements.married.achieved) {
|
||||
if (!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();
|
||||
userData.achievements.married.achieved = true;
|
||||
userData.achievements.married.progress.now = 1;
|
||||
|
||||
userData.markModified("achievements");
|
||||
await userData.save();
|
||||
}
|
||||
|
||||
return interaction.editReply({
|
||||
|
@ -165,17 +164,15 @@ class Marry extends BaseCommand {
|
|||
}),
|
||||
components: [],
|
||||
});
|
||||
} else {
|
||||
return interaction.editReply({
|
||||
content: interaction.translate("economy/marry:DENIED", {
|
||||
creator: interaction.member.toString(),
|
||||
partner: member.toString(),
|
||||
}),
|
||||
components: [],
|
||||
});
|
||||
}
|
||||
} else return interaction.editReply({
|
||||
content: interaction.translate("economy/marry:DENIED", {
|
||||
creator: interaction.member.toString(),
|
||||
partner: member.toString(),
|
||||
}, "error"),
|
||||
components: [],
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Marry;
|
||||
module.exports = Marry;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Money extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,46 +12,39 @@ class Money extends BaseCommand {
|
|||
.setName("money")
|
||||
.setDescription(client.translate("economy/money:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/money:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/money:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/money:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/money:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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"),
|
||||
})),
|
||||
aliases: [],
|
||||
.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"),
|
||||
}),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const member = interaction.options.getMember("user") || interaction.member;
|
||||
if (member.user.bot) return interaction.error("economy/money:BOT_USER");
|
||||
|
||||
const memberData = member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({
|
||||
id: member.id,
|
||||
guildId: interaction.guildId,
|
||||
});
|
||||
const memberData = member.id === interaction.user.id ? interaction.data.member : 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));
|
||||
|
||||
let globalMoney = 0;
|
||||
await client.functions.asyncForEach(guilds, async guild => {
|
||||
const data = await client.findOrCreateMember({
|
||||
|
@ -61,14 +54,14 @@ class Money extends BaseCommand {
|
|||
globalMoney += data.money + data.bankSold;
|
||||
});
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("economy/money:TITLE", {
|
||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
||||
user: member.user.getUsername(),
|
||||
}),
|
||||
iconURL: member.user.displayAvatarURL(),
|
||||
})
|
||||
.addFields([
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
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"))}`,
|
||||
|
@ -84,15 +77,13 @@ 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"))}`,
|
||||
inline: true,
|
||||
},
|
||||
])
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
});
|
||||
],
|
||||
});
|
||||
|
||||
interaction.editReply({
|
||||
embeds: [embed],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Money;
|
||||
module.exports = Money;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Pay extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,85 +12,89 @@ class Pay extends BaseCommand {
|
|||
.setName("pay")
|
||||
.setDescription(client.translate("economy/pay:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/pay:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/pay:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/pay:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/pay:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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))
|
||||
.addIntegerOption(option => option.setName("amount")
|
||||
.setDescription(client.translate("common:INT"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:INT", null, "uk-UA"),
|
||||
"ru": client.translate("common:INT", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.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),
|
||||
)
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("amount")
|
||||
.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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} 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");
|
||||
async execute(client, interaction) {
|
||||
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");
|
||||
|
||||
const amount = interaction.options.getInteger("amount");
|
||||
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
|
||||
if (amount > data.memberData.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"))}`,
|
||||
});
|
||||
if (amount > memberData.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"))}`,
|
||||
});
|
||||
|
||||
const memberData = await client.findOrCreateMember({
|
||||
id: member.id,
|
||||
const otherMemberData = await client.findOrCreateMember({
|
||||
id: otherMember.id,
|
||||
guildId: interaction.guildId,
|
||||
});
|
||||
|
||||
data.memberData.money -= amount;
|
||||
await data.memberData.save();
|
||||
memberData.money -= amount;
|
||||
|
||||
memberData.money += amount;
|
||||
memberData.markModified("money");
|
||||
await memberData.save();
|
||||
|
||||
otherMemberData.money += amount;
|
||||
|
||||
otherMemberData.markModified("money");
|
||||
await otherMemberData.save();
|
||||
|
||||
const info1 = {
|
||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
||||
user: otherMember.user.getUsername(),
|
||||
amount: amount,
|
||||
date: Date.now(),
|
||||
type: "send",
|
||||
};
|
||||
data.memberData.transactions.push(info1);
|
||||
memberData.transactions.push(info1);
|
||||
|
||||
const info2 = {
|
||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
||||
user: otherMember.user.getUsername(),
|
||||
amount: amount,
|
||||
date: Date.now(),
|
||||
type: "got",
|
||||
};
|
||||
data.memberData.transactions.push(info2);
|
||||
otherMemberData.transactions.push(info2);
|
||||
|
||||
interaction.success("economy/pay:SUCCESS", {
|
||||
user: member.toString(),
|
||||
user: otherMember.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"))}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Pay;
|
||||
module.exports = Pay;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Profile extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,48 +12,37 @@ class Profile extends BaseCommand {
|
|||
.setName("profile")
|
||||
.setDescription(client.translate("economy/profile:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/profile:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/profile:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/profile:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/profile:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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"),
|
||||
})),
|
||||
aliases: [],
|
||||
.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"),
|
||||
}),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const member = interaction.options.getMember("user") || interaction.member;
|
||||
if (member.user.bot) return interaction.error("economy/profile:BOT_USER");
|
||||
|
||||
const memberData = (member.id === interaction.user.id ? data.memberData : await client.findOrCreateMember({
|
||||
id: member.id,
|
||||
guildId: interaction.guildId,
|
||||
}));
|
||||
|
||||
const userData = (member.id === interaction.user.id ? data.userData : await client.findOrCreateUser({
|
||||
id: member.id,
|
||||
}));
|
||||
const memberData = member.id === interaction.user.id ? interaction.data.member : await client.findOrCreateMember({ id: member.id, guildId: interaction.guildId });
|
||||
const userData = member.id === interaction.user.id ? interaction.data.user : await client.findOrCreateUser(member.id);
|
||||
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));
|
||||
|
@ -68,19 +57,15 @@ class Profile extends BaseCommand {
|
|||
|
||||
const lover = client.users.cache.get(userData.lover);
|
||||
|
||||
const profileEmbed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("economy/profile:TITLE", {
|
||||
user: member.nickname,
|
||||
user: member.user.getUsername(),
|
||||
}),
|
||||
iconURL: member.displayAvatarURL(),
|
||||
})
|
||||
.setImage("attachment://achievements.png")
|
||||
.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})`,
|
||||
},
|
||||
},
|
||||
image: "attachment://achievements.png",
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("economy/profile:BIO"),
|
||||
value: userData.bio ? userData.bio : interaction.translate("common:UNKNOWN"),
|
||||
|
@ -107,7 +92,7 @@ class Profile extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:LEVEL"),
|
||||
value:`**${memberData.level}**`,
|
||||
value: `**${memberData.level}**`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
@ -117,40 +102,38 @@ class Profile extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:REGISTERED"),
|
||||
value: client.functions.printDate(client, new Date(memberData.registeredAt)),
|
||||
value: `<t:${Math.floor(memberData.registeredAt / 1000)}:f>`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:BIRTHDATE"),
|
||||
value: (!userData.birthdate ? interaction.translate("common:NOT_DEFINED") : client.functions.printDate(client, new Date(userData.birthdate))),
|
||||
value: !userData.birthdate ? interaction.translate("common:NOT_DEFINED") : `<t:${userData.birthdate}:D>`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:LOVER"),
|
||||
value: (!userData.lover ? interaction.translate("common:NOT_DEFINED") : lover.discriminator === "0" ? lover.username : lover.tag),
|
||||
value: !userData.lover ? interaction.translate("common:NOT_DEFINED") : lover.getUsername(),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("economy/profile:ACHIEVEMENTS"),
|
||||
value: interaction.translate("economy/profile:ACHIEVEMENTS_CONTENT"),
|
||||
},
|
||||
])
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
})
|
||||
.setTimestamp();
|
||||
],
|
||||
});
|
||||
|
||||
const buffer = await userData.getAchievements();
|
||||
const achievements = await userData.getAchievements();
|
||||
|
||||
interaction.editReply({
|
||||
embeds: [profileEmbed],
|
||||
files: [{
|
||||
name: "achievements.png",
|
||||
attachment: buffer,
|
||||
}],
|
||||
embeds: [embed],
|
||||
files: [
|
||||
{
|
||||
name: "achievements.png",
|
||||
attachment: achievements,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Profile;
|
||||
module.exports = Profile;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Rep extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,75 +12,75 @@ class Rep extends BaseCommand {
|
|||
.setName("rep")
|
||||
.setDescription(client.translate("economy/rep:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/rep:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/rep:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/rep:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/rep:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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)),
|
||||
aliases: [],
|
||||
.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/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const isInCooldown = data.userData.cooldowns?.rep;
|
||||
async execute(client, interaction) {
|
||||
const userData = interaction.data.user,
|
||||
isInCooldown = userData.cooldowns?.rep;
|
||||
|
||||
if (isInCooldown) {
|
||||
if (isInCooldown > Date.now()) return interaction.error("economy/rep:COOLDOWN", {
|
||||
time: client.functions.convertTime(client, isInCooldown, true, true, data.guildData.language),
|
||||
});
|
||||
if (isInCooldown > Date.now())
|
||||
return interaction.error("economy/rep:COOLDOWN", {
|
||||
time: `<t:${Math.floor(isInCooldown / 1000)}:R>`,
|
||||
});
|
||||
}
|
||||
|
||||
const user = interaction.options.getUser("user");
|
||||
if (user.bot) return interaction.error("economy/rep:BOT_USER");
|
||||
if (user.id === interaction.user.id) return interaction.error("economy/rep:YOURSELF");
|
||||
|
||||
const toWait = Date.now() + 21600000; // 12 hours
|
||||
if (!data.userData.cooldowns) data.userData.cooldowns = {};
|
||||
const toWait = Math.floor((Date.now() + 12 * 60 * 60 * 1000) / 1000); // 12 hours
|
||||
if (!userData.cooldowns) userData.cooldowns = {};
|
||||
|
||||
data.userData.cooldowns.rep = toWait;
|
||||
data.userData.markModified("cooldowns");
|
||||
await data.userData.save();
|
||||
userData.cooldowns.rep = toWait;
|
||||
|
||||
const userData = await client.findOrCreateUser({
|
||||
id: user.id,
|
||||
});
|
||||
userData.markModified("cooldowns");
|
||||
await userData.save();
|
||||
|
||||
userData.rep++;
|
||||
const otherUserData = await client.findOrCreateUser(user.id);
|
||||
|
||||
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 (userData.achievements.rep.progress.now >= userData.achievements.rep.progress.total) {
|
||||
userData.achievements.rep.achieved = true;
|
||||
otherUserData.rep++;
|
||||
|
||||
if (!otherUserData.achievements.rep.achieved) {
|
||||
otherUserData.achievements.rep.progress.now = otherUserData.rep > otherUserData.achievements.rep.progress.total ? otherUserData.achievements.rep.progress.total : otherUserData.rep;
|
||||
if (otherUserData.achievements.rep.progress.now >= otherUserData.achievements.rep.progress.total) {
|
||||
otherUserData.achievements.rep.achieved = true;
|
||||
interaction.followUp({
|
||||
content: `${user}`,
|
||||
files: [{
|
||||
name: "achievement_unlocked6.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked6.png",
|
||||
}],
|
||||
files: [
|
||||
{
|
||||
name: "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", {
|
||||
user: user.toString(),
|
||||
|
@ -88,4 +88,4 @@ class Rep extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Rep;
|
||||
module.exports = Rep;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Rob extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,87 +12,90 @@ class Rob extends BaseCommand {
|
|||
.setName("rob")
|
||||
.setDescription(client.translate("economy/rob:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/rob:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/rob:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/rob:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/rob:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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))
|
||||
.addIntegerOption(option => option.setName("amount")
|
||||
.setDescription(client.translate("common:INT"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:INT", null, "uk-UA"),
|
||||
"ru": client.translate("common:INT", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.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),
|
||||
)
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("amount")
|
||||
.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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} 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");
|
||||
async execute(client, interaction) {
|
||||
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");
|
||||
|
||||
const amount = interaction.options.getInteger("amount");
|
||||
if (amount <= 0) return interaction.error("misc:MORE_THAN_ZERO");
|
||||
|
||||
const memberData = await client.findOrCreateMember({
|
||||
id: member.id,
|
||||
const otherMemberData = await client.findOrCreateMember({
|
||||
id: otherMember.id,
|
||||
guildId: interaction.guildId,
|
||||
});
|
||||
if (amount > memberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: member.toString() });
|
||||
if (amount > otherMemberData.money) return interaction.error("economy/rob:NOT_ENOUGH_MEMBER", { user: otherMember.toString() });
|
||||
|
||||
const isInCooldown = memberData.cooldowns.rob || 0;
|
||||
const isInCooldown = otherMemberData.cooldowns.rob || 0;
|
||||
if (isInCooldown) {
|
||||
if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: member.toString() });
|
||||
if (isInCooldown > Date.now()) return interaction.error("economy/rob:COOLDOWN", { user: otherMember.toString() });
|
||||
}
|
||||
|
||||
const potentiallyLose = Math.floor(amount * 1.5);
|
||||
if (potentiallyLose > data.memberData.money) 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"))}`,
|
||||
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"))}`,
|
||||
});
|
||||
if (potentiallyLose > memberData.money)
|
||||
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"))}`,
|
||||
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);
|
||||
|
||||
if (itsAWon) {
|
||||
const toWait = Date.now() + (6 * 60 * 60 * 1000),
|
||||
const toWait = Date.now() + 6 * 60 * 60 * 1000,
|
||||
randomNum = client.functions.randomNum(1, 2);
|
||||
|
||||
memberData.cooldowns.rob = toWait;
|
||||
memberData.markModified("cooldowns");
|
||||
await memberData.save();
|
||||
otherMemberData.cooldowns.rob = toWait;
|
||||
|
||||
otherMemberData.markModified("cooldowns");
|
||||
await otherMemberData.save();
|
||||
|
||||
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"))}`,
|
||||
user: member.toString(),
|
||||
user: otherMember.toString(),
|
||||
});
|
||||
|
||||
data.memberData.money += amount;
|
||||
memberData.money -= amount;
|
||||
memberData.money += amount;
|
||||
otherMemberData.money -= amount;
|
||||
|
||||
memberData.markModified("money");
|
||||
otherMemberData.markModified("money");
|
||||
await memberData.save();
|
||||
await data.memberData.save();
|
||||
await otherMemberData.save();
|
||||
} else {
|
||||
const won = Math.floor(amount * 0.9),
|
||||
randomNum = client.functions.randomNum(1, 2);
|
||||
|
@ -100,16 +103,18 @@ class Rob extends BaseCommand {
|
|||
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"))}`,
|
||||
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: member.toString(),
|
||||
user: otherMember.toString(),
|
||||
});
|
||||
|
||||
data.memberData.money -= potentiallyLose;
|
||||
memberData.money += won;
|
||||
memberData.money -= potentiallyLose;
|
||||
otherMemberData.money += won;
|
||||
|
||||
memberData.markModified("money");
|
||||
otherMemberData.markModified("money");
|
||||
await memberData.save();
|
||||
await data.memberData.save();
|
||||
await otherMemberData.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Rob;
|
||||
module.exports = Rob;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Setbio extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,43 +12,42 @@ class Setbio extends BaseCommand {
|
|||
.setName("setbio")
|
||||
.setDescription(client.translate("economy/setbio:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/setbio:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/setbio:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/setbio:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/setbio:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option => option.setName("text")
|
||||
.setDescription(client.translate("economy/profile:BIO"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/profile:BIO", null, "uk-UA"),
|
||||
"ru": client.translate("economy/profile:BIO", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("text")
|
||||
.setDescription(client.translate("economy/profile:BIO"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("economy/profile:BIO", null, "uk-UA"),
|
||||
ru: client.translate("economy/profile:BIO", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const newBio = interaction.options.getString("text");
|
||||
async execute(client, interaction) {
|
||||
const userData = interaction.data.user,
|
||||
newBio = interaction.options.getString("text");
|
||||
if (newBio.length > 150) return interaction.error("economy/setbio:MAX_CHARACTERS");
|
||||
|
||||
data.userData.bio = newBio;
|
||||
await data.userData.save();
|
||||
userData.bio = newBio;
|
||||
|
||||
userData.markModified("bio");
|
||||
await userData.save();
|
||||
|
||||
interaction.success("economy/setbio:SUCCESS");
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Setbio;
|
||||
module.exports = Setbio;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Slots extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,52 +12,53 @@ class Slots extends BaseCommand {
|
|||
.setName("slots")
|
||||
.setDescription(client.translate("economy/slots:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/slots:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/slots:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/slots:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/slots:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addIntegerOption(option => option.setName("amount")
|
||||
.setDescription(client.translate("common:INT"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:INT", null, "uk-UA"),
|
||||
"ru": client.translate("common:INT", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("amount")
|
||||
.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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const 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 });
|
||||
const { member: memberData, user: userData } = interaction.data,
|
||||
amount = interaction.options.getInteger("amount");
|
||||
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 = ["🍎", "🍐", "🍌", "🍇", "🍉", "🍒", "🍓"];
|
||||
|
||||
let i1 = 0, j1 = 0, k1 = 0,
|
||||
i2 = 1, j2 = 1, k2 = 1,
|
||||
i3 = 2, j3 = 2, k3 = 2;
|
||||
let i1 = 0,
|
||||
j1 = 0,
|
||||
k1 = 0,
|
||||
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) {
|
||||
if (!isJackpot) number = number * 1.5;
|
||||
|
@ -76,69 +77,78 @@ class Slots extends BaseCommand {
|
|||
}, 4000);
|
||||
|
||||
async function end() {
|
||||
let msg = "[ :slot_machine: | **СЛОТЫ** ]\n------------------\n";
|
||||
let msg = "[ :slot_machine: | **SLOTS** ]\n------------------\n";
|
||||
|
||||
i1 = (i1 < fruits.length - 1) ? i1 + 1 : 0;
|
||||
i2 = (i2 < fruits.length - 1) ? i2 + 1 : 0;
|
||||
i3 = (i3 < fruits.length - 1) ? i3 + 1 : 0;
|
||||
j1 = (j1 < fruits.length - 1) ? j1 + 1 : 0;
|
||||
j2 = (j2 < fruits.length - 1) ? j2 + 1 : 0;
|
||||
j3 = (j3 < fruits.length - 1) ? j3 + 1 : 0;
|
||||
k1 = (k1 < fruits.length - 1) ? k1 + 1 : 0;
|
||||
k2 = (k2 < fruits.length - 1) ? k2 + 1 : 0;
|
||||
k3 = (k3 < fruits.length - 1) ? k3 + 1 : 0;
|
||||
i1 = i1 < fruits.length - 1 ? i1 + 1 : 0;
|
||||
i2 = i2 < fruits.length - 1 ? i2 + 1 : 0;
|
||||
i3 = i3 < fruits.length - 1 ? i3 + 1 : 0;
|
||||
j1 = j1 < fruits.length - 1 ? j1 + 1 : 0;
|
||||
j2 = j2 < fruits.length - 1 ? j2 + 1 : 0;
|
||||
j3 = j3 < fruits.length - 1 ? j3 + 1 : 0;
|
||||
k1 = k1 < fruits.length - 1 ? k1 + 1 : 0;
|
||||
k2 = k2 < fruits.length - 1 ? k2 + 1 : 0;
|
||||
k3 = k3 < fruits.length - 1 ? k3 + 1 : 0;
|
||||
|
||||
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][i3] + " : " + colonnes[1][j3] + " : " + colonnes[2][k3] + "\n------------------\n";
|
||||
|
||||
if ((colonnes[0][i2] == colonnes[1][j2]) && (colonnes[1][j2] == colonnes[2][k2])) {
|
||||
msg += "| : : : **" + (interaction.translate("common:VICTORY").toUpperCase()) + "** : : : |";
|
||||
if (colonnes[0][i2] == colonnes[1][j2] && colonnes[1][j2] == colonnes[2][k2]) {
|
||||
msg += "| : : : **" + interaction.translate("common:VICTORY").toUpperCase() + "** : : : |";
|
||||
await interaction.editReply({
|
||||
content: msg,
|
||||
});
|
||||
|
||||
const credits = getCredits(amount, true);
|
||||
interaction.followUp({
|
||||
content: "**!! ДЖЕКПОТ !!**\n" + interaction.translate("economy/slots:VICTORY", {
|
||||
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
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(),
|
||||
}),
|
||||
content:
|
||||
"**!! JACKPOT !!**\n" +
|
||||
interaction.translate("economy/slots:VICTORY", {
|
||||
money: `**${amount}** ${client.functions.getNoun(amount, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
|
||||
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;
|
||||
|
||||
data.memberData.money += toAdd;
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/slots:DESCRIPTION"),
|
||||
amount: toAdd,
|
||||
date: Date.now(),
|
||||
type: "got",
|
||||
};
|
||||
data.memberData.transactions.push(info);
|
||||
|
||||
if (!data.userData.achievements.slots.achieved) {
|
||||
data.userData.achievements.slots.progress.now += 1;
|
||||
if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) {
|
||||
data.userData.achievements.slots.achieved = true;
|
||||
memberData.money += toAdd;
|
||||
memberData.transactions.push(info);
|
||||
|
||||
if (!userData.achievements.slots.achieved) {
|
||||
userData.achievements.slots.progress.now += 1;
|
||||
if (userData.achievements.slots.progress.now === userData.achievements.slots.progress.total) {
|
||||
userData.achievements.slots.achieved = true;
|
||||
interaction.followUp({
|
||||
files: [{
|
||||
name: "achievement_unlocked4.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked4.png",
|
||||
}],
|
||||
files: [
|
||||
{
|
||||
name: "achievement_unlocked4.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked4.png",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
data.userData.markModified("achievements.slots");
|
||||
await data.userData.save();
|
||||
|
||||
userData.markModified("achievements");
|
||||
await userData.save();
|
||||
}
|
||||
await data.memberData.save();
|
||||
|
||||
memberData.markModified("money");
|
||||
memberData.markModified("transactions");
|
||||
await memberData.save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
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({
|
||||
content: msg,
|
||||
});
|
||||
|
@ -159,28 +169,36 @@ class Slots extends BaseCommand {
|
|||
date: Date.now(),
|
||||
type: "got",
|
||||
};
|
||||
data.memberData.transactions.push(info);
|
||||
data.memberData.money += toAdd;
|
||||
|
||||
if (!data.userData.achievements.slots.achieved) {
|
||||
data.userData.achievements.slots.progress.now += 1;
|
||||
if (data.userData.achievements.slots.progress.now === data.userData.achievements.slots.progress.total) {
|
||||
data.userData.achievements.slots.achieved = true;
|
||||
memberData.money += toAdd;
|
||||
memberData.transactions.push(info);
|
||||
|
||||
if (!userData.achievements.slots.achieved) {
|
||||
userData.achievements.slots.progress.now += 1;
|
||||
if (userData.achievements.slots.progress.now === userData.achievements.slots.progress.total) {
|
||||
userData.achievements.slots.achieved = true;
|
||||
interaction.followUp({
|
||||
files: [{
|
||||
name: "achievement_unlocked4.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked4.png",
|
||||
}],
|
||||
files: [
|
||||
{
|
||||
name: "achievement_unlocked4.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked4.png",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
data.userData.markModified("achievements.slots");
|
||||
await data.userData.save();
|
||||
|
||||
userData.markModified("achievements");
|
||||
await userData.save();
|
||||
}
|
||||
await data.memberData.save();
|
||||
|
||||
memberData.markModified("money");
|
||||
memberData.markModified("transactions");
|
||||
await memberData.save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
msg += "| : : : **" + (interaction.translate("common:DEFEAT").toUpperCase()) + "** : : : |";
|
||||
msg += "| : : : **" + interaction.translate("common:DEFEAT").toUpperCase() + "** : : : |";
|
||||
interaction.followUp({
|
||||
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"))}`,
|
||||
|
@ -194,30 +212,36 @@ class Slots extends BaseCommand {
|
|||
date: Date.now(),
|
||||
type: "send",
|
||||
};
|
||||
data.memberData.transactions.push(info);
|
||||
data.memberData.money -= amount;
|
||||
|
||||
if (!data.userData.achievements.slots.achieved) {
|
||||
data.userData.achievements.slots.progress.now = 0;
|
||||
data.userData.markModified("achievements.slots");
|
||||
await data.userData.save();
|
||||
memberData.money -= amount;
|
||||
memberData.transactions.push(info);
|
||||
|
||||
if (!userData.achievements.slots.achieved) {
|
||||
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;
|
||||
}
|
||||
|
||||
async function editMsg() {
|
||||
let msg = "[ :slot_machine: | **СЛОТЫ** ]\n------------------\n";
|
||||
let msg = "[ :slot_machine: | **SLOTS** ]\n------------------\n";
|
||||
|
||||
i1 = (i1 < fruits.length - 1) ? i1 + 1 : 0;
|
||||
i2 = (i2 < fruits.length - 1) ? i2 + 1 : 0;
|
||||
i3 = (i3 < fruits.length - 1) ? i3 + 1 : 0;
|
||||
j1 = (j1 < fruits.length - 1) ? j1 + 1 : 0;
|
||||
j2 = (j2 < fruits.length - 1) ? j2 + 1 : 0;
|
||||
j3 = (j3 < fruits.length - 1) ? j3 + 1 : 0;
|
||||
k1 = (k1 < fruits.length - 1) ? k1 + 1 : 0;
|
||||
k2 = (k2 < fruits.length - 1) ? k2 + 1 : 0;
|
||||
k3 = (k3 < fruits.length - 1) ? k3 + 1 : 0;
|
||||
i1 = i1 < fruits.length - 1 ? i1 + 1 : 0;
|
||||
i2 = i2 < fruits.length - 1 ? i2 + 1 : 0;
|
||||
i3 = i3 < fruits.length - 1 ? i3 + 1 : 0;
|
||||
j1 = j1 < fruits.length - 1 ? j1 + 1 : 0;
|
||||
j2 = j2 < fruits.length - 1 ? j2 + 1 : 0;
|
||||
j3 = j3 < fruits.length - 1 ? j3 + 1 : 0;
|
||||
k1 = k1 < fruits.length - 1 ? k1 + 1 : 0;
|
||||
k2 = k2 < fruits.length - 1 ? k2 + 1 : 0;
|
||||
k3 = k3 < fruits.length - 1 ? k3 + 1 : 0;
|
||||
|
||||
msg += colonnes[0][i1] + " : " + colonnes[1][j1] + " : " + colonnes[2][k1] + "\n";
|
||||
msg += colonnes[0][i2] + " : " + colonnes[1][j2] + " : " + colonnes[2][k2] + " **<**\n";
|
||||
|
@ -230,4 +254,4 @@ class Slots extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Slots;
|
||||
module.exports = Slots;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Transactions extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,77 +12,78 @@ class Transactions extends BaseCommand {
|
|||
.setName("transactions")
|
||||
.setDescription(client.translate("economy/transactions:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/transactions:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/transactions:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/transactions:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/transactions:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addBooleanOption(option => option.setName("clear")
|
||||
.setDescription(client.translate("economy/transactions:CLEAR"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/transactions:CLEAR", null, "uk-UA"),
|
||||
"ru": client.translate("economy/transactions:CLEAR", null, "ru-RU"),
|
||||
})),
|
||||
aliases: [],
|
||||
.addBooleanOption(option =>
|
||||
option
|
||||
.setName("clear")
|
||||
.setDescription(client.translate("economy/transactions:CLEAR"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("economy/transactions:CLEAR", null, "uk-UA"),
|
||||
ru: client.translate("economy/transactions:CLEAR", null, "ru-RU"),
|
||||
}),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
const memberData = interaction.data.member;
|
||||
|
||||
if (interaction.options.getBoolean("clear")) {
|
||||
data.memberData.transactions = [];
|
||||
await data.memberData.save();
|
||||
memberData.transactions = [];
|
||||
|
||||
memberData.markModified("transactions");
|
||||
await memberData.save();
|
||||
|
||||
return interaction.success("economy/transactions:CLEARED", null, { ephemeral: true });
|
||||
}
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("economy/transactions:EMBED_TRANSACTIONS"),
|
||||
iconURL: interaction.member.displayAvatarURL(),
|
||||
})
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
});
|
||||
|
||||
const transactions = data.memberData.transactions,
|
||||
sortedTransactions = [ [], [] ];
|
||||
},
|
||||
});
|
||||
const transactions = memberData.transactions,
|
||||
sortedTransactions = [[], []];
|
||||
|
||||
transactions.slice(-20).forEach(t => {
|
||||
const array = t.type === "got" ? sortedTransactions[0] : sortedTransactions[1];
|
||||
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`);
|
||||
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",
|
||||
)}: <t:${Math.floor(t.date / 1000)}:f>\n`,
|
||||
);
|
||||
});
|
||||
|
||||
if (transactions.length < 1) {
|
||||
embed.setDescription(interaction.translate("economy/transactions:NO_TRANSACTIONS"));
|
||||
embed.data.description = interaction.translate("economy/transactions:NO_TRANSACTIONS");
|
||||
} else {
|
||||
if (sortedTransactions[0].length > 0) embed.addFields([
|
||||
{
|
||||
name: interaction.translate("economy/transactions:T_GOT"),
|
||||
value: sortedTransactions[0].join("\n"),
|
||||
inline: true,
|
||||
},
|
||||
]);
|
||||
if (sortedTransactions[1].length > 0) embed.addFields([
|
||||
{
|
||||
name: interaction.translate("economy/transactions:T_SEND"),
|
||||
value: sortedTransactions[1].join("\n"),
|
||||
inline: true,
|
||||
},
|
||||
]);
|
||||
if (sortedTransactions[0].length > 0)
|
||||
embed.data.fields.push([
|
||||
{
|
||||
name: interaction.translate("economy/transactions:T_GOT"),
|
||||
value: sortedTransactions[0].join("\n"),
|
||||
inline: true,
|
||||
},
|
||||
]);
|
||||
if (sortedTransactions[1].length > 0)
|
||||
embed.data.fields.push([
|
||||
{
|
||||
name: interaction.translate("economy/transactions:T_SEND"),
|
||||
value: sortedTransactions[1].join("\n"),
|
||||
inline: true,
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
interaction.reply({
|
||||
|
@ -91,4 +92,4 @@ class Transactions extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Transactions;
|
||||
module.exports = Transactions;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
|
||||
const { SlashCommandBuilder, parseEmoji } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Work extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,63 +12,54 @@ class Work extends BaseCommand {
|
|||
.setName("work")
|
||||
.setDescription(client.translate("economy/work:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("economy/work:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("economy/work:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("economy/work:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("economy/work:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
const isInCooldown = data.memberData.cooldowns?.work;
|
||||
async execute(client, interaction) {
|
||||
const { member: memberData, user: userData } = interaction.data,
|
||||
isInCooldown = memberData.cooldowns?.work;
|
||||
|
||||
if (isInCooldown) {
|
||||
if (isInCooldown > Date.now()) return interaction.error("economy/work:COOLDOWN", {
|
||||
time: client.functions.convertTime(client, isInCooldown, true, true, data.guildData.language),
|
||||
});
|
||||
if (isInCooldown > Date.now())
|
||||
return interaction.error("economy/work:COOLDOWN", {
|
||||
time: `<t:${Math.floor(isInCooldown / 1000)}:R>`,
|
||||
});
|
||||
}
|
||||
if (Date.now() > data.memberData.cooldowns.work + (24 * 60 * 60 * 1000)) data.memberData.workStreak = 0;
|
||||
|
||||
const toWait = Date.now() + (24 * 60 * 60 * 1000); // 24 hours
|
||||
data.memberData.cooldowns.work = toWait;
|
||||
data.memberData.markModified("cooldowns");
|
||||
if (Date.now() > memberData.cooldowns.work + 24 * 60 * 60 * 1000) memberData.workStreak = 0;
|
||||
|
||||
data.memberData.workStreak = (data.memberData.workStreak || 0) + 1;
|
||||
await data.memberData.save();
|
||||
const toWait = Math.floor((Date.now() + 24 * 60 * 60 * 1000) / 1000); // 24 hours
|
||||
memberData.cooldowns.work = toWait;
|
||||
memberData.workStreak = (memberData.workStreak || 0) + 1;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setFooter({
|
||||
memberData.markModified("cooldowns");
|
||||
memberData.markModified("workStreak");
|
||||
await memberData.save();
|
||||
|
||||
const embed = client.embed({
|
||||
footer: {
|
||||
text: interaction.translate("economy/work:AWARD"),
|
||||
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;
|
||||
|
||||
if (data.memberData.workStreak >= 5) {
|
||||
if (memberData.workStreak >= 5) {
|
||||
won += 200;
|
||||
embed.addFields([
|
||||
embed.data.fields = [
|
||||
{
|
||||
name: interaction.translate("economy/work:SALARY"),
|
||||
value: interaction.translate("economy/work:SALARY_CONTENT", {
|
||||
|
@ -79,16 +70,17 @@ class Work extends BaseCommand {
|
|||
name: interaction.translate("economy/work:STREAK"),
|
||||
value: interaction.translate("economy/work:STREAK_CONTENT"),
|
||||
},
|
||||
]);
|
||||
data.memberData.workStreak = 0;
|
||||
];
|
||||
|
||||
memberData.workStreak = 0;
|
||||
} else {
|
||||
for (let i = 0; i < award.length; i++) {
|
||||
if (data.memberData.workStreak > i) {
|
||||
if (memberData.workStreak > i) {
|
||||
const letter = parseEmoji(award[i]).name.split("_")[1];
|
||||
award[i] = `:regional_indicator_${letter.toLowerCase()}:`;
|
||||
}
|
||||
}
|
||||
embed.addFields([
|
||||
embed.data.fields = [
|
||||
{
|
||||
name: interaction.translate("economy/work:SALARY"),
|
||||
value: interaction.translate("economy/work:SALARY_CONTENT", {
|
||||
|
@ -99,11 +91,13 @@ class Work extends BaseCommand {
|
|||
name: interaction.translate("economy/work:STREAK"),
|
||||
value: award.join(""),
|
||||
},
|
||||
]);
|
||||
];
|
||||
}
|
||||
|
||||
data.memberData.money += won;
|
||||
await data.memberData.save();
|
||||
memberData.money += won;
|
||||
|
||||
memberData.markModified("money");
|
||||
await memberData.save();
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/work:SALARY"),
|
||||
|
@ -111,26 +105,30 @@ class Work extends BaseCommand {
|
|||
date: Date.now(),
|
||||
type: "got",
|
||||
};
|
||||
data.memberData.transactions.push(info);
|
||||
memberData.transactions.push(info);
|
||||
|
||||
const messageOptions = {
|
||||
embeds: [embed],
|
||||
};
|
||||
if (!data.userData.achievements.work.achieved) {
|
||||
data.userData.achievements.work.progress.now += 1;
|
||||
if (data.userData.achievements.work.progress.now === data.userData.achievements.work.progress.total) {
|
||||
messageOptions.files = [{
|
||||
name: "unlocked.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked1.png",
|
||||
}];
|
||||
data.userData.achievements.work.achieved = true;
|
||||
|
||||
if (!userData.achievements.work.achieved) {
|
||||
userData.achievements.work.progress.now += 1;
|
||||
if (userData.achievements.work.progress.now === userData.achievements.work.progress.total) {
|
||||
messageOptions.files = [
|
||||
{
|
||||
name: "unlocked.png",
|
||||
attachment: "./assets/img/achievements/achievement_unlocked1.png",
|
||||
},
|
||||
];
|
||||
userData.achievements.work.achieved = true;
|
||||
}
|
||||
data.userData.markModified("achievements.work");
|
||||
await data.userData.save();
|
||||
|
||||
userData.markModified("achievements");
|
||||
await userData.save();
|
||||
}
|
||||
|
||||
interaction.reply(messageOptions);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Work;
|
||||
module.exports = Work;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Eightball extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,47 +12,51 @@ class Eightball extends BaseCommand {
|
|||
.setName("8ball")
|
||||
.setDescription(client.translate("fun/8ball:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/8ball:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/8ball:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("fun/8ball:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/8ball:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option => option.setName("question")
|
||||
.setDescription(client.translate("fun/8ball:QUESTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/8ball:QUESTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/8ball:QUESTION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("question")
|
||||
.setDescription(client.translate("fun/8ball:QUESTION"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("fun/8ball:QUESTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/8ball:QUESTION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const question = interaction.options.getString("question");
|
||||
const answer = interaction.translate(`fun/8ball:RESPONSE_${client.functions.randomNum(1, 20)}`);
|
||||
const embed = client.embed({
|
||||
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);
|
||||
|
||||
interaction.replyT("fun/8ball:ANSWER", {
|
||||
question,
|
||||
answer,
|
||||
}, { edit: true });
|
||||
interaction.editReply({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Eightball;
|
||||
module.exports = Eightball;
|
||||
|
|
|
@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class Cat extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,37 +13,32 @@ class Cat extends BaseCommand {
|
|||
.setName("cat")
|
||||
.setDescription(client.translate("fun/cat:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/cat:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/cat:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("fun/cat:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/cat: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("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const res = await fetch("https://and-here-is-my-code.glitch.me/img/cat").then(response => response.json());
|
||||
const res = await fetch("https://api.thecatapi.com/v1/images/search").then(r => r.json());
|
||||
const cat = res[0].url;
|
||||
|
||||
interaction.editReply({
|
||||
content: res.Link,
|
||||
const embed = client.embed({
|
||||
image: cat,
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Cat;
|
||||
module.exports = Cat;
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
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;
|
|
@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class Dog extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,37 +13,32 @@ class Dog extends BaseCommand {
|
|||
.setName("dog")
|
||||
.setDescription(client.translate("fun/dog:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/dog:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/dog:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("fun/dog:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/dog: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("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const res = await fetch("https://and-here-is-my-code.glitch.me/img/dog").then(response => response.json());
|
||||
const res = await fetch("https://dog.ceo/api/breeds/image/random").then(r => r.json());
|
||||
const dog = res.message;
|
||||
|
||||
interaction.editReply({
|
||||
content: res.Link,
|
||||
const embed = client.embed({
|
||||
image: dog,
|
||||
});
|
||||
|
||||
await interaction.editReply({ embeds: [embed] });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Dog;
|
||||
module.exports = Dog;
|
||||
|
|
|
@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class LMGTFY extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,54 +13,59 @@ class LMGTFY extends BaseCommand {
|
|||
.setName("lmgtfy")
|
||||
.setDescription(client.translate("fun/lmgtfy:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/lmgtfy:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/lmgtfy:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("fun/lmgtfy:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/lmgtfy:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option => option.setName("query")
|
||||
.setDescription(client.translate("fun/lmgtfy:QUERY"))
|
||||
.setDescriptionLocalizations({
|
||||
"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")
|
||||
.setDescription(client.translate("fun/lmgtfy:SHORT"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/lmgtfy:SHORT", null, "uk-UA"),
|
||||
"ru": client.translate("fun/lmgtfy:SHORT", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("query")
|
||||
.setDescription(client.translate("fun/lmgtfy:QUERY"))
|
||||
.setDescriptionLocalizations({
|
||||
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")
|
||||
.setDescription(client.translate("fun/lmgtfy:SHORT"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("fun/lmgtfy:SHORT", null, "uk-UA"),
|
||||
ru: client.translate("fun/lmgtfy:SHORT", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
const query = interaction.options.getString("query").replace(/[' '_]/g, "+"),
|
||||
short = interaction.options.getBoolean("short"),
|
||||
url = `https://letmegooglethat.com/?q=${query}`;
|
||||
url = `https://letmegooglethat.com/?q=${encodeURIComponent(query)}`;
|
||||
|
||||
if (short) {
|
||||
const res = await fetch(`https://is.gd/create.php?format=simple&url=${encodeURIComponent(url)}`).then(res => res.text());
|
||||
const res = await fetch("https://plsgo.ru/rest/v3/short-urls", {
|
||||
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({
|
||||
content: `<${res}>`,
|
||||
content: `<${res.shortUrl}>`,
|
||||
});
|
||||
} else {
|
||||
interaction.editReply({
|
||||
|
@ -70,4 +75,4 @@ class LMGTFY extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = LMGTFY;
|
||||
module.exports = LMGTFY;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
md5 = require("md5");
|
||||
|
||||
class Lovecalc extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,42 +13,38 @@ class Lovecalc extends BaseCommand {
|
|||
.setName("lovecalc")
|
||||
.setDescription(client.translate("fun/lovecalc:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/lovecalc:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/lovecalc:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("fun/lovecalc:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/lovecalc:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addUserOption(option =>
|
||||
option.setName("first_member")
|
||||
option
|
||||
.setName("first_member")
|
||||
.setDescription(client.translate("common:USER"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:USER", null, "uk-UA"),
|
||||
"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))
|
||||
.setRequired(true),
|
||||
)
|
||||
.addUserOption(option =>
|
||||
option.setName("second_member")
|
||||
option
|
||||
.setName("second_member")
|
||||
.setDescription(client.translate("common:USER"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:USER", null, "uk-UA"),
|
||||
"ru": client.translate("common:USER", null, "ru-RU"),
|
||||
})),
|
||||
aliases: [],
|
||||
uk: client.translate("common:USER", null, "uk-UA"),
|
||||
ru: client.translate("common:USER", null, "ru-RU"),
|
||||
}),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const firstMember = interaction.options.getMember("first_member"),
|
||||
|
@ -63,19 +59,16 @@ class Lovecalc extends BaseCommand {
|
|||
.join("");
|
||||
const percent = parseInt(string.slice(0, 2), 10);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: `❤️ ${interaction.translate("fun/lovecalc:DESCRIPTION")}`,
|
||||
})
|
||||
.setDescription(interaction.translate("fun/lovecalc:CONTENT", {
|
||||
},
|
||||
description: interaction.translate("fun/lovecalc:CONTENT", {
|
||||
percent,
|
||||
firstMember: firstMember.user.toString(),
|
||||
secondMember: secondMember.user.toString(),
|
||||
}))
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
});
|
||||
}),
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
embeds: [embed],
|
||||
|
@ -83,4 +76,4 @@ class Lovecalc extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Lovecalc;
|
||||
module.exports = Lovecalc;
|
||||
|
|
|
@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class Number extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,27 +13,19 @@ class Number extends BaseCommand {
|
|||
.setName("number")
|
||||
.setDescription(client.translate("fun/number:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/number:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/number:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("fun/number:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/number:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
if (currentGames[interaction.guildId]) return interaction.error("fun/number:GAME_RUNNING");
|
||||
|
@ -48,7 +40,7 @@ class Number extends BaseCommand {
|
|||
const filter = m => !m.author.bot;
|
||||
const collector = new MessageCollector(interaction.channel, {
|
||||
filter,
|
||||
time: (5 * 60 * 1000),
|
||||
time: 5 * 60 * 1000,
|
||||
});
|
||||
currentGames[interaction.guildId] = true;
|
||||
|
||||
|
@ -60,12 +52,11 @@ class Number extends BaseCommand {
|
|||
const parsedNumber = parseInt(msg.content, 10);
|
||||
|
||||
if (parsedNumber === number) {
|
||||
const time = client.functions.convertTime(client, gameCreatedAt, false, false, data.guildData.language);
|
||||
interaction.channel.send({
|
||||
content: interaction.translate("fun/number:GAME_STATS", {
|
||||
winner: msg.author.toString(),
|
||||
number,
|
||||
time,
|
||||
time: `<t:${Math.floor(gameCreatedAt / 1000)}:R>`,
|
||||
participantCount: participants.length,
|
||||
participants: participants.map(p => `<@${p}>`).join(", "),
|
||||
}),
|
||||
|
@ -96,17 +87,21 @@ class Number extends BaseCommand {
|
|||
};
|
||||
data.memberData.transactions.push(info);
|
||||
|
||||
memberData.markModified("transactions");
|
||||
await memberData.save();
|
||||
}
|
||||
|
||||
collector.stop();
|
||||
}
|
||||
|
||||
if (parseInt(msg.content) < number) msg.reply({
|
||||
content: interaction.translate("fun/number:TOO_BIG", { user: msg.author.toString(), number: parsedNumber }),
|
||||
});
|
||||
if (parseInt(msg.content) > number) msg.reply({
|
||||
content: interaction.translate("fun/number:TOO_SMALL", { user: msg.author.toString(), number: parsedNumber }),
|
||||
});
|
||||
if (parseInt(msg.content) < number)
|
||||
msg.reply({
|
||||
content: interaction.translate("fun/number:TOO_BIG", { user: msg.author.toString(), number: parsedNumber }),
|
||||
});
|
||||
if (parseInt(msg.content) > number)
|
||||
msg.reply({
|
||||
content: interaction.translate("fun/number:TOO_SMALL", { user: msg.author.toString(), number: parsedNumber }),
|
||||
});
|
||||
});
|
||||
|
||||
collector.on("end", (_, reason) => {
|
||||
|
@ -117,4 +112,4 @@ class Number extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Number;
|
||||
module.exports = Number;
|
||||
|
|
|
@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class TicTacToe extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,34 +13,29 @@ class TicTacToe extends BaseCommand {
|
|||
.setName("tictactoe")
|
||||
.setDescription(client.translate("fun/tictactoe:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("fun/tictactoe:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("fun/tictactoe:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("fun/tictactoe:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("fun/tictactoe:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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)),
|
||||
aliases: [],
|
||||
.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/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
tictactoe(interaction, {
|
||||
|
@ -54,7 +49,6 @@ class TicTacToe extends BaseCommand {
|
|||
});
|
||||
|
||||
memberData.money += 100;
|
||||
await memberData.save();
|
||||
|
||||
const info = {
|
||||
user: interaction.translate("economy/transactions:TTT"),
|
||||
|
@ -62,9 +56,14 @@ class TicTacToe extends BaseCommand {
|
|||
date: Date.now(),
|
||||
type: "got",
|
||||
};
|
||||
|
||||
memberData.transactions.push(info);
|
||||
|
||||
memberData.markModified("money");
|
||||
memberData.markModified("transactions");
|
||||
await memberData.save();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TicTacToe;
|
||||
module.exports = TicTacToe;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Afk extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,42 +12,40 @@ class Afk extends BaseCommand {
|
|||
.setName("afk")
|
||||
.setDescription(client.translate("general/afk:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/afk:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/afk:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/afk:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/afk: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)),
|
||||
aliases: [],
|
||||
.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),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
interaction.deferReply({ ephemeral: true });
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
const reason = interaction.options.getString("message");
|
||||
const userData = interaction.data.user,
|
||||
reason = interaction.options.getString("message");
|
||||
|
||||
data.userData.afk = reason;
|
||||
await data.userData.save();
|
||||
userData.afk = reason;
|
||||
|
||||
userData.markModified("afk");
|
||||
await userData.save();
|
||||
|
||||
interaction.success("general/afk:SUCCESS", {
|
||||
reason,
|
||||
|
@ -55,4 +53,4 @@ class Afk extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Afk;
|
||||
module.exports = Afk;
|
||||
|
|
35
commands/General/avatar.c.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
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;
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Avatar extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,50 +12,47 @@ class Avatar extends BaseCommand {
|
|||
.setName("avatar")
|
||||
.setDescription(client.translate("general/avatar:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/avatar:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/avatar:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/avatar:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/avatar:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.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"),
|
||||
}))
|
||||
.addBooleanOption(option => option.setName("server")
|
||||
.setDescription(client.translate("general/avatar:SERVER"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/avatar:SERVER", null, "uk-UA"),
|
||||
"ru": client.translate("general/avatar:SERVER", null, "ru-RU"),
|
||||
})),
|
||||
aliases: [],
|
||||
.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"),
|
||||
}),
|
||||
)
|
||||
.addBooleanOption(option =>
|
||||
option
|
||||
.setName("server")
|
||||
.setDescription(client.translate("general/avatar:SERVER"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("general/avatar:SERVER", null, "uk-UA"),
|
||||
ru: client.translate("general/avatar:SERVER", null, "ru-RU"),
|
||||
}),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const member = interaction.options.getMember("user") || interaction.member;
|
||||
const avatarURL = interaction.options.getBoolean("server") ? member.avatarURL({ size: 512 }) : member.user.avatarURL({ size: 512 });
|
||||
const avatarURL = interaction.options.getBoolean("server") ? member.displayAvatarURL({ size: 2048 }) : member.user.displayAvatarURL({ size: 2048 });
|
||||
const embed = client.embed({ image: avatarURL });
|
||||
|
||||
interaction.reply({
|
||||
files: [{
|
||||
attachment: avatarURL,
|
||||
}],
|
||||
embeds: [embed],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Avatar;
|
||||
module.exports = Avatar;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
|
||||
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Boosters extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,70 +12,41 @@ class Boosters extends BaseCommand {
|
|||
.setName("boosters")
|
||||
.setDescription(client.translate("general/boosters:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/boosters:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/boosters:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/boosters:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/boosters:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
async onLoad(client) {
|
||||
client.on("interactionCreate", async interaction => {
|
||||
if (!interaction.isButton()) return;
|
||||
|
||||
let currentPage = 0;
|
||||
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince);
|
||||
if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true });
|
||||
if (interaction.customId.startsWith("boosters_")) {
|
||||
interaction.data = [];
|
||||
interaction.data.guild = await client.findOrCreateGuild(interaction.guildId);
|
||||
|
||||
const embeds = generateBoostersEmbeds(client, interaction, boosters);
|
||||
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince),
|
||||
embeds = generateBoostersEmbeds(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("⏹️"),
|
||||
);
|
||||
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")}: **${currentPage + 1}**/**${embeds.length}**`,
|
||||
embeds: [embeds[currentPage]],
|
||||
components: [row],
|
||||
});
|
||||
let currentPage = Number(interaction.message.content.match(/\d+/g)[0]) - 1 ?? 0;
|
||||
|
||||
const filter = i => i.user.id === interaction.user.id;
|
||||
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 (interaction.customId === "boosters_prev_page") {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
if (currentPage !== 0) {
|
||||
--currentPage;
|
||||
|
@ -85,8 +56,8 @@ class Boosters extends BaseCommand {
|
|||
components: [row],
|
||||
});
|
||||
}
|
||||
} else if (i.customId === "boosters_next_page") {
|
||||
i.deferUpdate();
|
||||
} else if (interaction.customId === "boosters_next_page") {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
if (currentPage < embeds.length - 1) {
|
||||
currentPage++;
|
||||
|
@ -96,8 +67,8 @@ class Boosters extends BaseCommand {
|
|||
components: [row],
|
||||
});
|
||||
}
|
||||
} else if (i.customId === "boosters_jump_page") {
|
||||
i.deferUpdate();
|
||||
} else if (interaction.customId === "boosters_jump_page") {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
const msg = await interaction.followUp({
|
||||
content: interaction.translate("misc:JUMP_TO_PAGE", {
|
||||
|
@ -110,7 +81,7 @@ class Boosters extends BaseCommand {
|
|||
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]) {
|
||||
currentPage = collected.first().content - 1;
|
||||
interaction.editReply({
|
||||
|
@ -127,55 +98,78 @@ class Boosters extends BaseCommand {
|
|||
return;
|
||||
}
|
||||
});
|
||||
} else if (i.customId === "boosters_stop") {
|
||||
i.deferUpdate();
|
||||
collector.stop();
|
||||
} else if (interaction.customId === "boosters_stop") {
|
||||
await interaction.deferUpdate();
|
||||
|
||||
row.components.forEach(component => {
|
||||
component.setDisabled(true);
|
||||
});
|
||||
|
||||
return interaction.editReply({
|
||||
components: [row],
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
collector.on("end", () => {
|
||||
row.components.forEach(component => {
|
||||
component.setDisabled(true);
|
||||
});
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
return interaction.editReply({
|
||||
components: [row],
|
||||
});
|
||||
const boosters = (await interaction.guild.members.fetch()).filter(m => m.premiumSince);
|
||||
if (boosters.size === 0) return interaction.error("general/boosters:NO_BOOSTERS", null, { edit: true });
|
||||
|
||||
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 {Array} boosters
|
||||
* @returns
|
||||
*/
|
||||
function generateBoostersEmbeds(client, interaction, boosters) {
|
||||
function generateBoostersEmbeds(interaction, boosters) {
|
||||
const embeds = [];
|
||||
let k = 10;
|
||||
|
||||
for (let i = 0; i < boosters.size; i += 10) {
|
||||
const current = boosters.sort((a, b) => a.premiumSinceTimestamp - b.premiumSinceTimestamp).map(g => g).slice(i, k);
|
||||
const current = boosters
|
||||
.sort((a, b) => a.premiumSinceTimestamp - b.premiumSinceTimestamp)
|
||||
.map(g => g)
|
||||
.slice(i, k);
|
||||
let j = i;
|
||||
k += 10;
|
||||
|
||||
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 info = current.map(member => `${++j}. ${member.toString()} | ${interaction.translate("general/boosters:BOOSTER_SINCE")}: **${Math.floor(new Date(member.premiumSince).getTime() / 1000)}**`).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);
|
||||
}
|
||||
|
||||
return embeds;
|
||||
}
|
||||
|
||||
module.exports = Boosters;
|
||||
module.exports = Boosters;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
|
||||
const { SlashCommandBuilder, parseEmoji } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Emoji extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,50 +12,41 @@ class Emoji extends BaseCommand {
|
|||
.setName("emoji")
|
||||
.setDescription(client.translate("general/emoji:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/emoji:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/emoji:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/emoji:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/emoji:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option => option.setName("emoji")
|
||||
.setDescription(client.translate("common:EMOJI"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("commom:EMOJI", null, "uk-UA"),
|
||||
"ru": client.translate("common:EMOJI", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("emoji")
|
||||
.setDescription(client.translate("common:EMOJI"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("commom:EMOJI", null, "uk-UA"),
|
||||
ru: client.translate("common:EMOJI", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const rawEmoji = interaction.options.getString("emoji");
|
||||
const parsedEmoji = parseEmoji(rawEmoji);
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("general/emoji:TITLE", {
|
||||
emoji: parsedEmoji.name,
|
||||
}),
|
||||
})
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
})
|
||||
.addFields([
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("common:NAME"),
|
||||
value: parsedEmoji.name,
|
||||
|
@ -72,7 +63,8 @@ class Emoji extends BaseCommand {
|
|||
name: interaction.translate("general/emoji:LINK"),
|
||||
value: `https://cdn.discordapp.com/emojis/${parsedEmoji.id}.${parsedEmoji.animated ? "gif" : "png"}`,
|
||||
},
|
||||
]);
|
||||
],
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
embeds: [embed],
|
||||
|
@ -80,4 +72,4 @@ class Emoji extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Emoji;
|
||||
module.exports = Emoji;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder, PermissionsBitField } = require("discord.js");
|
||||
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Help extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,33 +12,70 @@ class Help extends BaseCommand {
|
|||
.setName("help")
|
||||
.setDescription(client.translate("general/help:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/help:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/help:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/help:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/help:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option =>
|
||||
option.setName("command")
|
||||
option
|
||||
.setName("command")
|
||||
.setDescription(client.translate("common:COMMAND"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:COMMAND", null, "uk-UA"),
|
||||
"ru": client.translate("common:COMMAND", null, "ru-RU"),
|
||||
uk: client.translate("common:COMMAND", null, "uk-UA"),
|
||||
ru: client.translate("common:COMMAND", null, "ru-RU"),
|
||||
})
|
||||
.setAutocomplete(true)),
|
||||
aliases: [],
|
||||
.setAutocomplete(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
async onLoad(client) {
|
||||
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/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
|
@ -46,25 +83,15 @@ class Help extends BaseCommand {
|
|||
await interaction.deferReply();
|
||||
|
||||
const commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()];
|
||||
const categories = [];
|
||||
const categories = [... new Set(commands.map(c => c.category))];
|
||||
const command = interaction.options.getString("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, ephemeral: true });
|
||||
|
||||
return interaction.editReply({ embeds: [ generateCommandHelp(interaction, 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 });
|
||||
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)] });
|
||||
}
|
||||
|
||||
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 => {
|
||||
return {
|
||||
label: `${c} (${commands.filter(cmd => cmd.category === c).length})`,
|
||||
|
@ -72,68 +99,17 @@ class Help extends BaseCommand {
|
|||
};
|
||||
});
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new StringSelectMenuBuilder()
|
||||
.setCustomId("help_category_select")
|
||||
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
|
||||
.addOptions(categoriesRows),
|
||||
);
|
||||
const row = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder().setCustomId("help_category_select").setPlaceholder(interaction.translate("common:NOTHING_SELECTED")).addOptions(categoriesRows));
|
||||
|
||||
const msg = await interaction.editReply({
|
||||
content: interaction.translate("common:AVAILABLE_OPTIONS"),
|
||||
await interaction.editReply({
|
||||
fetchReply: true,
|
||||
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/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").AutocompleteInteraction} interaction
|
||||
* @returns
|
||||
*/
|
||||
|
@ -142,18 +118,17 @@ class Help extends BaseCommand {
|
|||
commands = [...new Map(client.commands.map(v => [v.constructor.name, v])).values()],
|
||||
results = commands.filter(c => c.command.name.includes(command));
|
||||
|
||||
return interaction.respond(
|
||||
return await interaction.respond(
|
||||
results.slice(0, 25).map(command => ({
|
||||
name: command.command.name,
|
||||
value: command.command.name,
|
||||
}),
|
||||
));
|
||||
})),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -161,44 +136,38 @@ function generateCommandHelp(interaction, command) {
|
|||
const cmd = interaction.client.commands.get(command);
|
||||
if (!cmd) return interaction.error("general/help:NOT_FOUND", { command }, { edit: true });
|
||||
|
||||
const usage = interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:USAGE`) === "" ?
|
||||
interaction.translate("misc:NO_ARGS")
|
||||
: interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:USAGE`);
|
||||
if (cmd.category === "Owner" && interaction.user.id !== interaction.client.config.owner.id) return interaction.error("misc:OWNER_ONLY", null, { edit: true });
|
||||
else if (cmd.category === "IAT" && interaction.guildId !== "1039187019957555252") return interaction.error("misc:OWNER_ONLY", null, { edit: true });
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = interaction.client.embed({
|
||||
author: {
|
||||
name: interaction.translate("general/help:CMD_TITLE", {
|
||||
cmd: cmd.command.name,
|
||||
}),
|
||||
})
|
||||
.addFields([
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("general/help:FIELD_DESCRIPTION"),
|
||||
value: interaction.translate(`${cmd.category.toLowerCase()}/${cmd.command.name}:DESCRIPTION`),
|
||||
},
|
||||
{
|
||||
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` + usage,
|
||||
value: `*${cmd.command.dm_permission === false ? interaction.translate("general/help:GUILD_ONLY") : interaction.translate("general/help:NOT_GUILD_ONLY")}*\n\n${
|
||||
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"),
|
||||
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"),
|
||||
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;
|
||||
}
|
||||
|
||||
module.exports = Help;
|
||||
module.exports = Help;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
gamedig = require("gamedig");
|
||||
|
||||
class Minecraft extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,34 +13,29 @@ class Minecraft extends BaseCommand {
|
|||
.setName("minecraft")
|
||||
.setDescription(client.translate("general/minecraft:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/minecraft:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/minecraft:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/minecraft:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/minecraft:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option => option.setName("ip")
|
||||
.setDescription(client.translate("common:IP"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:IP", null, "uk-UA"),
|
||||
"ru": client.translate("common:IP", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("ip")
|
||||
.setDescription(client.translate("common:IP"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:IP", null, "uk-UA"),
|
||||
ru: client.translate("common:IP", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
@ -66,18 +61,27 @@ class Minecraft extends BaseCommand {
|
|||
|
||||
if (!res) return interaction.error("general/minecraft:FAILED", null, { edit: true });
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: res.name,
|
||||
})
|
||||
.addFields([
|
||||
const embed = client.embed({
|
||||
author: { name: res.name || "Unknown" },
|
||||
thumbnail: `https://eu.mc-api.net/v3/server/favicon/${ip}`,
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("general/minecraft:FIELD_STATUS"),
|
||||
value: interaction.translate("general/minecraft:ONLINE"),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("general/minecraft:FIELD_CONNECTED"),
|
||||
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"))}`,
|
||||
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"),
|
||||
)}`,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("general/minecraft:FIELD_IP"),
|
||||
|
@ -88,18 +92,13 @@ class Minecraft extends BaseCommand {
|
|||
name: interaction.translate("general/minecraft:FIELD_VERSION"),
|
||||
value: res.raw.vanilla.raw.version.name,
|
||||
inline: true,
|
||||
|
||||
},
|
||||
{
|
||||
name: interaction.translate("general/minecraft:FIELD_PING"),
|
||||
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({
|
||||
embeds: [embed],
|
||||
|
@ -107,4 +106,4 @@ class Minecraft extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Minecraft;
|
||||
module.exports = Minecraft;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Ping extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,41 +12,29 @@ class Ping extends BaseCommand {
|
|||
.setName("ping")
|
||||
.setDescription(client.translate("general/ping:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/ping:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/ping:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/ping:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/ping: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("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
})
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("general/ping:PONG"),
|
||||
iconURL: client.user.avatarURL(),
|
||||
})
|
||||
.setDescription(interaction.translate("general/ping:PING", {
|
||||
},
|
||||
description: interaction.translate("general/ping:PING", {
|
||||
ping: Math.round(client.ws.ping),
|
||||
}));
|
||||
}),
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
embeds: [embed],
|
||||
|
@ -54,4 +42,4 @@ class Ping extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Ping;
|
||||
module.exports = Ping;
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
ms = require("ms"),
|
||||
moment = require("moment");
|
||||
ms = require("ms");
|
||||
|
||||
class Remindme extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -14,66 +13,80 @@ class Remindme extends BaseCommand {
|
|||
.setName("remindme")
|
||||
.setDescription(client.translate("general/remindme:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/remindme:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/remindme:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/remindme:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/remindme:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option => option.setName("time")
|
||||
.setDescription(client.translate("general/remindme:TIME"))
|
||||
.setDescriptionLocalizations({
|
||||
"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")
|
||||
.setDescription(client.translate("common:MESSAGE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:MESSAGE", null, "uk-UA"),
|
||||
"ru": client.translate("common:MESSAGE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("time")
|
||||
.setDescription(client.translate("general/remindme:TIME"))
|
||||
.setDescriptionLocalizations({
|
||||
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")
|
||||
.setDescription(client.translate("common:MESSAGE"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:MESSAGE", null, "uk-UA"),
|
||||
ru: client.translate("common:MESSAGE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
const time = interaction.options.getString("time");
|
||||
const message = interaction.options.getString("message");
|
||||
const dateNow = Date.now();
|
||||
if (!data.userData.reminds) data.userData.reminds = [];
|
||||
const userData = interaction.data.user;
|
||||
|
||||
const rData = {
|
||||
message: message,
|
||||
createdAt: dateNow,
|
||||
sendAt: dateNow + ms(time),
|
||||
if (!userData.reminds) userData.reminds = [];
|
||||
|
||||
const dateNow = Date.now();
|
||||
|
||||
const reminder = {
|
||||
message: interaction.options.getString("message"),
|
||||
createdAt: Math.floor(dateNow / 1000),
|
||||
sendAt: Math.floor((dateNow + ms(interaction.options.getString("time"))) / 1000),
|
||||
};
|
||||
|
||||
data.userData.reminds.push(rData);
|
||||
data.userData.markModified("reminds");
|
||||
data.userData.save();
|
||||
client.databaseCache.usersReminds.set(interaction.member.id, data.userData);
|
||||
userData.reminds.push(reminder);
|
||||
|
||||
interaction.success("general/remindme:SAVED", {
|
||||
message,
|
||||
time: moment(rData.sendAt).locale(interaction.guild.data.language).format("dddd, Do MMMM YYYY, HH:mm:ss"),
|
||||
}, { edit: true });
|
||||
userData.markModified("reminds");
|
||||
await userData.save();
|
||||
|
||||
client.databaseCache.usersReminds.set(interaction.user.id, userData);
|
||||
|
||||
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;
|
||||
|
|
176
commands/General/reminds.js
Normal file
|
@ -0,0 +1,176 @@
|
|||
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;
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
|
||||
const { SlashCommandBuilder, parseEmoji } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Report extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,63 +12,61 @@ class Report extends BaseCommand {
|
|||
.setName("report")
|
||||
.setDescription(client.translate("general/report:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/report:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/report:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/report:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/report:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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("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)),
|
||||
aliases: [],
|
||||
.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("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),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const repChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.reports);
|
||||
const guildData = interaction.data.guild,
|
||||
repChannel = interaction.guild.channels.cache.get(guildData.plugins.reports);
|
||||
if (!repChannel) return interaction.error("general/report:MISSING_CHANNEL");
|
||||
|
||||
const member = interaction.options.getMember("user");
|
||||
if (member.id === interaction.user.id) return interaction.error("general/report:INVALID_USER");
|
||||
|
||||
const rep = interaction.options.getString("message");
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("general/report:TITLE", {
|
||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
||||
user: member.user.getUsername(),
|
||||
}),
|
||||
iconURL: interaction.user.displayAvatarURL({
|
||||
extension: "png",
|
||||
size: 512,
|
||||
}),
|
||||
})
|
||||
.addFields([
|
||||
iconURL: interaction.user.displayAvatarURL(),
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("common:DATE"),
|
||||
value: client.functions.printDate(client, new Date(Date.now())),
|
||||
value: `<t:${Math.floor(Date.now() / 1000)}:D>`,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:AUTHOR"),
|
||||
|
@ -85,11 +83,8 @@ class Report extends BaseCommand {
|
|||
value: rep,
|
||||
inline: true,
|
||||
},
|
||||
])
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
});
|
||||
],
|
||||
});
|
||||
|
||||
const success = parseEmoji(client.customEmojis.cool).id;
|
||||
const error = parseEmoji(client.customEmojis.notcool).id;
|
||||
|
@ -107,4 +102,4 @@ class Report extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Report;
|
||||
module.exports = Report;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, ChannelType } = require("discord.js");
|
||||
const { SlashCommandBuilder, ChannelType } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Serverinfo extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,45 +12,30 @@ class Serverinfo extends BaseCommand {
|
|||
.setName("serverinfo")
|
||||
.setDescription(client.translate("general/serverinfo:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/serverinfo:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/serverinfo:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/serverinfo:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/serverinfo:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const guild = interaction.guild;
|
||||
const { guild } = interaction;
|
||||
|
||||
await guild.members.fetch();
|
||||
const owner = await guild.fetchOwner();
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: guild.name,
|
||||
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})`,
|
||||
},
|
||||
const embed = client.embed({
|
||||
author: guild.name,
|
||||
thumbnail: guild.iconURL(),
|
||||
fields: [
|
||||
{
|
||||
name: client.customEmojis.title + interaction.translate("common:NAME"),
|
||||
value: guild.name,
|
||||
|
@ -58,13 +43,25 @@ class Serverinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.calendar + interaction.translate("common:CREATION"),
|
||||
value: client.functions.printDate(client, guild.createdAt),
|
||||
value: `<t:${guild.createdTimestamp}:D>`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.users + interaction.translate("common:MEMBERS"),
|
||||
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"))}` +
|
||||
"\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"))}`,
|
||||
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"),
|
||||
)}` +
|
||||
"\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,
|
||||
},
|
||||
{
|
||||
|
@ -89,17 +86,31 @@ class Serverinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.channels + interaction.translate("common:CHANNELS"),
|
||||
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"))}` +
|
||||
"\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"))}`,
|
||||
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"),
|
||||
)}` +
|
||||
"\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,
|
||||
},
|
||||
])
|
||||
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
});
|
||||
],
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
embeds: [embed],
|
||||
|
@ -107,4 +118,4 @@ class Serverinfo extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Serverinfo;
|
||||
module.exports = Serverinfo;
|
||||
|
|
|
@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class Shorturl extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,44 +13,47 @@ class Shorturl extends BaseCommand {
|
|||
.setName("shorturl")
|
||||
.setDescription(client.translate("general/shorturl:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/shorturl:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/shorturl:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/shorturl:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/shorturl:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option => option.setName("url")
|
||||
.setDescription(client.translate("common:URL"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:URL", null, "uk-UA"),
|
||||
"ru": client.translate("common:URL", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("url")
|
||||
.setDescription(client.translate("common:URL"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:URL", null, "uk-UA"),
|
||||
ru: client.translate("common:URL", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const url = interaction.options.getString("url");
|
||||
const res = await fetch(`https://is.gd/create.php?format=simple&url=${encodeURIComponent(url)}`).then(res => res.text());
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
interaction.reply({
|
||||
content: `<${res}>`,
|
||||
ephemeral: true,
|
||||
const url = interaction.options.getString("url");
|
||||
const res = await fetch("https://plsgo.ru/rest/v3/short-urls", {
|
||||
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({
|
||||
content: `<${res.shortUrl}>`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Shorturl;
|
||||
module.exports = Shorturl;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, PermissionsBitField, version } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField, version: djsVersion } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Stats extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,29 +12,21 @@ class Stats extends BaseCommand {
|
|||
.setName("stats")
|
||||
.setDescription(client.translate("general/stats:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/stats:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/stats:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/stats:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/stats: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("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
const hiddenGuildMembersCount = client.guilds.cache.get("568120814776614924").memberCount;
|
||||
const servers = client.guilds.cache.size - 1;
|
||||
let users = 0;
|
||||
|
@ -43,16 +35,10 @@ class Stats extends BaseCommand {
|
|||
});
|
||||
users = users - hiddenGuildMembersCount;
|
||||
|
||||
const statsEmbed = new EmbedBuilder()
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
})
|
||||
.setAuthor({
|
||||
name: interaction.translate("common:STATS"),
|
||||
})
|
||||
.setDescription(interaction.translate("general/stats:MADE"))
|
||||
.addFields([
|
||||
const embed = client.embed({
|
||||
author: interaction.translate("common:STATS"),
|
||||
descirption: interaction.translate("general/stats:MADE"),
|
||||
fields: [
|
||||
{
|
||||
name: client.customEmojis.stats + " " + interaction.translate("general/stats:COUNTS_TITLE"),
|
||||
value: interaction.translate("general/stats:COUNTS_CONTENT", {
|
||||
|
@ -63,24 +49,29 @@ class Stats extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.version + " " + interaction.translate("general/stats:VERSIONS_TITLE"),
|
||||
value: `\`Discord.js: v${version}\`\n\`Nodejs: v${process.versions.node}\``,
|
||||
value: `\`Discord.js: v${djsVersion}\`\n\`Nodejs: v${process.versions.node}\``,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.ram + " " + interaction.translate("general/stats:RAM_TITLE"),
|
||||
value: `\`${(process.memoryUsage().heapUsed / 1024 / 1024).toFixed(2)}MB\``,
|
||||
value: `\`${Math.floor(process.memoryUsage().heapUsed / 1024 / 1024)}MB\``,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.status.online + " " + interaction.translate("general/stats:ONLINE_TITLE"),
|
||||
value: interaction.translate("general/stats:ONLINE_CONTENT", {
|
||||
time: client.functions.convertTime(client, Date.now() + client.uptime, true, true, data.guildData.language),
|
||||
time: `<t:${Math.floor((Date.now() - client.uptime) / 1000)}:R>`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.voice + " " + interaction.translate("general/stats:MUSIC_TITLE"),
|
||||
value: interaction.translate("general/stats:MUSIC_CONTENT", {
|
||||
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"))}`,
|
||||
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"),
|
||||
)}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
@ -90,19 +81,20 @@ class Stats extends BaseCommand {
|
|||
{
|
||||
name: client.customEmojis.link + " " + interaction.translate("general/stats:LINKS_TITLE"),
|
||||
value: interaction.translate("misc:STATS_FOOTER", {
|
||||
dashboardLink: client.config.dashboard.baseURL,
|
||||
dashboardLink: client.config.dashboard.domain,
|
||||
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",
|
||||
owner: client.config.owner.id,
|
||||
}),
|
||||
},
|
||||
]);
|
||||
],
|
||||
});
|
||||
|
||||
interaction.reply({
|
||||
embeds: [statsEmbed],
|
||||
embeds: [embed],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Stats;
|
||||
module.exports = Stats;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, parseEmoji } = require("discord.js");
|
||||
const { SlashCommandBuilder, parseEmoji } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Suggest extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,51 +12,48 @@ class Suggest extends BaseCommand {
|
|||
.setName("suggest")
|
||||
.setDescription(client.translate("general/suggest:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/suggest:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/suggest:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/suggest:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/suggest:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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)),
|
||||
aliases: [],
|
||||
.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),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const suggChannel = interaction.guild.channels.cache.get(interaction.guild.data.plugins.suggestions);
|
||||
if (!suggChannel) return interaction.error("general/suggest:MISSING_CHANNEL");
|
||||
const guildData = interaction.data.guild,
|
||||
channel = interaction.guild.channels.cache.get(guildData.plugins.suggestions);
|
||||
if (!channel) return interaction.error("general/suggest:MISSING_CHANNEL");
|
||||
|
||||
const suggestion = interaction.options.getString("message");
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("general/suggest:TITLE", {
|
||||
user: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
|
||||
user: interaction.user.getUsername(),
|
||||
}),
|
||||
iconURL: interaction.member.displayAvatarURL(),
|
||||
})
|
||||
.addFields([
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("common:DATE"),
|
||||
value: client.functions.printDate(client, new Date(Date.now())),
|
||||
value: `<t:${Math.floor(Date.now() / 1000)}:D>`,
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:AUTHOR"),
|
||||
|
@ -68,16 +65,13 @@ class Suggest extends BaseCommand {
|
|||
value: suggestion,
|
||||
inline: true,
|
||||
},
|
||||
])
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
});
|
||||
],
|
||||
});
|
||||
|
||||
const success = parseEmoji(client.customEmojis.cool).id;
|
||||
const error = parseEmoji(client.customEmojis.notcool).id;
|
||||
|
||||
suggChannel.send({
|
||||
channel.send({
|
||||
embeds: [embed],
|
||||
}).then(async m => {
|
||||
await m.react(success);
|
||||
|
@ -85,9 +79,9 @@ class Suggest extends BaseCommand {
|
|||
});
|
||||
|
||||
interaction.success("general/suggest:SUCCESS", {
|
||||
channel: suggChannel.toString(),
|
||||
channel: channel.toString(),
|
||||
}, { ephemeral: true });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Suggest;
|
||||
module.exports = Suggest;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Userinfo extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,48 +12,43 @@ class Userinfo extends BaseCommand {
|
|||
.setName("userinfo")
|
||||
.setDescription(client.translate("general/userinfo:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/userinfo:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/userinfo:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/userinfo:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/userinfo:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.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"),
|
||||
})),
|
||||
aliases: [],
|
||||
.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"),
|
||||
}),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const member = interaction.options.getMember("user") || interaction.member;
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: `${member.user.discriminator === "0" ? member.user.username : member.user.tag} (${member.id})`,
|
||||
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: `${member.user.getUsername()} (${member.id})`,
|
||||
iconURL: member.displayAvatarURL(),
|
||||
})
|
||||
.setThumbnail(member.displayAvatarURL({
|
||||
size: 512,
|
||||
}))
|
||||
.addFields([
|
||||
},
|
||||
thumbnail: member.displayAvatarURL(),
|
||||
fields: [
|
||||
{
|
||||
name: ":man: " + interaction.translate("common:USERNAME"),
|
||||
value: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
||||
value: member.user.getUsername(),
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
@ -61,11 +56,6 @@ class Userinfo extends BaseCommand {
|
|||
value: member.nickname || interaction.translate("general/userinfo:NO_NICKNAME"),
|
||||
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"),
|
||||
value: member.user.bot ? interaction.translate("common:YES") : interaction.translate("common:NO"),
|
||||
|
@ -73,12 +63,12 @@ class Userinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.calendar + " " + interaction.translate("common:CREATION"),
|
||||
value: client.functions.printDate(client, member.user.createdAt),
|
||||
value: `<t:${member.user.createdTimestamp}:D>`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: client.customEmojis.calendar2 + " " + interaction.translate("common:JOINED"),
|
||||
value: client.functions.printDate(client, member.joinedAt),
|
||||
value: `<t:${member.joinedTimestamp}:D>`,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
|
@ -88,35 +78,17 @@ class Userinfo extends BaseCommand {
|
|||
},
|
||||
{
|
||||
name: client.customEmojis.roles + " " + interaction.translate("common:ROLES"),
|
||||
value: (member.roles.size > 10 ? member.roles.cache.map(r => r).slice(0, 10).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).join(", ")),
|
||||
value:
|
||||
member.roles.size > 10
|
||||
? member.roles.cache.map(r => r).filter(r => r.id !== interaction.guild.roles.everyone.id).slice(0, 10).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,
|
||||
},
|
||||
])
|
||||
.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({
|
||||
embeds: [embed],
|
||||
|
@ -124,4 +96,4 @@ class Userinfo extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Userinfo;
|
||||
module.exports = Userinfo;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
fetch = require("node-fetch");
|
||||
|
||||
class Whois extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,34 +13,29 @@ class Whois extends BaseCommand {
|
|||
.setName("whois")
|
||||
.setDescription(client.translate("general/whois:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("general/whois:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("general/whois:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("general/whois:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("general/whois:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true)
|
||||
.addStringOption(option => option.setName("ip")
|
||||
.setDescription(client.translate("common:IP"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:IP", null, "uk-UA"),
|
||||
"ru": client.translate("common:IP", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("ip")
|
||||
.setDescription(client.translate("common:IP"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:IP", null, "uk-UA"),
|
||||
ru: client.translate("common:IP", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
@ -50,15 +45,11 @@ class Whois extends BaseCommand {
|
|||
|
||||
if (whois.status === "fail") return interaction.editReply({ content: interaction.translate("general/whois:ERROR", { ip }) });
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(interaction.translate("general/whois:INFO_ABOUT", {
|
||||
const embed = client.embed({
|
||||
title: interaction.translate("general/whois:INFO_ABOUT", {
|
||||
ip,
|
||||
}))
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
})
|
||||
.setColor(client.config.embed.color)
|
||||
.addFields(
|
||||
}),
|
||||
fields: [
|
||||
{ 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:REGION"), value: `${whois.regionName || interaction.translate("common:UNKNOWN")} (${whois.region || interaction.translate("common:UNKNOWN")})`, inline: true },
|
||||
|
@ -68,12 +59,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: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 },
|
||||
)
|
||||
.setTimestamp();
|
||||
],
|
||||
});
|
||||
|
||||
if (whois.proxy) embed.addFields({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:PROXY") });
|
||||
if (whois.mobile) embed.addFields({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:MOBILE") });
|
||||
if (whois.hosting) embed.addFields({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:HOSTING") });
|
||||
if (whois.proxy) embed.data.fields.push({ 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.hosting) embed.data.fields.push({ name: interaction.translate("general/whois:INFO"), value: interaction.translate("general/whois:HOSTING") });
|
||||
|
||||
interaction.editReply({
|
||||
embeds: [embed],
|
||||
|
@ -81,4 +72,4 @@ class Whois extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Whois;
|
||||
module.exports = Whois;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
fetch = require("node-fetch"),
|
||||
moment = require("moment");
|
||||
|
@ -6,7 +6,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class Checkjar extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -14,69 +14,54 @@ class Checkjar extends BaseCommand {
|
|||
.setName("checkjar")
|
||||
.setDescription(client.translate("iat/checkjar:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("iat/checkjar:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("iat/checkjar:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("iat/checkjar:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("iat/checkjar:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
||||
const jarsList = await fetch("https://api.monobank.ua/personal/client-info", {
|
||||
const clientInfo = await fetch("https://api.monobank.ua/personal/client-info", {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"X-Token": client.config.apiKeys.monobankApiKey,
|
||||
"X-Token": client.config.apiKeys.monobank.key,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}).then(res => res.json());
|
||||
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 jar = clientInfo.jars.find(j => j.id === client.config.apiKeys.monobank.jar);
|
||||
const jarTransactions = await fetch(`https://api.monobank.ua/personal/statement/${jar.id}/${Date.now() - 7 * 24 * 60 * 60 * 1000}/${Date.now()}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"X-Token": client.config.apiKeys.monobankApiKey,
|
||||
"X-Token": client.config.apiKeys.monobank.key,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
}).then(res => res.json());
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.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)`);
|
||||
const embed = client.embed({
|
||||
description: `Текущий баланс: **${jar.balance / Math.pow(10, 2)}** грн\nТребуется на след. месяц: **379,18** грн (по курсу евро на 02.07.2023).\nЗдесь указаны последние 10 транзакций.`,
|
||||
});
|
||||
|
||||
jarTransactions.length = 10;
|
||||
|
||||
jarTransactions.forEach(t => {
|
||||
// TODO
|
||||
const time = moment.unix(t.time);
|
||||
|
||||
embed.addFields([
|
||||
embed.data.fields.push([
|
||||
{
|
||||
name: `${t.description}`,
|
||||
value: `Дата: ${time.locale("uk-UA").format("DD MMMM YYYY, HH:mm")}\nСумма: ${t.amount / Math.pow(10, 2)} грн`,
|
||||
inline: true,
|
||||
value: `Дата: <t:${time}:D>\nСумма: ${t.amount / Math.pow(10, 2)} грн`,
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
@ -87,4 +72,4 @@ class Checkjar extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Checkjar;
|
||||
module.exports = Checkjar;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Clear extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,47 +12,48 @@ class Clear extends BaseCommand {
|
|||
.setName("clear")
|
||||
.setDescription(client.translate("moderation/clear:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/clear:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/clear:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("moderation/clear:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("moderation/clear:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
|
||||
.addStringOption(option => option.setName("option")
|
||||
.setDescription(client.translate("moderation/clear:OPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"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")
|
||||
.setDescription(client.translate("common:USER"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:USER", null, "uk-UA"),
|
||||
"ru": client.translate("common:USER", null, "ru-RU"),
|
||||
}))
|
||||
.addStringOption(option => 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"),
|
||||
})),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("option")
|
||||
.setDescription(client.translate("moderation/clear:OPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
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")
|
||||
.setDescription(client.translate("common:USER"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:USER", null, "uk-UA"),
|
||||
ru: client.translate("common:USER", null, "ru-RU"),
|
||||
}),
|
||||
)
|
||||
.addStringOption(option =>
|
||||
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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
@ -62,17 +63,10 @@ class Clear extends BaseCommand {
|
|||
user_id = interaction.options.getString("id");
|
||||
|
||||
if (option === "all") {
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
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),
|
||||
);
|
||||
const row = new ActionRowBuilder().addComponents(
|
||||
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({
|
||||
content: interaction.translate("moderation/clear:ALL_CONFIRM"),
|
||||
|
@ -80,7 +74,7 @@ class Clear extends BaseCommand {
|
|||
});
|
||||
|
||||
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 => {
|
||||
if (i.isButton()) {
|
||||
|
@ -125,9 +119,7 @@ class Clear extends BaseCommand {
|
|||
} else {
|
||||
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) messages = messages.filter(m => m.author.id === (user_id || member.id));
|
||||
|
@ -137,7 +129,7 @@ class Clear extends BaseCommand {
|
|||
if (member || user_id) {
|
||||
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"))}`,
|
||||
user: (member?.user.discriminator === "0" ? member?.user.username : member?.user.tag || user_id),
|
||||
user: user_id || member.toString(),
|
||||
}, { edit: true });
|
||||
} else {
|
||||
interaction.replyT("moderation/clear:CLEARED", {
|
||||
|
@ -148,4 +140,4 @@ class Clear extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Clear;
|
||||
module.exports = Clear;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Clearwarns extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,35 +12,30 @@ class Clearwarns extends BaseCommand {
|
|||
.setName("clearwarns")
|
||||
.setDescription(client.translate("moderation/clearwarns:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/clearwarns:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/clearwarns:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("moderation/clearwarns:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("moderation/clearwarns:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
|
||||
.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)),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
|
||||
.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/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const member = interaction.options.getMember("user");
|
||||
|
@ -51,7 +46,9 @@ class Clearwarns extends BaseCommand {
|
|||
});
|
||||
|
||||
memberData.sanctions = [];
|
||||
memberData.save();
|
||||
|
||||
memberData.markModified("sanctions");
|
||||
await memberData.save();
|
||||
|
||||
interaction.success("moderation/clearwarns:SUCCESS", {
|
||||
user: member.toString(),
|
||||
|
@ -59,4 +56,4 @@ class Clearwarns extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Clearwarns;
|
||||
module.exports = Clearwarns;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
ms = require("ms");
|
||||
|
||||
class Giveaway extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,105 +13,126 @@ class Giveaway extends BaseCommand {
|
|||
.setName("giveaway")
|
||||
.setDescription(client.translate("moderation/giveaway:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/giveaway:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/giveaway:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("moderation/giveaway:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("moderation/giveaway:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
|
||||
.addSubcommand(subcommand => subcommand.setName("create")
|
||||
.setDescription(client.translate("moderation/giveaway:CREATE"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("create")
|
||||
.setDescription(client.translate("moderation/giveaway:CREATE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("common:DURATION", null, "uk-UA"),
|
||||
"ru": client.translate("common:DURATION", null, "ru-RU"),
|
||||
uk: client.translate("moderation/giveaway:CREATE", null, "uk-UA"),
|
||||
ru: client.translate("moderation/giveaway:CREATE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true))
|
||||
.addIntegerOption(option => option.setName("winners_count")
|
||||
.setDescription(client.translate("moderation/giveaway:WINNERS_COUNT"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/giveaway:WINNERS_COUNT", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/giveaway:WINNERS_COUNT", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true))
|
||||
.addStringOption(option => option.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)),
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("duration")
|
||||
.setDescription(client.translate("common:DURATION"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("common:DURATION", null, "uk-UA"),
|
||||
ru: client.translate("common:DURATION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
)
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("winners_count")
|
||||
.setDescription(client.translate("moderation/giveaway:WINNERS_COUNT"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("moderation/giveaway:WINNERS_COUNT", null, "uk-UA"),
|
||||
ru: client.translate("moderation/giveaway:WINNERS_COUNT", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.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 => subcommand.setName("reroll")
|
||||
.setDescription(client.translate("moderation/giveaway:REROLL"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("reroll")
|
||||
.setDescription(client.translate("moderation/giveaway:REROLL"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
|
||||
uk: client.translate("moderation/giveaway:REROLL", null, "uk-UA"),
|
||||
ru: client.translate("moderation/giveaway:REROLL", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
.addStringOption(option =>
|
||||
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 => subcommand.setName("end")
|
||||
.setDescription(client.translate("moderation/giveaway:END"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("end")
|
||||
.setDescription(client.translate("moderation/giveaway:END"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
|
||||
uk: client.translate("moderation/giveaway:END", null, "uk-UA"),
|
||||
ru: client.translate("moderation/giveaway:END", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
.addStringOption(option =>
|
||||
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 => subcommand.setName("delete")
|
||||
.setDescription(client.translate("moderation/giveaway:DELETE"))
|
||||
.setDescriptionLocalizations({
|
||||
"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"))
|
||||
.addSubcommand(subcommand =>
|
||||
subcommand
|
||||
.setName("delete")
|
||||
.setDescription(client.translate("moderation/giveaway:DELETE"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
|
||||
uk: client.translate("moderation/giveaway:DELETE", null, "uk-UA"),
|
||||
ru: client.translate("moderation/giveaway:DELETE", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
.addStringOption(option =>
|
||||
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,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const command = interaction.options.getSubcommand();
|
||||
|
@ -129,44 +150,49 @@ class Giveaway extends BaseCommand {
|
|||
const prize = interaction.options.getString("prize");
|
||||
const isdrop = interaction.options.getBoolean("isdrop");
|
||||
|
||||
client.giveawaysManager.start(interaction.channel, {
|
||||
duration: ms(duration),
|
||||
winnerCount: winnersCount,
|
||||
prize: prize,
|
||||
hostedBy: interaction.user,
|
||||
isDrop: isdrop,
|
||||
messages: {
|
||||
giveaway: interaction.translate("moderation/giveaway:TITLE"),
|
||||
giveawayEnded: interaction.translate("moderation/giveaway:ENDED"),
|
||||
timeRemaining: interaction.translate("moderation/giveaway:TIME_REMAINING"),
|
||||
inviteToParticipate: interaction.translate("moderation/giveaway:INVITE_PARTICIPATE"),
|
||||
winMessage: interaction.translate("moderation/giveaway:WIN_MESSAGE"),
|
||||
drawing: interaction.translate("moderation/giveaway:DRAWING"),
|
||||
dropMessage: interaction.translate("moderation/giveaway:DROP"),
|
||||
embedFooter: interaction.translate("moderation/giveaway:FOOTER"),
|
||||
noWinner: interaction.translate("moderation/giveaway:NO_WINNER"),
|
||||
winners: interaction.translate("moderation/giveaway:WINNERS"),
|
||||
endedAt: interaction.translate("moderation/giveaway:END_AT"),
|
||||
hostedBy: interaction.translate("moderation/giveaway:HOSTED_BY"),
|
||||
},
|
||||
}).then(() => {
|
||||
return interaction.success("moderation/giveaway:GIVEAWAY_CREATED", null, { ephemeral: true });
|
||||
});
|
||||
client.giveawaysManager
|
||||
.start(interaction.channel, {
|
||||
duration: ms(duration),
|
||||
winnerCount: winnersCount,
|
||||
prize: prize,
|
||||
hostedBy: interaction.user,
|
||||
isDrop: isdrop,
|
||||
messages: {
|
||||
giveaway: interaction.translate("moderation/giveaway:TITLE"),
|
||||
giveawayEnded: interaction.translate("moderation/giveaway:ENDED"),
|
||||
timeRemaining: interaction.translate("moderation/giveaway:TIME_REMAINING"),
|
||||
inviteToParticipate: interaction.translate("moderation/giveaway:INVITE_PARTICIPATE"),
|
||||
winMessage: interaction.translate("moderation/giveaway:WIN_MESSAGE"),
|
||||
drawing: interaction.translate("moderation/giveaway:DRAWING"),
|
||||
dropMessage: interaction.translate("moderation/giveaway:DROP"),
|
||||
embedFooter: interaction.translate("moderation/giveaway:FOOTER"),
|
||||
noWinner: interaction.translate("moderation/giveaway:NO_WINNER"),
|
||||
winners: interaction.translate("moderation/giveaway:WINNERS"),
|
||||
endedAt: interaction.translate("moderation/giveaway:END_AT"),
|
||||
hostedBy: interaction.translate("moderation/giveaway:HOSTED_BY"),
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
return interaction.success("moderation/giveaway:GIVEAWAY_CREATED", null, { ephemeral: true });
|
||||
});
|
||||
} else if (command === "reroll") {
|
||||
const giveaway_id = interaction.options.getString("giveaway_id");
|
||||
|
||||
client.giveawaysManager.reroll(giveaway_id, {
|
||||
messages: {
|
||||
congrat: interaction.translate("moderation/giveaway:REROLL_CONGRAT"),
|
||||
error: interaction.translate("moderation/giveaway:REROLL_ERROR"),
|
||||
},
|
||||
}).then(() => {
|
||||
return interaction.success("moderation/giveaway:GIVEAWAY_REROLLED");
|
||||
}).catch(() => {
|
||||
return interaction.error("moderation/giveaway:NOT_FOUND_ENDED", {
|
||||
messageId: giveaway_id,
|
||||
}, { ephemeral: true });
|
||||
});
|
||||
client.giveawaysManager
|
||||
.reroll(giveaway_id, {
|
||||
messages: {
|
||||
congrat: interaction.translate("moderation/giveaway:REROLL_CONGRAT"),
|
||||
error: interaction.translate("moderation/giveaway:REROLL_ERROR"),
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
return interaction.success("moderation/giveaway:GIVEAWAY_REROLLED");
|
||||
})
|
||||
.catch(() => {
|
||||
return interaction.error("moderation/giveaway:NOT_FOUND_ENDED", {
|
||||
messageId: giveaway_id,
|
||||
}, { ephemeral: true });
|
||||
});
|
||||
} else if (command === "end") {
|
||||
const giveaway_id = interaction.options.getString("giveaway_id");
|
||||
|
||||
|
@ -181,15 +207,18 @@ class Giveaway extends BaseCommand {
|
|||
} else if (command === "delete") {
|
||||
const giveaway_id = interaction.options.getString("giveaway_id");
|
||||
|
||||
client.giveawaysManager.delete(giveaway_id).then(() => {
|
||||
return interaction.success("moderation/giveaway:GIVEAWAY_DELETED");
|
||||
}).catch(() => {
|
||||
return interaction.error("moderation/giveaway:NOT_FOUND", {
|
||||
messageId: giveaway_id,
|
||||
}, { ephemeral: true });
|
||||
});
|
||||
client.giveawaysManager
|
||||
.delete(giveaway_id)
|
||||
.then(() => {
|
||||
return interaction.success("moderation/giveaway:GIVEAWAY_DELETED");
|
||||
})
|
||||
.catch(() => {
|
||||
return interaction.error("moderation/giveaway:NOT_FOUND", {
|
||||
messageId: giveaway_id,
|
||||
}, { ephemeral: true });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Giveaway;
|
||||
module.exports = Giveaway;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Poll extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,59 +12,40 @@ class Poll extends BaseCommand {
|
|||
.setName("poll")
|
||||
.setDescription(client.translate("moderation/poll:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/poll:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/poll:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("moderation/poll:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("moderation/poll:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
|
||||
.addStringOption(option => option.setName("question")
|
||||
.setDescription(client.translate("moderation/poll:QUESTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/poll:QUESTION", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/poll:QUESTION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("question")
|
||||
.setDescription(client.translate("moderation/poll:QUESTION"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("moderation/poll:QUESTION", null, "uk-UA"),
|
||||
ru: client.translate("moderation/poll:QUESTION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const question = interaction.options.getString("question");
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new ButtonBuilder()
|
||||
.setCustomId("poll_everyone")
|
||||
.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),
|
||||
);
|
||||
|
||||
const row = new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder().setCustomId("poll_everyone").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({
|
||||
content: interaction.translate("moderation/poll:SELECT_MENTION"),
|
||||
|
@ -74,7 +55,7 @@ class Poll extends BaseCommand {
|
|||
|
||||
let mention = null;
|
||||
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 => {
|
||||
if (i.isButton()) {
|
||||
|
@ -106,24 +87,22 @@ class Poll extends BaseCommand {
|
|||
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 embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.translate("moderation/poll:TITLE"),
|
||||
})
|
||||
.setColor(client.config.embed.color)
|
||||
.addFields([
|
||||
const embed = client.embed({
|
||||
author: interaction.translate("moderation/poll:TITLE"),
|
||||
fields: [
|
||||
{
|
||||
name: "\u200b",
|
||||
name: "\u200B",
|
||||
value: question,
|
||||
},
|
||||
{
|
||||
name: "\u200b",
|
||||
name: "\u200B",
|
||||
value: interaction.translate("moderation/poll:REACT", {
|
||||
success: cool.toString(),
|
||||
error: notcool.toString(),
|
||||
}),
|
||||
},
|
||||
]);
|
||||
],
|
||||
});
|
||||
|
||||
return interaction.channel.send({
|
||||
content: mention,
|
||||
|
@ -137,4 +116,4 @@ class Poll extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Poll;
|
||||
module.exports = Poll;
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Unban extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,35 +12,30 @@ class Unban extends BaseCommand {
|
|||
.setName("unban")
|
||||
.setDescription(client.translate("moderation/unban:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/unban:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/unban:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("moderation/unban:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("moderation/unban:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
|
||||
.addStringOption(option => option.setName("user_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"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("user_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"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const id = interaction.options.getString("user_id"),
|
||||
|
@ -56,4 +51,4 @@ class Unban extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Unban;
|
||||
module.exports = Unban;
|
||||
|
|
58
commands/Moderation/untimeout.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
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;
|
|
@ -1,44 +1,36 @@
|
|||
const { ContextMenuCommandBuilder, ModalBuilder, EmbedBuilder, ActionRowBuilder, TextInputBuilder, ApplicationCommandType, PermissionFlagsBits, TextInputStyle } = require("discord.js");
|
||||
const { ContextMenuCommandBuilder, ModalBuilder, ActionRowBuilder, TextInputBuilder, ApplicationCommandType, PermissionsBitField, TextInputStyle } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Warn extends BaseCommand {
|
||||
class WarnContext extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor() {
|
||||
super({
|
||||
command: new ContextMenuCommandBuilder()
|
||||
.setName("warn")
|
||||
.setName("Give Warn")
|
||||
.setType(ApplicationCommandType.User)
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").UserContextMenuCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction, data) {
|
||||
async execute(client, interaction) {
|
||||
const member = interaction.targetMember,
|
||||
memberPosition = 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.id === interaction.member.id) return interaction.error("moderation/warn:YOURSELF", null, { ephemeral: true });
|
||||
if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition)) return interaction.error("moderation/ban:SUPERIOR", null, { ephemeral: true });
|
||||
if (interaction.guild.ownerId !== interaction.member.id && !(moderationPosition > memberPosition)) return interaction.error("moderation/warn:SUPERIOR", null, { ephemeral: true });
|
||||
|
||||
const memberData = await client.findOrCreateMember({
|
||||
id: member.id,
|
||||
|
@ -47,7 +39,9 @@ class Warn extends BaseCommand {
|
|||
|
||||
const modal = new ModalBuilder()
|
||||
.setCustomId("warn_modal")
|
||||
.setTitle(interaction.translate("moderation/warn:MODAL_TITLE", { nickname: member.user.discriminator === "0" ? member.user.username : member.user.tag }).normalize("NFKD"));
|
||||
.setTitle(interaction.translate("moderation/warn:MODAL_TITLE", {
|
||||
nickname: member.user.getUsername(),
|
||||
}).normalize("NFKD"));
|
||||
|
||||
const reasonInput = new TextInputBuilder()
|
||||
.setCustomId("warn_reason")
|
||||
|
@ -61,22 +55,24 @@ class Warn extends BaseCommand {
|
|||
|
||||
await interaction.showModal(modal);
|
||||
|
||||
const submitted = await interaction.awaitModalSubmit({
|
||||
time: (2 * 60 * 1000),
|
||||
filter: i => i.user.id === interaction.member.id && i.customId === "warn_modal",
|
||||
}).catch(() => {
|
||||
interaction.followUp({
|
||||
content: interaction.translate("misc:TIMED_OUT"),
|
||||
ephemeral: true,
|
||||
const submitted = await interaction
|
||||
.awaitModalSubmit({
|
||||
time: 2 * 60 * 1000,
|
||||
filter: i => i.user.id === interaction.member.id && i.customId === "warn_modal",
|
||||
})
|
||||
.catch(() => {
|
||||
interaction.followUp({
|
||||
content: interaction.translate("misc:TIMED_OUT"),
|
||||
ephemeral: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (submitted) {
|
||||
const reason = submitted.fields.getTextInputValue("warn_reason");
|
||||
|
||||
const sanctions = memberData.sanctions.filter(s => s.type === "warn").length;
|
||||
const banCount = data.guildData.plugins.warnsSanctions.ban;
|
||||
const kickCount = data.guildData.plugins.warnsSanctions.kick;
|
||||
// const sanctions = memberData.sanctions.filter(s => s.type === "warn").length;
|
||||
// const banCount = data.guildData.plugins.warnsSanctions.ban;
|
||||
// const kickCount = data.guildData.plugins.warnsSanctions.kick;
|
||||
|
||||
const caseInfo = {
|
||||
moderator: interaction.member.id,
|
||||
|
@ -85,29 +81,32 @@ class Warn extends BaseCommand {
|
|||
reason,
|
||||
};
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.addFields([
|
||||
const embed = client.embed({
|
||||
author: interaction.translate("moderation/warn:WARN"),
|
||||
fields: [
|
||||
{
|
||||
name: interaction.translate("common:USER"),
|
||||
value: `\`${member.user.discriminator === "0" ? member.user.username : member.user.tag}\` (${member.user.toString()})`,
|
||||
value: member.user.toString(),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:MODERATOR"),
|
||||
value: `\`${interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag}\` (${interaction.user.toString()})`,
|
||||
value: interaction.user.toString(),
|
||||
},
|
||||
{
|
||||
name: interaction.translate("common:REASON"),
|
||||
value: reason,
|
||||
inline: true,
|
||||
},
|
||||
]);
|
||||
],
|
||||
});
|
||||
|
||||
/*
|
||||
if (banCount) {
|
||||
if (sanctions >= banCount) {
|
||||
member.send({
|
||||
content: interaction.translate("moderation/ban:BANNED_DM", {
|
||||
user: member.user,
|
||||
moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
|
||||
moderator: interaction.user.getUsername(),
|
||||
server: interaction.guild.name,
|
||||
reason,
|
||||
}),
|
||||
|
@ -122,9 +121,10 @@ class Warn extends BaseCommand {
|
|||
.setColor(client.config.embed.color);
|
||||
|
||||
interaction.guild.members.ban(member).catch(() => {});
|
||||
|
||||
interaction.followUp({
|
||||
content: interaction.translate("moderation/setwarns:AUTO_BAN", {
|
||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
||||
user: member.user.getUsername(),
|
||||
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 Warn extends BaseCommand {
|
|||
member.send({
|
||||
content: interaction.translate("moderation/kick:KICKED_DM", {
|
||||
user: member.user,
|
||||
moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
|
||||
moderator: interaction.user.getUsername(),
|
||||
server: interaction.guild.name,
|
||||
reason,
|
||||
}),
|
||||
|
@ -151,35 +151,38 @@ class Warn extends BaseCommand {
|
|||
.setColor(client.config.embed.color);
|
||||
|
||||
member.kick().catch(() => {});
|
||||
|
||||
interaction.followUp({
|
||||
content: interaction.translate("moderation/setwarns:AUTO_KICK", {
|
||||
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
|
||||
user: member.user.getUsername(),
|
||||
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.save();
|
||||
|
||||
if (data.guildData.plugins.modlogs) {
|
||||
const channel = interaction.guild.channels.cache.get(data.guildData.plugins.modlogs);
|
||||
memberData.markModified("sanctions");
|
||||
await memberData.save();
|
||||
|
||||
const guildData = interaction.data.guild;
|
||||
|
||||
if (guildData.plugins.modlogs) {
|
||||
const channel = interaction.guild.channels.cache.get(guildData.plugins.modlogs);
|
||||
if (!channel) return;
|
||||
|
||||
channel.send({
|
||||
|
@ -197,4 +200,4 @@ class Warn extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Warn;
|
||||
module.exports = WarnContext;
|
|
@ -1,10 +1,10 @@
|
|||
const { SlashCommandBuilder, PermissionFlagsBits, EmbedBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Warns extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,35 +12,30 @@ class Warns extends BaseCommand {
|
|||
.setName("warns")
|
||||
.setDescription(client.translate("moderation/warns:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("moderation/warns:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("moderation/warns:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("moderation/warns:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("moderation/warns:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.setDefaultMemberPermissions(PermissionFlagsBits.ModerateMembers && PermissionFlagsBits.ManageMessages)
|
||||
.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)),
|
||||
aliases: [],
|
||||
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageMessages)
|
||||
.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/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const member = interaction.options.getMember("user");
|
||||
|
@ -51,43 +46,37 @@ class Warns extends BaseCommand {
|
|||
guildId: interaction.guildId,
|
||||
});
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
const embed = client.embed({
|
||||
author: {
|
||||
name: interaction.translate("moderation/warns:SANCTIONS_OF", {
|
||||
member: member.nickname || member.user.username,
|
||||
member: member.user.getUsername(),
|
||||
}),
|
||||
iconURL: member.displayAvatarURL({
|
||||
extension: "png",
|
||||
size: 512,
|
||||
}),
|
||||
})
|
||||
.setColor(client.config.embed.color)
|
||||
.setFooter({
|
||||
text: client.config.embed.footer,
|
||||
});
|
||||
iconURL: member.displayAvatarURL(),
|
||||
},
|
||||
});
|
||||
|
||||
if (memberData.sanctions.length === 0) {
|
||||
embed.setDescription(interaction.translate("moderation/warns:NO_SANCTIONS", {
|
||||
member: member.nickname || member.user.username,
|
||||
}));
|
||||
embed.data.description = interaction.translate("moderation/warns:NO_SANCTIONS", {
|
||||
member: member.user.getUsername(),
|
||||
});
|
||||
|
||||
return interaction.reply({
|
||||
embeds: [embed],
|
||||
});
|
||||
} else {
|
||||
memberData.sanctions.forEach(sanction => {
|
||||
embed.addFields([
|
||||
{
|
||||
name: sanction.type,
|
||||
value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`,
|
||||
inline: true,
|
||||
},
|
||||
]);
|
||||
embed.data.fields.push({
|
||||
name: sanction.type,
|
||||
value: `${interaction.translate("common:MODERATOR")}: <@${sanction.moderator}>\n${interaction.translate("common:REASON")}: ${sanction.reason}`,
|
||||
inline: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
interaction.reply({
|
||||
embeds: [embed],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Warns;
|
||||
module.exports = Warns;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Back extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,27 +12,19 @@ class Back extends BaseCommand {
|
|||
.setName("back")
|
||||
.setDescription(client.translate("music/back:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/back:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/back:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/back:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/back:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const voice = interaction.member.voice.channel;
|
||||
|
@ -47,4 +39,4 @@ class Back extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Back;
|
||||
module.exports = Back;
|
||||
|
|
|
@ -6,7 +6,7 @@ const BaseCommand = require("../../base/BaseCommand"),
|
|||
class Clips extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -14,35 +14,30 @@ class Clips extends BaseCommand {
|
|||
.setName("clips")
|
||||
.setDescription(client.translate("music/clips:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/clips:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/clips:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/clips:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/clips:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addStringOption(option => option.setName("query")
|
||||
.setDescription(client.translate("music/clips:QUERY"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/clips:QUERY", null, "uk-UA"),
|
||||
"ru": client.translate("music/clips:QUERY", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("query")
|
||||
.setDescription(client.translate("music/clips:QUERY"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("music/clips:QUERY", null, "uk-UA"),
|
||||
ru: client.translate("music/clips:QUERY", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
@ -56,11 +51,7 @@ class Clips extends BaseCommand {
|
|||
|
||||
client.player.play(interaction.member.voice.channel, query, {
|
||||
nodeOptions: {
|
||||
metadata: {
|
||||
client,
|
||||
channel: interaction.channel,
|
||||
requestedBy: interaction.user,
|
||||
},
|
||||
metadata: interaction,
|
||||
},
|
||||
searchEngine: QueryType.FILE,
|
||||
selfDeaf: true,
|
||||
|
@ -79,7 +70,7 @@ class Clips extends BaseCommand {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").AutocompleteInteraction} interaction
|
||||
* @returns
|
||||
*/
|
||||
|
@ -88,13 +79,13 @@ class Clips extends BaseCommand {
|
|||
files = fs.readdirSync("./clips"),
|
||||
results = files.filter(f => f.includes(query));
|
||||
|
||||
return interaction.respond(
|
||||
return await interaction.respond(
|
||||
results.slice(0, 25).map(file => ({
|
||||
name: file.substring(0, file.length - 4),
|
||||
value: `./clips/${file}`,
|
||||
}),
|
||||
));
|
||||
})),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Clips;
|
||||
module.exports = Clips;
|
||||
|
|
|
@ -5,7 +5,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Loop extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,40 +13,35 @@ class Loop extends BaseCommand {
|
|||
.setName("loop")
|
||||
.setDescription(client.translate("music/loop:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/loop:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/loop:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/loop:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/loop:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addStringOption(option => option.setName("option")
|
||||
.setDescription(client.translate("music/loop:OPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/loop:OPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/loop:OPTION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: client.translate("music/loop:AUTOPLAY"), value: "3" },
|
||||
{ name: client.translate("music/loop:QUEUE"), value: "2" },
|
||||
{ name: client.translate("music/loop:TRACK"), value: "1" },
|
||||
{ name: client.translate("music/loop:DISABLE"), value: "0" },
|
||||
)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("option")
|
||||
.setDescription(client.translate("music/loop:OPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("music/loop:OPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/loop:OPTION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setChoices(
|
||||
{ name: client.translate("music/loop:AUTOPLAY"), value: "3" },
|
||||
{ name: client.translate("music/loop:QUEUE"), value: "2" },
|
||||
{ name: client.translate("music/loop:TRACK"), value: "1" },
|
||||
{ name: client.translate("music/loop:DISABLE"), value: "0" },
|
||||
),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const voice = interaction.member.voice.channel;
|
||||
|
@ -55,19 +50,20 @@ class Loop extends BaseCommand {
|
|||
const queue = client.player.nodes.get(interaction.guildId);
|
||||
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"),
|
||||
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);
|
||||
|
||||
interaction.success(`music/loop:${
|
||||
type === "3" ? "AUTOPLAY_ENABLED" :
|
||||
type === "2" ? "QUEUE_ENABLED" :
|
||||
type === "1" ? "TRACK_ENABLED" : "LOOP_DISABLED"
|
||||
}`);
|
||||
interaction.reply({ content: translated[type] });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Loop;
|
||||
module.exports = Loop;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder } = require("discord.js"),
|
||||
const { SlashCommandBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, StringSelectMenuOptionBuilder } = require("discord.js"),
|
||||
{ QueueRepeatMode } = require("discord-player");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Nowplaying extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,25 +13,183 @@ class Nowplaying extends BaseCommand {
|
|||
.setName("nowplaying")
|
||||
.setDescription(client.translate("music/nowplaying:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/nowplaying:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/nowplaying:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/nowplaying:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/nowplaying:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
async onLoad(client) {
|
||||
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/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
|
@ -40,59 +198,93 @@ class Nowplaying extends BaseCommand {
|
|||
|
||||
const queue = client.player.nodes.get(interaction.guildId);
|
||||
if (!queue) return interaction.error("music/play:NOT_PLAYING", null, { edit: true });
|
||||
const progressBar = queue.node.createProgressBar(),
|
||||
track = queue.currentTrack;
|
||||
|
||||
const embed = new EmbedBuilder()
|
||||
.setAuthor({
|
||||
name: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
|
||||
})
|
||||
.setThumbnail(track.thumbnail)
|
||||
.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 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("🔁"),
|
||||
);
|
||||
|
||||
interaction.editReply({
|
||||
const row2 = new ActionRowBuilder().addComponents(
|
||||
new ButtonBuilder().setCustomId("nowp_queue").setStyle(ButtonStyle.Secondary).setEmoji("ℹ️"),
|
||||
);
|
||||
|
||||
const embed = await updateEmbed(interaction, queue);
|
||||
|
||||
const message = await interaction.editReply({
|
||||
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;
|
||||
|
|
71
commands/Music/play.c.js
Normal file
|
@ -0,0 +1,71 @@
|
|||
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;
|
|
@ -1,10 +1,11 @@
|
|||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js");
|
||||
const { SlashCommandBuilder, PermissionsBitField } = require("discord.js"),
|
||||
{ QueryType } = require("discord-player");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Play extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,35 +13,30 @@ class Play extends BaseCommand {
|
|||
.setName("play")
|
||||
.setDescription(client.translate("music/play:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/play:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/play:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/play:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/play:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addStringOption(option => option.setName("query")
|
||||
.setDescription(client.translate("music/play:QUERY"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/play:QUERY", null, "uk-UA"),
|
||||
"ru": client.translate("music/play:QUERY", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true)),
|
||||
aliases: [],
|
||||
.addStringOption(option =>
|
||||
option
|
||||
.setName("query")
|
||||
.setDescription(client.translate("music/play:QUERY"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("music/play:QUERY", null, "uk-UA"),
|
||||
ru: client.translate("music/play:QUERY", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)
|
||||
.setAutocomplete(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply();
|
||||
|
@ -58,48 +54,66 @@ class Play extends BaseCommand {
|
|||
|
||||
if (!searchResult.hasTracks()) return interaction.error("music/play:NO_RESULT", { query }, { edit: true });
|
||||
else {
|
||||
client.player.play(interaction.member.voice.channel, searchResult, {
|
||||
await client.player.play(interaction.member.voice.channel, searchResult, {
|
||||
nodeOptions: {
|
||||
metadata: {
|
||||
client,
|
||||
channel: interaction.channel,
|
||||
requestedBy: interaction.user,
|
||||
},
|
||||
metadata: interaction,
|
||||
},
|
||||
selfDeaf: true,
|
||||
leaveOnEnd: false,
|
||||
leaveOnStop: true,
|
||||
skipOnNoStream: true,
|
||||
bufferingTimeout: 1000,
|
||||
maxSize: 200,
|
||||
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/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").AutocompleteInteraction} interaction
|
||||
* @returns
|
||||
*/
|
||||
async autocompleteRun(client, interaction) {
|
||||
const query = interaction.options.getString("query");
|
||||
if (query.includes("http") || query === "") return;
|
||||
|
||||
const results = await client.player.search(query);
|
||||
if (query === "") return;
|
||||
if (query.startsWith("http"))
|
||||
return interaction.respond([
|
||||
{
|
||||
name: "Current link",
|
||||
value: query,
|
||||
},
|
||||
]);
|
||||
|
||||
return interaction.respond(
|
||||
results.tracks.slice(0, 10).map(track => ({
|
||||
name: (`${track.author} - ${track.title}`.length >= 100 & `${track.author} - ${track.title}`.slice(0, 90) + "...") || `${track.author} - ${track.title}`,
|
||||
value: track.url,
|
||||
}),
|
||||
));
|
||||
const youtubeResults = await client.player.search(query, { searchEngine: QueryType.YOUTUBE });
|
||||
const spotifyResults = await client.player.search(query, { searchEngine: QueryType.SPOTIFY_SEARCH });
|
||||
const tracks = [];
|
||||
|
||||
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;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle } = require("discord.js"),
|
||||
{ QueueRepeatMode } = require("discord-player");
|
||||
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, ButtonBuilder, ButtonStyle } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand");
|
||||
|
||||
class Queue extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,141 +12,139 @@ class Queue extends BaseCommand {
|
|||
.setName("queue")
|
||||
.setDescription(client.translate("music/queue:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/queue:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/queue:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/queue:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/queue:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
async onLoad(client) {
|
||||
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/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const queue = client.player.nodes.get(interaction.guildId);
|
||||
if (!queue) return interaction.error("music/play:NOT_PLAYING");
|
||||
|
||||
let currentPage = 0;
|
||||
let embeds = generateQueueEmbeds(interaction, queue);
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
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("⏹️"),
|
||||
const { embeds, size } = generateQueueEmbeds(interaction, queue),
|
||||
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("❌"),
|
||||
);
|
||||
|
||||
await interaction.reply({
|
||||
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
|
||||
embeds: [embeds[currentPage]],
|
||||
if (interaction.customId) return await interaction.followUp({
|
||||
content: `${interaction.translate("common:PAGE")}: **1**/**${size}**`,
|
||||
embeds: [embeds[0]],
|
||||
components: [row],
|
||||
});
|
||||
|
||||
const filter = i => i.user.id === interaction.user.id;
|
||||
const collector = interaction.channel.createMessageComponentCollector({ filter, idle: (20 * 1000) });
|
||||
|
||||
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],
|
||||
});
|
||||
await interaction.reply({
|
||||
content: `${interaction.translate("common:PAGE")}: **1**/**${size}**`,
|
||||
embeds: [embeds[0]],
|
||||
components: [row],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -159,24 +156,29 @@ class Queue extends BaseCommand {
|
|||
* @returns
|
||||
*/
|
||||
function generateQueueEmbeds(interaction, queue) {
|
||||
const embeds = [];
|
||||
const currentTrack = queue.currentTrack;
|
||||
const embeds = [],
|
||||
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;
|
||||
|
||||
if (!queue.tracks.size) {
|
||||
const embed = new EmbedBuilder()
|
||||
.setTitle(interaction.translate("music/nowplaying:CURRENTLY_PLAYING"))
|
||||
.setThumbnail(currentTrack.thumbnail)
|
||||
.setColor(interaction.client.config.embed.color)
|
||||
.setDescription(`${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")
|
||||
}\`\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();
|
||||
const embed = interaction.client.embed({
|
||||
title: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
|
||||
thumbnail: currentTrack.thumbnail || null,
|
||||
description: `${interaction.translate("music/nowplaying:REPEAT")}: \`${translated[queue.repeatMode]}\`\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")}`,
|
||||
});
|
||||
|
||||
embeds.push(embed);
|
||||
|
||||
return embeds;
|
||||
return { embeds: embeds, size: embeds.length };
|
||||
}
|
||||
|
||||
for (let i = 0; i < queue.getSize(); i += 10) {
|
||||
|
@ -186,20 +188,18 @@ 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 embed = new EmbedBuilder()
|
||||
.setTitle(interaction.translate("music/nowplaying:CURRENTLY_PLAYING"))
|
||||
.setThumbnail(currentTrack.thumbnail)
|
||||
.setColor(interaction.client.config.embed.color)
|
||||
.setDescription(`${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")
|
||||
}\`\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();
|
||||
const embed = interaction.client.embed({
|
||||
title: interaction.translate("music/nowplaying:CURRENTLY_PLAYING"),
|
||||
thumbnail: currentTrack.thumbnail || null,
|
||||
description: `${interaction.translate("music/nowplaying:REPEAT")}: \`${translated[queue.repeatMode]}\`\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}`,
|
||||
});
|
||||
|
||||
embeds.push(embed);
|
||||
}
|
||||
|
||||
return embeds;
|
||||
return { embeds: embeds, size: embeds.length };
|
||||
}
|
||||
|
||||
module.exports = Queue;
|
||||
module.exports = Queue;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Seek extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,33 +12,28 @@ class Seek extends BaseCommand {
|
|||
.setName("seek")
|
||||
.setDescription(client.translate("music/seek:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/seek:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/seek:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/seek:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/seek:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.addIntegerOption(option => option.setName("time")
|
||||
.setDescription(client.translate("music/seek:TIME"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/seek:TIME", null, "uk-UA"),
|
||||
"ru": client.translate("music/seek:TIME", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("time")
|
||||
.setDescription(client.translate("music/seek:TIME"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("music/seek:TIME", null, "uk-UA"),
|
||||
ru: client.translate("music/seek:TIME", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const time = interaction.options.getInteger("time"),
|
||||
|
@ -55,4 +50,4 @@ class Seek extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Seek;
|
||||
module.exports = Seek;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Shuffle extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,27 +12,19 @@ class Shuffle extends BaseCommand {
|
|||
.setName("shuffle")
|
||||
.setDescription(client.translate("music/shuffle:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/shuffle:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/shuffle:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/shuffle:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/shuffle:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const voice = interaction.member.voice.channel;
|
||||
|
@ -46,4 +38,4 @@ class Shuffle extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Shuffle;
|
||||
module.exports = Shuffle;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Skip extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,27 +12,19 @@ class Skip extends BaseCommand {
|
|||
.setName("skip")
|
||||
.setDescription(client.translate("music/skip:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/skip:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/skip:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/skip:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/skip:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const voice = interaction.member.voice.channel;
|
||||
|
@ -46,4 +38,4 @@ class Skip extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Skip;
|
||||
module.exports = Skip;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Skipto extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,34 +12,29 @@ class Skipto extends BaseCommand {
|
|||
.setName("skipto")
|
||||
.setDescription(client.translate("music/skipto:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/skipto:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/skipto:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/skipto:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/skipto:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addIntegerOption(option => option.setName("position")
|
||||
.setDescription(client.translate("music/skipto:POSITION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/skipto:POSITION", null, "uk-UA"),
|
||||
"ru": client.translate("music/skipto:POSITION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true)),
|
||||
aliases: [],
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.setName("position")
|
||||
.setDescription(client.translate("music/skipto:POSITION"))
|
||||
.setDescriptionLocalizations({
|
||||
uk: client.translate("music/skipto:POSITION", null, "uk-UA"),
|
||||
ru: client.translate("music/skipto:POSITION", null, "ru-RU"),
|
||||
})
|
||||
.setRequired(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const voice = interaction.member.voice.channel;
|
||||
|
@ -55,10 +50,10 @@ class Skipto extends BaseCommand {
|
|||
queue.node.skipTo(queue.tracks.at(position - 1));
|
||||
|
||||
interaction.success("music/skipto:SUCCESS", {
|
||||
position,
|
||||
track: queue.tracks.at(0).title,
|
||||
});
|
||||
} else return interaction.error("music/skipto:ERROR", { position: position });
|
||||
} else return interaction.error("music/skipto:ERROR", { position });
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Skipto;
|
||||
module.exports = Skipto;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Stop extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,27 +12,19 @@ class Stop extends BaseCommand {
|
|||
.setName("stop")
|
||||
.setDescription(client.translate("music/stop:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/stop:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/stop:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/stop:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/stop:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const voice = interaction.member.voice.channel;
|
||||
|
@ -46,4 +38,4 @@ class Stop extends BaseCommand {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = Stop;
|
||||
module.exports = Stop;
|
||||
|
|
|
@ -4,7 +4,7 @@ const BaseCommand = require("../../base/BaseCommand");
|
|||
class Volume extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -12,35 +12,30 @@ class Volume extends BaseCommand {
|
|||
.setName("volume")
|
||||
.setDescription(client.translate("music/volume:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("music/volume:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("music/volume:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("music/volume:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("music/volume:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(false)
|
||||
.addIntegerOption(option => option.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)
|
||||
.setAutocomplete(true)),
|
||||
aliases: [],
|
||||
.addIntegerOption(option =>
|
||||
option
|
||||
.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)
|
||||
.setAutocomplete(true),
|
||||
),
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
const voice = interaction.member.voice.channel;
|
||||
|
@ -60,7 +55,7 @@ class Volume extends BaseCommand {
|
|||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").AutocompleteInteraction} interaction
|
||||
* @returns
|
||||
*/
|
||||
|
@ -68,13 +63,13 @@ class Volume extends BaseCommand {
|
|||
const int = interaction.options.getInteger("int"),
|
||||
results = Array.from({ length: 100 }, (_, k) => k + 1).filter(i => i.toString().includes(int));
|
||||
|
||||
return interaction.respond(
|
||||
return await interaction.respond(
|
||||
results.slice(0, 25).map(i => ({
|
||||
name: i,
|
||||
value: i,
|
||||
}),
|
||||
));
|
||||
})),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Volume;
|
||||
module.exports = Volume;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
const { SlashCommandBuilder, EmbedBuilder, ActionRowBuilder, StringSelectMenuBuilder } = require("discord.js");
|
||||
const { SlashCommandBuilder, ActionRowBuilder, StringSelectMenuBuilder, AttachmentBuilder } = require("discord.js");
|
||||
const BaseCommand = require("../../base/BaseCommand"),
|
||||
fetch = require("node-fetch");
|
||||
|
||||
class NSFW extends BaseCommand {
|
||||
/**
|
||||
*
|
||||
* @param {import("../base/JaBa")} client
|
||||
* @param {import("../base/Client")} client
|
||||
*/
|
||||
constructor(client) {
|
||||
super({
|
||||
|
@ -13,87 +13,74 @@ class NSFW extends BaseCommand {
|
|||
.setName("nsfw")
|
||||
.setDescription(client.translate("nsfw/nsfw:DESCRIPTION"))
|
||||
.setDescriptionLocalizations({
|
||||
"uk": client.translate("nsfw/nsfw:DESCRIPTION", null, "uk-UA"),
|
||||
"ru": client.translate("nsfw/nsfw:DESCRIPTION", null, "ru-RU"),
|
||||
uk: client.translate("nsfw/nsfw:DESCRIPTION", null, "uk-UA"),
|
||||
ru: client.translate("nsfw/nsfw:DESCRIPTION", null, "ru-RU"),
|
||||
})
|
||||
.setDMPermission(true),
|
||||
aliases: [],
|
||||
dirname: __dirname,
|
||||
ownerOnly: false,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import("../../base/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
*/
|
||||
async onLoad() {
|
||||
//...
|
||||
async onLoad(client) {
|
||||
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/JaBa")} client
|
||||
* @param {import("../../base/Client")} client
|
||||
* @param {import("discord.js").ChatInputCommandInteraction} interaction
|
||||
* @param {Object} data
|
||||
*/
|
||||
async execute(client, interaction) {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
if (interaction.guildId && !interaction.channel.nsfw) return interaction.replyT("misc:NSFW_COMMAND", null, { edit: true });
|
||||
if (interaction.guild && !interaction.channel.nsfw) return interaction.error("misc:NSFW_COMMAND", null, { edit: true, ephemeral: true });
|
||||
|
||||
const tags = ["hentai", "ecchi", "lewdanimegirls", "hentaifemdom", "animefeets", "animebooty", "biganimetiddies", "sideoppai", "ahegao"].map(tag =>
|
||||
JSON.parse(JSON.stringify({
|
||||
label: tag,
|
||||
value: tag,
|
||||
})),
|
||||
);
|
||||
|
||||
const row = new ActionRowBuilder()
|
||||
.addComponents(
|
||||
new StringSelectMenuBuilder()
|
||||
.setCustomId("nsfw_select")
|
||||
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
|
||||
.addOptions(tags),
|
||||
const tags = ["Hentai_Vanila", "Hentai_Yaoi", "Hentai_Yuri", "Hentai_BDSM", "Hentai_Trap", "Real_Ass", "Real_Boobs", "Real_Pussy"]
|
||||
.map(tag =>
|
||||
JSON.parse(
|
||||
JSON.stringify({
|
||||
label: `(${tag.split("_")[0]}) ${tag.split("_")[1]}`,
|
||||
value: tag,
|
||||
}),
|
||||
),
|
||||
);
|
||||
|
||||
const msg = await interaction.editReply({
|
||||
const row = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder().setCustomId("nsfw_select").setPlaceholder(interaction.translate("common:NOTHING_SELECTED")).addOptions(tags.slice(0, 25)));
|
||||
|
||||
await interaction.editReply({
|
||||
content: interaction.translate("common:AVAILABLE_OPTIONS"),
|
||||
ephemeral: true,
|
||||
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 === "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;
|
||||
|
|