Compare commits

...

206 commits

Author SHA1 Message Date
e6f239894f
pwease work 2024-04-27 18:47:08 +05:00
9b4b150643
update depends 2024-04-17 21:31:05 +05:00
dcdaf66b76
fix birthdays announcements (i hope) 2024-04-10 17:45:25 +05:00
321189f285
update for courses database changes 2024-04-10 09:15:28 +05:00
2cd08d3151
replace usernames with user mention 2024-04-07 20:14:04 +05:00
b0cdd9b2c9
update ignores 2024-04-07 16:18:13 +05:00
5a7a22c558
push clips folder 2024-04-07 16:18:02 +05:00
3896ee27da
update cat and dog locals 2024-04-07 16:04:47 +05:00
7618492300
update JaBa image 2024-04-07 15:33:25 +05:00
b1d1c5a0ab
v4.5.0 2024-04-07 15:29:16 +05:00
07658d64d2
fix /servers embeds 2024-04-04 11:50:59 +05:00
e65d9adbe1
update submodule link 2024-03-30 12:09:52 +05:00
cf4f510e82
v4.4.4 2024-03-30 12:06:19 +05:00
784f3e966a
fix nsfw 2024-03-27 19:20:04 +05:00
Jonny_Bro (Nikita)
f76a199789
remove title from nsfw 2024-03-21 16:18:37 +05:00
e3c4edfc2c
fix leaderboards 2024-03-19 19:01:45 +05:00
Jonny_Bro (Nikita)
39df50b877
update submodule to my local instance 2024-03-07 17:48:26 +05:00
Jonny_Bro (Nikita)
5ae0d289e1
fixed some random errors 2024-03-06 13:57:03 +05:00
Jonny_Bro (Nikita)
00d63d01b0
Floored memory usage in stats 2024-03-06 09:22:00 +05:00
Jonny_Bro (Nikita)
7130632844
update to new url shortener 2024-02-28 18:35:51 +05:00
Jonny_Bro (Nikita)
91d1e37be0
fix uptime calculation 2024-02-27 16:51:37 +05:00
Jonny_Bro (Nikita)
b9d7dfa51c
fix reminders 2024-02-17 21:34:26 +05:00
Jonny_Bro (Nikita)
8766a10469
remove userId from config 2024-02-14 21:16:13 +05:00
Jonny_Bro (Nikita)
1128269023
fix typo 2024-02-13 23:19:27 +05:00
Jonny_Bro (Nikita)
6479d434a7
fix work's embed 2024-02-12 17:03:14 +05:00
Jonny_Bro (Nikita)
0cde8ee856
Update config.sample.js 2024-02-12 14:00:19 +05:00
Jonny_Bro (Nikita)
8afa53d9b7
Update config.sample.js 2024-02-12 13:59:24 +05:00
Jonny_Bro (Nikita)
235621afd1
rollback achivements to english 2024-02-11 23:08:00 +05:00
Jonny_Bro (Nikita)
da3ece57b4
Update README.md 2024-02-10 16:37:34 +05:00
Jonny_Bro (Nikita)
589ea22619
remove old files (moved to wiki) 2024-02-09 23:50:43 +05:00
Jonny_Bro (Nikita)
1ff8784066
localize monitoring 2024-02-09 23:41:36 +05:00
Jonny_Bro (Nikita)
cc0fd759f7
v4.4.3 2024-02-09 23:26:57 +05:00
Jonny_Bro (Nikita)
427e1c6ae2
update embed generator 2024-02-09 21:30:11 +05:00
Jonny_Bro (Nikita)
c96d298f14
Update README.md 2024-02-09 18:37:43 +05:00
Jonny_Bro (Nikita)
e012981ef9
Update README.md 2024-02-09 18:37:01 +05:00
Jonny_Bro (Nikita)
d36394898e
Update README.md 2024-02-09 18:36:21 +05:00
Jonny_Bro (Nikita)
91d7849902
update README 2024-02-09 18:35:34 +05:00
Jonny_Bro (Nikita)
1cb6a8796b
update depends 2024-02-07 21:15:56 +05:00
Jonny_Bro (Nikita)
ac636b2da3
remove debug stuff 2024-02-07 21:10:39 +05:00
Jonny_Bro (Nikita)
8c139da4c2
wtf discord????? 2024-02-07 20:46:56 +05:00
Jonny_Bro (Nikita)
8265e1ad8d
update submodules for real 2024-02-06 21:52:10 +05:00
Jonny_Bro (Nikita)
79ec7b4e59
update submodules 2024-02-06 21:46:40 +05:00
Jonny_Bro (Nikita)
70a37c9ea0
v4.4.2 - https://blog.jababot.ru/update-4-4-2/ 2024-02-06 21:45:53 +05:00
Jonny_Bro (Nikita)
20b438fb5d
replace youtube-ext with ytdl-core 2024-02-02 21:02:15 +05:00
Jonny_Bro (Nikita)
b82a51b6bc
fix cat and dog yipeee 2024-02-02 20:49:55 +05:00
Jonny_Bro (Nikita)
e9855591b2
fix goodbye and welcome not setting image 2024-01-29 18:49:14 +05:00
Jonny_Bro (Nikita)
57b4acc540
reminder rework 2024-01-27 16:31:34 +05:00
Jonny_Bro (Nikita)
f33ff35e4b
pweaase 2024-01-23 16:11:10 +05:00
Jonny_Bro (Nikita)
8353cf0461
disable cat, crab and dog 2024-01-15 23:29:51 +05:00
Jonny_Bro (Nikita)
aec6ec7c58
v4.4.1 - https://blog.jababot.ru 2024-01-15 23:19:59 +05:00
Jonny_Bro (Nikita)
33f842088b
fix some quoting issues 2024-01-13 23:17:21 +05:00
Jonny_Bro (Nikita)
e67ce7cd53
should fix birthdays (oopsie daisy) 2024-01-13 00:51:35 +05:00
Jonny_Bro (Nikita)
e5737c4f95
update depends 2024-01-09 18:40:13 +05:00
Jonny_Bro (Nikita)
51a5e3e99b change up some emoji 2024-01-08 01:54:03 +05:00
Jonny_Bro (Nikita)
59b191aadc fix all languages errors 😎 2023-12-14 18:58:19 +05:00
Jonny_Bro (Nikita)
a8d8517876 should be good 2023-11-30 17:36:02 +05:00
Jonny_Bro (Nikita)
67c53c520d update depends 2023-11-25 22:13:15 +05:00
Jonny_Bro (Nikita)
ea3aebe4eb fix error if message now playing doesn't exist 2023-11-25 18:41:36 +05:00
Jonny_Bro (Nikita)
c9d61d0e98 some fixes 2023-11-24 22:09:17 +05:00
Jonny_Bro (Nikita)
d410aaaa24 fix translations for queue and nowplaying 2023-11-24 01:12:54 +05:00
Jonny_Bro (Nikita)
a945f42802 autoupdate nowplaying every 2 minutes 2023-11-21 01:19:46 +05:00
Jonny_Bro (Nikita)
87360465d1 fix play.c if there is no link in message 2023-11-20 20:14:15 +05:00
Jonny_Bro (Nikita)
b7565115c3 some clean up 2023-11-19 22:43:17 +05:00
Jonny_Bro (Nikita)
e07da7f183 Merge branch 'main' of https://github.com/JonnyBro/JaBa 2023-11-18 16:30:48 +05:00
Jonny_Bro (Nikita)
e5ffa7b622 use HTTPs in shorturl 2023-11-18 16:30:42 +05:00
Jonny_Bro (Nikita)
d3917faa3e
update icons in readme 2023-11-16 13:32:25 +05:00
Jonny_Bro (Nikita)
44c6de3fa5 fix embeds in tictactoe 2023-11-11 21:02:26 +05:00
Jonny_Bro (Nikita)
dbdc24f9b4 add an announcement to the updates.md 2023-11-10 18:24:24 +05:00
Jonny_Bro (Nikita)
4af141772a fix checkjar getting wrong jar 2023-11-06 18:38:38 +05:00
Jonny_Bro (Nikita)
7811127db6 im stupid 2023-11-06 18:23:02 +05:00
Jonny_Bro (Nikita)
c72c7f9023 ?????? 2023-11-06 18:19:48 +05:00
Jonny_Bro (Nikita)
39f34d45ee remove SC check 2023-11-06 18:18:16 +05:00
Jonny_Bro (Nikita)
8414ef0b83 Rename JaBa class to Client 2023-11-05 16:03:23 +05:00
Jonny_Bro (Nikita)
d2cb694ae8 fix repeat mode fr this time 2023-11-05 00:06:19 +05:00
Jonny_Bro (Nikita)
3a4f854fc0 change buttons order 2023-11-04 23:52:05 +05:00
Jonny_Bro (Nikita)
d47b3bf479 fix loop 2023-11-04 23:37:20 +05:00
Jonny_Bro (Nikita)
8afc01f648 revert some changes 2023-11-04 23:06:51 +05:00
Jonny_Bro (Nikita)
6774804543 fix? 2023-11-04 23:01:47 +05:00
Jonny_Bro (Nikita)
21d049dca8 update gitignore 2023-11-04 22:58:56 +05:00
Jonny_Bro (Nikita)
cb7e3ffd92 yes 2023-11-04 22:58:26 +05:00
Jonny_Bro (Nikita)
8513fb4326 typos 2023-11-04 16:57:37 +05:00
Jonny_Bro (Nikita)
a9edce1b75 v4.4.0 - https:/dash.jababot.ru/updates 2023-11-04 16:56:10 +05:00
Jonny_Bro (Nikita)
82a92f0caa
Update README.md 2023-11-01 18:46:29 +05:00
Jonny_Bro (Nikita)
efdab69651 v4.3.6 - https://dash.jababot.ru/updates 2023-10-31 22:24:40 +05:00
Jonny_Bro (Nikita)
bf3e6065c3 remove yandex music 2023-10-31 20:42:16 +05:00
Jonny_Bro (Nikita)
0c7e731a9c fix spotify hopefully 2023-10-31 20:35:12 +05:00
Jonny_Bro (Nikita)
58844d4873 update dashboard 2023-10-30 22:33:43 +05:00
Jonny_Bro (Nikita)
8e2c5bedad remove port from redirect 2023-10-30 22:07:56 +05:00
Jonny_Bro (Nikita)
5d8dc531bb update submodule 2023-10-30 22:06:15 +05:00
Jonny_Bro (Nikita)
113f4ae3e0 update depends 2023-10-30 21:45:10 +05:00
Jonny_Bro (Nikita)
3410fb2091 rewrite automod 2023-10-30 21:13:12 +05:00
Jonny_Bro (Nikita)
444a537f11 add name to skipto 2023-10-29 18:23:56 +05:00
Jonny_Bro (Nikita)
7a0a34cb98 add image if attached in quote 2023-10-22 14:24:53 +05:00
Jonny_Bro (Nikita)
b900207c44 update config sample 2023-10-22 00:30:31 +05:00
Jonny_Bro (Nikita)
f1366cc9ec change domain + rewrite quotes 2023-10-21 21:15:25 +05:00
Jonny_Bro (Nikita)
f7c1245f61 update depends 2023-10-21 14:45:47 +05:00
Jonny_Bro (Nikita)
46d4ee82ca fix queue 💀 2023-10-21 14:41:32 +05:00
Jonny_Bro (Nikita)
f628812c1c remove SunCountry 2023-10-20 22:47:00 +05:00
Jonny_Bro (Nikita)
3674666396 Update to MongoDB 5.0 2023-10-19 22:48:38 +05:00
Jonny_Bro (Nikita)
c9c4c62d3b 💀 2023-10-17 16:59:47 +05:00
Jonny_Bro (Nikita)
101b3e86c6 dsad 2023-10-17 16:58:10 +05:00
Jonny_Bro (Nikita)
8ba0e62308 raaaaaar 2023-10-17 16:55:12 +05:00
Jonny_Bro (Nikita)
01f64d474c Merge branch 'main' of https://github.com/JonnyBro/JaBa 2023-10-17 16:54:37 +05:00
Jonny_Bro (Nikita)
051a033545 fr fr 2023-10-17 16:54:26 +05:00
Jonny_Bro (Nikita)
7019dc3d98
Update birthdate.json ru 2 2023-10-17 12:49:49 +05:00
Jonny_Bro (Nikita)
3000f7277b
Update birthdate.json uk 2023-10-17 12:49:11 +05:00
Jonny_Bro (Nikita)
abd5ce6146
Update birthdate.json en 2023-10-17 12:48:25 +05:00
Jonny_Bro (Nikita)
ecc9729d4b
Update birthdate.json ru 2023-10-17 12:47:47 +05:00
Jonny_Bro (Nikita)
658499b47e fix remindme fr 2023-10-17 08:33:41 +05:00
Jonny_Bro (Nikita)
eb84a3e664 update readme 2023-10-16 18:33:22 +05:00
Jonny_Bro (Nikita)
92f64e4d94 yay 2023-10-15 15:05:10 +05:00
Jonny_Bro (Nikita)
19a58a9748 fix error 2023-10-12 19:44:26 +05:00
Jonny_Bro (Nikita)
c620e492c9 some cleanup in helpers functions 2023-10-10 20:44:42 +05:00
Jonny_Bro (Nikita)
89ce374f37 fix for DM use 2023-10-09 17:08:19 +05:00
Jonny_Bro (Nikita)
7b9549f883 ad 2023-10-08 18:24:17 +05:00
Jonny_Bro (Nikita)
04bb802cc5 use my own shorturl domain 2023-10-08 13:59:40 +05:00
Jonny_Bro (Nikita)
83414e817a fix minecraft error 2023-09-25 22:38:08 +05:00
Jonny_Bro (Nikita)
b6ee119e3d seek to given time in the link 2023-09-25 22:32:36 +05:00
Jonny_Bro (Nikita)
be634fa563 v4.3.5 - http://jababot.ru:8080/updates 2023-09-25 21:42:43 +05:00
Jonny_Bro (Nikita)
ceb2aebc5e update depends 2 2023-09-23 23:32:55 +05:00
Jonny_Bro (Nikita)
e33eb197f4 update depends 2023-09-23 23:27:29 +05:00
Jonny_Bro (Nikita)
035c4fed34
JACKPOT 2023-09-21 13:26:40 +05:00
Jonny_Bro (Nikita)
4b4e7cab16 change СЛОТЫ to SLOTS 2023-09-08 19:26:36 +05:00
Jonny_Bro (Nikita)
42d70b3dd7 fix usernames 2023-09-01 17:39:52 +05:00
Jonny_Bro (Nikita)
0d5ddc5fca
add missing 2023-08-29 12:18:36 +05:00
Jonny_Bro (Nikita)
222fa65371 update depends 2023-08-24 19:02:00 +05:00
Jonny_Bro (Nikita)
e10ca0ae74 update footers 2023-08-24 19:00:24 +05:00
Jonny_Bro (Nikita)
48d5754727 remove unused lines 2023-08-20 14:05:51 +05:00
Jonny_Bro (Nikita)
92d5ad0e71 more reliable way to find a ticket creator 2023-08-18 22:01:38 +05:00
Jonny_Bro (Nikita)
c16ab0d6a5 use server's locale in birthdays messages 2023-08-18 20:53:11 +05:00
Jonny_Bro (Nikita)
e5dcf03f95 oi 2023-08-16 20:46:27 +05:00
Jonny_Bro (Nikita)
d61d8e28df 🤷 2023-08-16 20:46:00 +05:00
Jonny_Bro (Nikita)
0c8ad6ce27
update format for printDate 2023-08-08 22:58:43 +05:00
Jonny_Bro (Nikita)
e8a7d9670f
maybe? 2023-08-08 22:22:06 +05:00
Jonny_Bro (Nikita)
eb934a37c3
rename closed ticket to {name}-closed 2023-08-08 17:28:03 +05:00
Jonny_Bro (Nikita)
ce30dae7fa
typo 2023-08-06 23:28:23 +05:00
Jonny_Bro (Nikita)
f2fb1c57bf
add missing translation 2023-08-06 23:19:20 +05:00
Jonny_Bro (Nikita)
35def3cf7c
fix random error? 2023-08-06 18:56:09 +05:00
Jonny_Bro (Nikita)
7d0680d5aa
fix stats not working in DMs 2023-08-05 18:51:39 +05:00
Jonny_Bro (Nikita)
e89e53ef58
Merge branches 'main' and 'main' of https://github.com/JonnyBro/JaBa 2023-08-05 14:34:17 +05:00
Jonny_Bro (Nikita)
77d1101808
Update translations 2023-08-05 14:31:11 +05:00
Jonny_Bro (Nikita)
11284a1996
Allow birthdate command in DMs 2023-08-03 13:02:48 +05:00
Jonny_Bro (Nikita)
cdc3f3fd3c
:O 2023-07-31 22:50:15 +05:00
Jonny_Bro (Nikita)
a2640556cc
Update README.md 2023-07-31 22:46:15 +05:00
Jonny_Bro (Nikita)
1574ac78d9 update depends 2023-07-31 22:09:27 +05:00
Jonny_Bro (Nikita)
2e119b9219 remove author 2023-07-26 22:16:03 +05:00
Jonny_Bro (Nikita)
2ca991cb39 update format for birthdate 2023-07-24 22:21:22 +05:00
Jonny_Bro (Nikita)
d95e3a6ec5 update localization 2023-07-23 00:03:53 +05:00
Jonny_Bro (Nikita)
c22ec58fe1 fix? 2023-07-22 23:59:14 +05:00
Jonny_Bro (Nikita)
7103692052 update config example 2023-07-19 21:43:56 +05:00
Jonny_Bro (Nikita)
0ac8ecddac ah 2023-07-10 21:15:02 +05:00
Jonny_Bro (Nikita)
02e31e8d9a raaar 2023-07-10 21:10:21 +05:00
Jonny_Bro (Nikita)
4d9ed056a7 oi 2023-07-10 21:07:24 +05:00
Jonny_Bro (Nikita)
741fd8d3d5 fixies 2023-07-10 21:02:38 +05:00
Jonny_Bro (Nikita)
e4e5e6b03f nah 2023-07-10 20:39:00 +05:00
Jonny_Bro (Nikita)
a185f50dba move settings to new file because it's too big 2023-07-10 20:37:50 +05:00
Jonny_Bro (Nikita)
78cfdb92a8 use guild's locale in printDate 2023-07-10 20:13:23 +05:00
Jonny_Bro (Nikita)
cea32c0deb update again 2023-07-07 21:52:16 +05:00
Jonny_Bro (Nikita)
00b37379f5 update 8ball 2023-07-07 21:50:36 +05:00
Jonny_Bro (Nikita)
c088c9f414 some minor spelling mistake 2023-07-07 21:16:45 +05:00
Jonny_Bro (Nikita)
053bf14ae5 v4.3.3 - http://jababot.ru:8080/updates 2023-07-07 21:13:11 +05:00
Jonny_Bro (Nikita)
aaa0d01c54 some tickets stuff 2023-07-07 17:34:23 +05:00
Jonny_Bro (Nikita)
c3dca64be4 prettier 2023-07-05 00:58:06 +05:00
Jonny_Bro (Nikita)
0fb732b1d0 remove unused crap 2023-07-04 23:40:22 +05:00
Jonny_Bro (Nikita)
aa2a18d529 update dependencies list 2023-07-04 01:45:18 +05:00
Jonny_Bro (Nikita)
d28b604f89 use pnpm 2023-07-04 01:31:08 +05:00
Jonny_Bro (Nikita)
45c7b93cf0 ? 2023-07-03 21:14:53 +05:00
Jonny_Bro (Nikita)
2ab201e1c1 fix permissions 2023-07-03 21:13:08 +05:00
Jonny_Bro (Nikita)
ac641f9c28 ManageGuild 2023-07-03 21:04:21 +05:00
Jonny_Bro (Nikita)
9f0d8007e8 updates link 2023-07-03 20:01:52 +05:00
Jonny_Bro (Nikita)
5219a47b91 update submodule again 2023-07-03 19:58:04 +05:00
Jonny_Bro (Nikita)
2d53c61608 updato 2023-07-03 19:43:50 +05:00
Jonny_Bro (Nikita)
b87d63c327 update submodule 2023-07-03 19:38:26 +05:00
Nikita
0e204528d0
Update README.md 2023-07-03 19:33:09 +05:00
Jonny_Bro (Nikita)
776be20851 v4.3.1 - https://jababot.ru 2023-07-03 19:30:47 +05:00
Nikita
f56975d1a8
Update README.md 2023-07-03 14:53:56 +05:00
Jonny_Bro (Nikita)
ec79480bcb extend the User object other than using a function 2023-07-03 14:25:25 +05:00
Jonny_Bro (Nikita)
76e8d16eb1 getUsername function 2023-07-02 21:02:55 +05:00
Jonny_Bro (Nikita)
55a4734926 update submodule 2023-07-02 01:44:29 +05:00
Jonny_Bro (Nikita)
97f4ef5590 update submodule 2023-07-02 01:14:45 +05:00
Jonny_Bro (Nikita)
006342a9da update submodule 2023-07-02 00:12:15 +05:00
Jonny_Bro (Nikita)
030f725777 update checkjar 2023-07-02 00:02:31 +05:00
Jonny_Bro (Nikita)
3aca11ebb3 oi 2023-06-29 14:00:08 +05:00
Jonny_Bro (Nikita)
7174722160 remove unused code 2023-06-27 21:19:55 +05:00
Jonny_Bro (Nikita)
f1eca51313 remove unused assets and code 2023-06-27 20:54:35 +05:00
Jonny_Bro (Nikita)
8fe40285e8 fix missing semicolon 2023-06-27 20:52:43 +05:00
Jonny_Bro (Nikita)
5009261839 update discord.js logo 2023-06-27 20:51:45 +05:00
Jonny_Bro (Nikita)
740bc9501c update packages 2023-06-27 19:18:42 +05:00
Nikita
4f1774af84
Update README.md 2023-06-27 19:12:25 +05:00
Nikita
d6758e9112
Update updates.md 2023-06-27 19:09:43 +05:00
Jonny_Bro (Nikita)
885d4ec3cc some ready event changes 2023-06-27 19:01:39 +05:00
Jonny_Bro (Nikita)
64ad5bf56f update submodule 2023-06-27 13:23:45 +05:00
Jonny_Bro (Nikita)
93c1db265e disable for now 2023-06-27 01:01:33 +05:00
Jonny_Bro (Nikita)
e91d0725d1 ? 2023-06-27 00:56:18 +05:00
Jonny_Bro (Nikita)
97898d88b1 hm 2023-06-27 00:52:58 +05:00
Jonny_Bro (Nikita)
8b304539ee no way 2023-06-27 00:49:32 +05:00
Jonny_Bro (Nikita)
14059cab22 update submodule 2023-06-27 00:43:46 +05:00
Jonny_Bro (Nikita)
0a899d1627 certificates 2023-06-27 00:41:09 +05:00
Jonny_Bro (Nikita)
da2a27bc85 change node to players 2023-06-27 00:28:41 +05:00
Jonny_Bro (Nikita)
7ace802d3e modules 2023-06-26 17:49:00 +05:00
Jonny_Bro (Nikita)
939252c072 ???? 2023-06-26 17:44:04 +05:00
Jonny_Bro (Nikita)
b7e7ad6c40 update submodule? 2023-06-26 17:43:20 +05:00
Jonny_Bro (Nikita)
ebfa1b9ae1 updato 2023-06-26 17:34:39 +05:00
Nikita
d325e40e49
v4.3.0 - https://github.com/JonnyBro/JaBa 2023-06-26 17:29:51 +05:00
Nikita
8edc8ffc88
New dashboard (#15) 2023-06-26 17:25:17 +05:00
Jonny_Bro (Nikita)
fa62deb39b use server avatar is possible 2023-06-22 17:36:58 +05:00
7638 changed files with 9845 additions and 711353 deletions

27
.gitignore vendored
View file

@ -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
View 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
View file

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

107
README.md
View file

@ -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-на-своей-машине)
* **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!
## *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/)
* [Панель управления](http://jababot.duckdns.org)
* [Dashboard](https://dash.jababot.ru)
## Поддержка
Перед **созданием сообщения об ошибке или вопросе**, пожалуйста, убедитесь что оно ещё не создано: [тык](https://github.com/JonnyBro/JaBa/issues).
Если у вас есть какие-либо вопросы, вы можете задать их на моём [Discord сервере](https://discord.gg/NPkySYKMkN).
Если вы хотите помочь в разработке, можете создать форк и отправить запрос на вытягивание: [тык](https://github.com/JonnyBro/JaBa/pulls)!
## 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).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

View file

@ -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,7 +15,7 @@ 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";
}
}

376
base/Client.js Normal file
View 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;

View file

@ -9,7 +9,9 @@ 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: {
plugins: {
type: Object,
default: {
welcome: {
enabled: false,
message: null,
@ -31,13 +33,23 @@ module.exports = mongoose.model("Guild", new Schema({
ignored: [],
},
warnsSanctions: {
kick: false,
ban: false,
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,
},
},
news: false,
suggestions: false,
modlogs: false,
birthdays: false,
reports: false,
} },
}));

View file

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

View file

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

View file

@ -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,7 +19,9 @@ const userSchema = new mongoose.Schema({
registeredAt: { type: Number, default: Date.now() },
achievements: { type: Object, default: {
achievements: {
type: Object,
default: {
married: {
achieved: false,
progress: {
@ -70,11 +71,15 @@ const userSchema = new mongoose.Schema({
total: 1,
},
},
} },
},
},
cooldowns: { type: Object, default: {
cooldowns: {
type: Object,
default: {
rep: 0,
} },
},
},
afk: { type: String, default: null },
reminds: { type: Array, default: [] },

73
commands/!DISABLED/ban.js Normal file
View 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;

View file

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

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

View file

@ -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,82 +13,65 @@ 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],
});
}
}

View file

@ -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,51 +12,46 @@ 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({

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

View file

@ -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,75 +12,85 @@ 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")
.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"),
uk: client.translate("common:STATE", null, "uk-UA"),
ru: client.translate("common:STATE", null, "ru-RU"),
})
.setRequired(true))
.addChannelOption(option => option.setName("channel")
.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"),
uk: client.translate("common:CHANNEL", null, "uk-UA"),
ru: client.translate("common:CHANNEL", null, "ru-RU"),
})
.addChannelTypes(ChannelType.GuildText)),
aliases: [],
.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:${state ? "ENABLED" : "DISABLED"}`);
} else if (command === "ignore") {
data.guild.plugins.automod.ignored.push(channel.id);
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:DISABLED");
}
}
}
}

View file

@ -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,68 +12,64 @@ 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")
.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"),
uk: client.translate("common:STATE", null, "uk-UA"),
ru: client.translate("common:STATE", null, "ru-RU"),
})
.setRequired(true))
.addRoleOption(option => option.setName("role")
.setRequired(true),
)
.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: [],
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");
data.guildData.plugins.autorole = {
enabled: true,
role: role.id,
guildData.plugins.autorole = {
enabled: state,
role,
};
data.guildData.markModified("plugins.autorole");
await data.guildData.save();
interaction.success("administration/autorole:SUCCESS_ENABLED", {
if (state && role) {
guildData.markModified("plugins.autorole");
await guildData.save();
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");
}
}
}

View file

@ -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,89 +12,94 @@ 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")
.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"),
uk: client.translate("administration/config:LIST", null, "uk-UA"),
ru: client.translate("administration/config:LIST", null, "ru-RU"),
}),
)
.addSubcommand(subcommand => subcommand.setName("set")
.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"),
uk: client.translate("administration/config:SET", null, "uk-UA"),
ru: client.translate("administration/config:SET", null, "ru-RU"),
})
.addStringOption(option => option.setName("setting")
.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"),
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:NEWS"), value: "news" },
{ name: client.translate("administration/config:REPORTS"), value: "reports" },
{ name: client.translate("administration/config:SUGGESTIONS"), value: "suggestions" },
{ name: client.translate("administration/config:TICKETSCATEGORY"), value: "tickets.ticketsCategory" },
{ name: client.translate("administration/config:TICKETLOGS"), value: "tickets.ticketLogs" },
{ name: client.translate("administration/config:TRANSCRIPTIONLOGS"), value: "tickets.transcriptionLogs" },
{ name: client.translate("administration/config:MESSAGEUPDATE"), value: "monitoring.messageUpdate" },
{ name: client.translate("administration/config:MESSAGEDELETE"), value: "monitoring.messageDelete" },
)
.setRequired(true))
.addBooleanOption(option => option.setName("state")
.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"),
uk: client.translate("common:STATE", null, "uk-UA"),
ru: client.translate("common:STATE", null, "ru-RU"),
})
.setRequired(true))
.addChannelOption(option => option.setName("channel")
.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"),
})),
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", {
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"),
@ -102,7 +107,8 @@ class Config extends BaseCommand {
},
{
name: interaction.translate("administration/config:GOODBYE_TITLE"),
value: guildData.plugins.goodbye.enabled ? interaction.translate("administration/config:GOODBYE_CONTENT", {
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"),
@ -110,46 +116,51 @@ class Config extends BaseCommand {
},
{
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", {
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", {
}) : 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", {
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: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")}*`,
}),
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:DASHBOARD_TITLE"),
// value: `[${interaction.translate("administration/config:DASHBOARD_CONTENT")}](${client.config.dashboard.baseURL})`
// }
]);
{
name: interaction.translate("administration/config:SPECIAL_CHANNELS"),
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.domain})`,
},
],
});
interaction.reply({
embeds: [embed],
@ -170,14 +181,53 @@ 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) {
const settingSplitted = setting.split("."),
data = interaction.data.guild;
if (settingSplitted.length === 2) {
if (data.plugins[settingSplitted[0]] === undefined) data.plugins[settingSplitted[0]] = {};
if (!state) {
interaction.guild.data.plugins[setting] = null;
interaction.guild.data.markModified(`plugins.${setting}`);
await interaction.guild.data.save();
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 (!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:DISABLED")}**`,
@ -185,9 +235,10 @@ async function changeSetting(interaction, setting, state, channel) {
});
} else {
if (channel) {
interaction.guild.data.plugins[setting] = channel.id;
interaction.guild.data.markModified(`plugins.${setting}`);
await interaction.guild.data.save();
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()})`,
@ -195,10 +246,13 @@ async function changeSetting(interaction, setting, state, channel) {
});
} 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()}`)}: ${
data.plugins[setting] ? `**${interaction.translate("common:ENABLED")}** (<#${data.plugins[setting]}>)` : `**${interaction.translate("common:DISABLED")}**`
}`,
ephemeral: true,
});
}
}
}
module.exports = Config;

View file

@ -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")
.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"),
uk: client.translate("administration/goodbye:TEST", null, "uk-UA"),
ru: client.translate("administration/goodbye:TEST", null, "ru-RU"),
}),
)
.addSubcommand(subcommand => subcommand.setName("config")
.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"),
uk: client.translate("administration/goodbye:CONFIG", null, "uk-UA"),
ru: client.translate("administration/goodbye:CONFIG", null, "ru-RU"),
})
.addBooleanOption(option => option.setName("state")
.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"),
uk: client.translate("common:STATE", null, "uk-UA"),
ru: client.translate("common:STATE", null, "ru-RU"),
})
.setRequired(true))
.addChannelOption(option => option.setName("channel")
.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")
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")
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"),
})),
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,32 +94,34 @@ 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 });
}
}

View file

@ -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")
.setDefaultMemberPermissions(PermissionsBitField.Flags.ManageGuild)
.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"),
uk: client.translate("administration/selectroles:MESSAGE", null, "uk-UA"),
ru: client.translate("administration/selectroles:MESSAGE", null, "ru-RU"),
})
.addStringOption(option => option.setName("text")
.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"),
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true)),
.setRequired(true),
),
)
.addSubcommand(subcommand => subcommand.setName("addrole")
.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"),
uk: client.translate("administration/selectroles:ADDROLE", null, "uk-UA"),
ru: client.translate("administration/selectroles:ADDROLE", null, "ru-RU"),
})
.addChannelOption(option => option.setName("channel")
.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"),
uk: client.translate("common:CHANNEL", null, "uk-UA"),
ru: client.translate("common:CHANNEL", null, "ru-RU"),
})
.setRequired(true))
.addStringOption(option => option.setName("message_id")
.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"),
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")
.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"),
uk: client.translate("common:ROLE", null, "uk-UA"),
ru: client.translate("common:ROLE", null, "ru-RU"),
})
.setRequired(true)),
.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 = [{
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(
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")
.setMinValues(0)
.setMaxValues(1)
.setPlaceholder(interaction.translate("common:AVAILABLE_OPTIONS"))
.addOptions(option),
);
row.addComponents(new StringSelectMenuBuilder().setCustomId("auto_roles").setMinValues(0).setMaxValues(1).setPlaceholder(interaction.translate("common:AVAILABLE_OPTIONS")).addOptions(option));
}
message.edit({

View file

@ -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,16 +12,18 @@ 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")
.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"),
uk: client.translate("owner/debug:TYPE", null, "uk-UA"),
ru: client.translate("owner/debug:TYPE", null, "ru-RU"),
})
.setRequired(true)
.setChoices(
@ -29,38 +31,37 @@ class Set extends BaseCommand {
{ 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")
),
)
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true))
.addIntegerOption(option => option.setName("int")
.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"),
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,

View file

@ -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")
.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"),
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: [],
.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,

View file

@ -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")
.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"),
uk: client.translate("common:EMOJI", null, "uk-UA"),
ru: client.translate("common:EMOJI", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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", {
.then(emoji =>
interaction.success("administration/stealemoji:SUCCESS", {
emoji: emoji.name,
}, { ephemeral: true }))
}, { ephemeral: true }),
)
.catch(e => {
interaction.error("administration/stealemoji:ERROR", {
emoji: parsedEmoji.name,

View file

@ -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")
.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"),
uk: client.translate("administration/goodbye:TEST", null, "uk-UA"),
ru: client.translate("administration/goodbye:TEST", null, "ru-RU"),
}),
)
.addSubcommand(subcommand => subcommand.setName("config")
.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"),
uk: client.translate("administration/goodbye:CONFIG", null, "uk-UA"),
ru: client.translate("administration/goodbye:CONFIG", null, "ru-RU"),
})
.addBooleanOption(option => option.setName("state")
.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"),
uk: client.translate("common:STATE", null, "uk-UA"),
ru: client.translate("common:STATE", null, "ru-RU"),
})
.setRequired(true))
.addChannelOption(option => option.setName("channel")
.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")
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")
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"),
})),
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,32 +94,34 @@ 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 });
}
}

View file

@ -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,52 +12,41 @@ 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")
.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: [],
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([
iconURL: user.displayAvatarURL(),
},
fields: [
{
name: interaction.translate("economy/achievements:SEND_CMD"),
value: interaction.translate("economy/achievements:PROGRESS", {
@ -114,7 +103,8 @@ class Achievements extends BaseCommand {
percent: Math.round(100 * (userData.achievements.invite.progress.now / userData.achievements.invite.progress.total)),
}),
},
]);
],
});
interaction.reply({
embeds: [embed],

View file

@ -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")
.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"),
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")
.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"),
uk: client.translate("misc:OPTION_NAN_ALL", null, "uk-UA"),
ru: client.translate("misc:OPTION_NAN_ALL", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.setRequired(true),
),
dirname: __dirname,
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"))}`,

View file

@ -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,22 +12,27 @@ 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")
.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"),
uk: client.translate("economy/birthdate:DAY", null, "uk-UA"),
ru: client.translate("economy/birthdate:DAY", null, "ru-RU"),
})
.setRequired(true))
.addIntegerOption(option => option.setName("month")
.setRequired(true),
)
.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"),
uk: client.translate("economy/birthdate:MONTH", null, "uk-UA"),
ru: client.translate("economy/birthdate:MONTH", null, "ru-RU"),
})
.setRequired(true)
.setChoices(
@ -43,47 +48,47 @@ class Birthdate extends BaseCommand {
{ 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")
),
)
.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"),
uk: client.translate("economy/birthdate:YEAR", null, "uk-UA"),
ru: client.translate("economy/birthdate:YEAR", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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>`,
});
}
}

View file

@ -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,50 +12,48 @@ 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(),
});
try {
user.send({
content: interaction.translate("economy/divorce:DIVORCED_U", {
user: interaction.member.toString(),
}),
});
} catch (e) { /**/ }
}
}

View file

@ -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")
.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"),
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: [],
.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({
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,15 +120,7 @@ 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([
embed.data.fields = [
{
name: interaction.translate("common:USER"),
value: userNames.join("\n"),
@ -148,7 +136,7 @@ class Leaderboard extends BaseCommand {
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],

View file

@ -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")
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,16 +83,9 @@ 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({
@ -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: [{
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,15 +164,13 @@ class Marry extends BaseCommand {
}),
components: [],
});
} else {
return interaction.editReply({
} else return interaction.editReply({
content: interaction.translate("economy/marry:DENIED", {
creator: interaction.member.toString(),
partner: member.toString(),
}),
}, "error"),
components: [],
});
}
});
}
}

View file

@ -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")
.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: [],
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,11 +77,9 @@ 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],
});

View file

@ -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,82 +12,86 @@ 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")
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true))
.addIntegerOption(option => option.setName("amount")
.setRequired(true),
)
.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"),
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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", {
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"))}`,
});
}

View file

@ -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")
.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: [],
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"),
@ -117,38 +102,36 @@ 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: [{
embeds: [embed],
files: [
{
name: "achievements.png",
attachment: buffer,
}],
attachment: achievements,
},
],
});
}
}

View file

@ -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,40 +12,38 @@ 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")
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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>`,
});
}
@ -53,34 +51,36 @@ class Rep extends BaseCommand {
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: [{
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(),

View file

@ -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")
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true))
.addIntegerOption(option => option.setName("amount")
.setRequired(true),
)
.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"),
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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", {
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: `**${data.memberData.money}** ${client.functions.getNoun(data.memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
moneyCurrent: `**${memberData.money}** ${client.functions.getNoun(memberData.money, interaction.translate("misc:NOUNS:CREDIT:1"), interaction.translate("misc:NOUNS:CREDIT:2"), interaction.translate("misc:NOUNS:CREDIT:5"))}`,
});
const itsAWon = Math.floor(client.functions.randomNum(0, 100) < 25);
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,14 +103,16 @@ 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();
}
}
}

View file

@ -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,41 +12,40 @@ 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")
.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"),
uk: client.translate("economy/profile:BIO", null, "uk-UA"),
ru: client.translate("economy/profile:BIO", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.setRequired(true),
),
dirname: __dirname,
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");
}
}

View file

@ -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")
.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"),
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,31 +77,33 @@ 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", {
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(),
@ -109,36 +112,43 @@ class Slots extends BaseCommand {
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: [{
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: [{
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";

View file

@ -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,71 +12,72 @@ 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")
.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: [],
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,
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([
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.addFields([
if (sortedTransactions[1].length > 0)
embed.data.fields.push([
{
name: interaction.translate("economy/transactions:T_SEND"),
value: sortedTransactions[1].join("\n"),

View file

@ -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,22 +105,26 @@ 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 = [{
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",
}];
data.userData.achievements.work.achieved = true;
},
];
userData.achievements.work.achieved = true;
}
data.userData.markModified("achievements.work");
await data.userData.save();
userData.markModified("achievements");
await userData.save();
}
interaction.reply(messageOptions);

View file

@ -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,46 +12,50 @@ 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")
.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"),
uk: client.translate("fun/8ball:QUESTION", null, "uk-UA"),
ru: client.translate("fun/8ball:QUESTION", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.setRequired(true),
),
dirname: __dirname,
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] });
}
}

View file

@ -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,36 +13,31 @@ 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] });
}
}

View file

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

View file

@ -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,36 +13,31 @@ 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] });
}
}

View file

@ -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")
.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"),
uk: client.translate("fun/lmgtfy:QUERY", null, "uk-UA"),
ru: client.translate("fun/lmgtfy:QUERY", null, "ru-RU"),
})
.setRequired(true))
.addBooleanOption(option => option.setName("short")
.setRequired(true),
)
.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"),
uk: client.translate("fun/lmgtfy:SHORT", null, "uk-UA"),
ru: client.translate("fun/lmgtfy:SHORT", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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({

View file

@ -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,18 +59,15 @@ 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({

View file

@ -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,15 +87,19 @@ class Number extends BaseCommand {
};
data.memberData.transactions.push(info);
memberData.markModified("transactions");
await memberData.save();
}
collector.stop();
}
if (parseInt(msg.content) < number) msg.reply({
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({
if (parseInt(msg.content) > number)
msg.reply({
content: interaction.translate("fun/number:TOO_SMALL", { user: msg.author.toString(), number: parsedNumber }),
});
});

View file

@ -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")
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,7 +56,12 @@ class TicTacToe extends BaseCommand {
date: Date.now(),
type: "got",
};
memberData.transactions.push(info);
memberData.markModified("money");
memberData.markModified("transactions");
await memberData.save();
});
}
}

View file

@ -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")
.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"),
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,

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

View file

@ -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,48 +12,45 @@ 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")
.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")
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: [],
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],
});
}
}

View file

@ -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,14 +98,9 @@ class Boosters extends BaseCommand {
return;
}
});
} else if (i.customId === "boosters_stop") {
i.deferUpdate();
collector.stop();
}
}
});
} else if (interaction.customId === "boosters_stop") {
await interaction.deferUpdate();
collector.on("end", () => {
row.components.forEach(component => {
component.setDisabled(true);
});
@ -142,36 +108,64 @@ class Boosters extends BaseCommand {
return interaction.editReply({
components: [row],
});
}
}
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
await interaction.deferReply();
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);
}

View file

@ -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")
.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"),
uk: client.translate("commom:EMOJI", null, "uk-UA"),
ru: client.translate("common:EMOJI", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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],

View file

@ -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,41 +136,35 @@ 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;

View file

@ -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")
.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"),
uk: client.translate("common:IP", null, "uk-UA"),
ru: client.translate("common:IP", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,17 +92,12 @@ 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({

View file

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

View file

@ -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,65 +13,79 @@ 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")
.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"),
uk: client.translate("general/remindme:TIME", null, "uk-UA"),
ru: client.translate("general/remindme:TIME", null, "ru-RU"),
})
.setRequired(true))
.addStringOption(option => option.setName("message")
.setRequired(true),
)
.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"),
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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],
});
}
}

176
commands/General/reminds.js Normal file
View 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;

View file

@ -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")
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true))
.addStringOption(option => option.setName("message")
.setRequired(true),
)
.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"),
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,10 +83,7 @@ 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;

View file

@ -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,16 +86,30 @@ 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({

View file

@ -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,42 +13,45 @@ 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")
.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"),
uk: client.translate("common:URL", null, "uk-UA"),
ru: client.translate("common:URL", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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}>`,
});
}
}

View file

@ -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,17 +81,18 @@ 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] }),
donateLink: "https://www.donationalerts.com/r/jonny_bro",
owner: client.config.owner.id,
}),
},
]);
],
});
interaction.reply({
embeds: [statsEmbed],
embeds: [embed],
});
}
}

View file

@ -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")
.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"),
uk: client.translate("common:MESSAGE", null, "uk-UA"),
ru: client.translate("common:MESSAGE", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,7 +79,7 @@ class Suggest extends BaseCommand {
});
interaction.success("general/suggest:SUCCESS", {
channel: suggChannel.toString(),
channel: channel.toString(),
}, { ephemeral: true });
}
}

View file

@ -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")
.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: [],
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,36 +78,18 @@ 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", {
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).join(", ")),
})
: 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],
});

View file

@ -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")
.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"),
uk: client.translate("common:IP", null, "uk-UA"),
ru: client.translate("common:IP", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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],

View file

@ -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)} грн`,
},
]);
});

View file

@ -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")
.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"),
uk: client.translate("moderation/clear:OPTION", null, "uk-UA"),
ru: client.translate("moderation/clear:OPTION", null, "ru-RU"),
})
.setRequired(true))
.addUserOption(option => option.setName("user")
.setRequired(true),
)
.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")
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: [],
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,16 +63,9 @@ 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({
@ -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", {

View file

@ -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")
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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(),

View file

@ -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")
.setDefaultMemberPermissions(PermissionsBitField.Flags.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"),
uk: client.translate("moderation/giveaway:CREATE", null, "uk-UA"),
ru: client.translate("moderation/giveaway:CREATE", null, "ru-RU"),
})
.addStringOption(option => option.setName("duration")
.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"),
uk: client.translate("common:DURATION", null, "uk-UA"),
ru: client.translate("common:DURATION", null, "ru-RU"),
})
.setRequired(true))
.addIntegerOption(option => option.setName("winners_count")
.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"),
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")
.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"),
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")
.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"),
uk: client.translate("moderation/giveaway:ISDROP", null, "uk-UA"),
ru: client.translate("moderation/giveaway:ISDROP", null, "ru-RU"),
})
.setRequired(true)),
.setRequired(true),
),
)
.addSubcommand(subcommand => subcommand.setName("reroll")
.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"),
uk: client.translate("moderation/giveaway:REROLL", null, "uk-UA"),
ru: client.translate("moderation/giveaway:REROLL", null, "ru-RU"),
})
.addStringOption(option => option.setName("giveaway_id")
.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"),
uk: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
})
.setRequired(true)),
.setRequired(true),
),
)
.addSubcommand(subcommand => subcommand.setName("end")
.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"),
uk: client.translate("moderation/giveaway:END", null, "uk-UA"),
ru: client.translate("moderation/giveaway:END", null, "ru-RU"),
})
.addStringOption(option => option.setName("giveaway_id")
.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"),
uk: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
})
.setRequired(true)),
.setRequired(true),
),
)
.addSubcommand(subcommand => subcommand.setName("delete")
.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"),
uk: client.translate("moderation/giveaway:DELETE", null, "uk-UA"),
ru: client.translate("moderation/giveaway:DELETE", null, "ru-RU"),
})
.addStringOption(option => option.setName("giveaway_id")
.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"),
uk: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "uk-UA"),
ru: client.translate("moderation/giveaway:GIVEAWAY_ID", null, "ru-RU"),
})
.setRequired(true)),
.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,7 +150,8 @@ class Giveaway extends BaseCommand {
const prize = interaction.options.getString("prize");
const isdrop = interaction.options.getBoolean("isdrop");
client.giveawaysManager.start(interaction.channel, {
client.giveawaysManager
.start(interaction.channel, {
duration: ms(duration),
winnerCount: winnersCount,
prize: prize,
@ -149,20 +171,24 @@ class Giveaway extends BaseCommand {
endedAt: interaction.translate("moderation/giveaway:END_AT"),
hostedBy: interaction.translate("moderation/giveaway:HOSTED_BY"),
},
}).then(() => {
})
.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, {
client.giveawaysManager
.reroll(giveaway_id, {
messages: {
congrat: interaction.translate("moderation/giveaway:REROLL_CONGRAT"),
error: interaction.translate("moderation/giveaway:REROLL_ERROR"),
},
}).then(() => {
})
.then(() => {
return interaction.success("moderation/giveaway:GIVEAWAY_REROLLED");
}).catch(() => {
})
.catch(() => {
return interaction.error("moderation/giveaway:NOT_FOUND_ENDED", {
messageId: giveaway_id,
}, { ephemeral: true });
@ -181,9 +207,12 @@ class Giveaway extends BaseCommand {
} else if (command === "delete") {
const giveaway_id = interaction.options.getString("giveaway_id");
client.giveawaysManager.delete(giveaway_id).then(() => {
client.giveawaysManager
.delete(giveaway_id)
.then(() => {
return interaction.success("moderation/giveaway:GIVEAWAY_DELETED");
}).catch(() => {
})
.catch(() => {
return interaction.error("moderation/giveaway:NOT_FOUND", {
messageId: giveaway_id,
}, { ephemeral: true });

View file

@ -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,60 +12,41 @@ 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")
.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"),
uk: client.translate("moderation/poll:QUESTION", null, "uk-UA"),
ru: client.translate("moderation/poll:QUESTION", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.setRequired(true),
),
dirname: __dirname,
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"),
ephemeral: true,
@ -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,

View file

@ -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")
.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"),
uk: client.translate("common:USER_ID", null, "uk-UA"),
ru: client.translate("common:USER_ID", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.setRequired(true),
),
dirname: __dirname,
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"),

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

View file

@ -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,10 +55,12 @@ class Warn extends BaseCommand {
await interaction.showModal(modal);
const submitted = await interaction.awaitModalSubmit({
time: (2 * 60 * 1000),
const submitted = await interaction
.awaitModalSubmit({
time: 2 * 60 * 1000,
filter: i => i.user.id === interaction.member.id && i.customId === "warn_modal",
}).catch(() => {
})
.catch(() => {
interaction.followUp({
content: interaction.translate("misc:TIMED_OUT"),
ephemeral: true,
@ -74,9 +70,9 @@ class Warn extends BaseCommand {
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"))}`,
}),
});
}
}
} */
member.send({
try {
await member.send({
content: interaction.translate("moderation/warn:WARNED_DM", {
user: member.user.discriminator === "0" ? member.user.username : member.user.tag,
user: member.toString(),
server: interaction.guild.name,
moderator: interaction.user.discriminator === "0" ? interaction.user.username : interaction.user.tag,
moderator: interaction.user.toString(),
reason,
}),
});
embed
.setAuthor({
name: interaction.translate("moderation/warn:WARN"),
})
.setColor(client.config.embed.color);
} catch (e) {
interaction.followUp({ content: interaction.translate("misc:CANT_DM"), ephemeral: true });
}
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;

View file

@ -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")
.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"),
uk: client.translate("common:USER", null, "uk-UA"),
ru: client.translate("common:USER", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.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,39 +46,33 @@ 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([
{
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],
});

View file

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

View file

@ -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")
.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"),
uk: client.translate("music/clips:QUERY", null, "uk-UA"),
ru: client.translate("music/clips:QUERY", null, "ru-RU"),
})
.setRequired(true)
.setAutocomplete(true)),
aliases: [],
.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,12 +79,12 @@ 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}`,
}),
));
})),
);
}
}

View file

@ -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,15 +13,17 @@ 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")
.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"),
uk: client.translate("music/loop:OPTION", null, "uk-UA"),
ru: client.translate("music/loop:OPTION", null, "ru-RU"),
})
.setRequired(true)
.setChoices(
@ -29,24 +31,17 @@ class Loop extends BaseCommand {
{ 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: [],
),
),
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,18 +50,19 @@ 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] });
}
}

View file

@ -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,15 +198,60 @@ 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([
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(""),
);
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);
}
}
/**
*
* @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})`,
@ -62,7 +265,7 @@ class Nowplaying extends BaseCommand {
{ 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),
value: track.raw.live ? "Live" : new Intl.NumberFormat(interaction.client.defaultLanguage.moment, { notation: "standard" }).format(track.raw.views),
inline: true,
},
{
@ -75,24 +278,13 @@ class Nowplaying extends BaseCommand {
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")
}\``,
name: "\u200B",
value: `${interaction.translate("music/nowplaying:REPEAT")}: \`${translated[mode]}\``,
},
])
.setColor(client.config.embed.color)
.setFooter({
text: client.config.embed.footer,
})
.setTimestamp();
interaction.editReply({
embeds: [embed],
],
});
}
return embed;
}
module.exports = Nowplaying;

71
commands/Music/play.c.js Normal file
View 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;

View file

@ -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")
.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"),
uk: client.translate("music/play:QUERY", null, "uk-UA"),
ru: client.translate("music/play:QUERY", null, "ru-RU"),
})
.setRequired(true)
.setAutocomplete(true)),
aliases: [],
.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,47 +54,65 @@ 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,
songName: searchResult.hasPlaylist() ? searchResult.playlist.title : `${searchResult.tracks[0].title} - ${searchResult.tracks[0].author}`,
}),
});
}
}
/**
*
* @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);
}
}

View file

@ -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,134 +12,100 @@ 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() {
//...
}
/**
*
* @param {import("../../base/JaBa")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
* @param {Object} data
*/
async execute(client, interaction) {
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");
let currentPage = 0;
let embeds = generateQueueEmbeds(interaction, queue);
const { embeds, size } = 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("⏹️"),
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("❌"),
);
await interaction.reply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
embeds: [embeds[currentPage]],
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 (interaction.customId === "queue_prev_page") {
await interaction.deferUpdate();
if (currentPage !== 0) {
--currentPage;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${size}**`,
embeds: [embeds[currentPage]],
components: [row],
});
}
} else if (i.customId === "queue_next_page") {
i.deferUpdate();
if (embeds != generateQueueEmbeds(interaction, queue)) embeds = generateQueueEmbeds(interaction, queue);
} else if (interaction.customId === "queue_next_page") {
await interaction.deferUpdate();
if (currentPage < embeds.length - 1) {
if (currentPage < size - 1) {
currentPage++;
interaction.editReply({
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${embeds.length}**`,
content: `${interaction.translate("common:PAGE")}: **${currentPage + 1}**/**${size}**`,
embeds: [embeds[currentPage]],
components: [row],
});
}
} else if (i.customId === "queue_jump_page") {
i.deferUpdate();
if (embeds != generateQueueEmbeds(interaction, queue)) embeds = generateQueueEmbeds(interaction, queue);
} else if (interaction.customId === "queue_jump_page") {
await interaction.deferUpdate();
const msg = await interaction.followUp({
content: interaction.translate("misc:JUMP_TO_PAGE", {
length: embeds.length,
}),
fetchReply: true,
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 = res => {
return res.author.id === interaction.user.id && !isNaN(res.content);
};
const filter = i => i.user.id === interaction.user.id,
collected = await msg.awaitMessageComponent({ filter, time: 10 * 1000 }),
page = Number(collected.values[0]);
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]],
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();
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);
});
@ -148,6 +113,38 @@ class Queue extends BaseCommand {
return interaction.editReply({
components: [row],
});
}
}
});
}
/**
*
* @param {import("../../base/Client")} client
* @param {import("discord.js").ChatInputCommandInteraction} interaction
*/
async execute(client, interaction) {
const queue = client.player.nodes.get(interaction.guildId);
if (!queue) return interaction.error("music/play:NOT_PLAYING");
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("❌"),
);
if (interaction.customId) return await interaction.followUp({
content: `${interaction.translate("common:PAGE")}: **1**/**${size}**`,
embeds: [embeds[0]],
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;

View file

@ -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")
.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"),
uk: client.translate("music/seek:TIME", null, "uk-UA"),
ru: client.translate("music/seek:TIME", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.setRequired(true),
),
dirname: __dirname,
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"),

View file

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

View file

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

View file

@ -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")
.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"),
uk: client.translate("music/skipto:POSITION", null, "uk-UA"),
ru: client.translate("music/skipto:POSITION", null, "ru-RU"),
})
.setRequired(true)),
aliases: [],
.setRequired(true),
),
dirname: __dirname,
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,9 +50,9 @@ 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 });
}
}

View file

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

View file

@ -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")
.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"),
uk: client.translate("common:INT", null, "uk-UA"),
ru: client.translate("common:INT", null, "ru-RU"),
})
.setRequired(true)
.setAutocomplete(true)),
aliases: [],
.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,12 +63,12 @@ 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,
}),
));
})),
);
}
}

View file

@ -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,85 +13,72 @@ 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,
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 row = new ActionRowBuilder()
.addComponents(
new StringSelectMenuBuilder()
.setCustomId("nsfw_select")
.setPlaceholder(client.translate("common:NOTHING_SELECTED"))
.addOptions(tags),
);
const msg = 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();
const row = new ActionRowBuilder().addComponents(new StringSelectMenuBuilder().setCustomId("nsfw_select").setPlaceholder(interaction.translate("common:NOTHING_SELECTED")).addOptions(tags.slice(0, 25)));
await interaction.editReply({
embeds: [embed],
});
}
});
collector.on("end", () => {
return interaction.editReply({
components: [],
});
content: interaction.translate("common:AVAILABLE_OPTIONS"),
ephemeral: true,
components: [row],
});
}
}

View file

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

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