@duque.edits/sdk 1.1.3 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{index-BPxglVSk.d.ts → index-0BFrnm6S.d.ts} +437 -193
- package/dist/index.d.ts +2 -1
- package/dist/index.js +10 -4225
- package/dist/index.js.map +1 -0
- package/dist/managers/automaticmessage/AutomaticMessageManager.d.ts +2 -1
- package/dist/managers/automaticmessage/AutomaticMessageManager.js +42 -739
- package/dist/managers/automaticmessage/AutomaticMessageManager.js.map +1 -0
- package/dist/managers/base.d.ts +2 -1
- package/dist/managers/base.js +8 -89
- package/dist/managers/base.js.map +1 -0
- package/dist/managers/bet/GuildBetManager.d.ts +2 -1
- package/dist/managers/bet/GuildBetManager.js +21 -901
- package/dist/managers/bet/GuildBetManager.js.map +1 -0
- package/dist/managers/betuser/GuildBetUserManager.d.ts +2 -1
- package/dist/managers/betuser/GuildBetUserManager.js +22 -444
- package/dist/managers/betuser/GuildBetUserManager.js.map +1 -0
- package/dist/managers/buffer/BufferManager.d.ts +2 -1
- package/dist/managers/buffer/BufferManager.js +8 -192
- package/dist/managers/buffer/BufferManager.js.map +1 -0
- package/dist/managers/guild/GuildManager.d.ts +2 -1
- package/dist/managers/guild/GuildManager.js +38 -3704
- package/dist/managers/guild/GuildManager.js.map +1 -0
- package/dist/managers/index.d.ts +2 -1
- package/dist/managers/index.js +40 -3937
- package/dist/managers/index.js.map +1 -0
- package/dist/managers/logs/LogManager.d.ts +2 -1
- package/dist/managers/logs/LogManager.js +16 -673
- package/dist/managers/logs/LogManager.js.map +1 -0
- package/dist/managers/match/GuildMatchManager.d.ts +2 -1
- package/dist/managers/match/GuildMatchManager.js +26 -1225
- package/dist/managers/match/GuildMatchManager.js.map +1 -0
- package/dist/managers/mediator/GuildMediatorManager.d.ts +2 -1
- package/dist/managers/mediator/GuildMediatorManager.js +23 -365
- package/dist/managers/mediator/GuildMediatorManager.js.map +1 -0
- package/dist/managers/message/MessagesManager.d.ts +2 -1
- package/dist/managers/message/MessagesManager.js +5 -88
- package/dist/managers/message/MessagesManager.js.map +1 -0
- package/dist/managers/minesgame/MinesGameManager.d.ts +2 -1
- package/dist/managers/minesgame/MinesGameManager.js +16 -655
- package/dist/managers/minesgame/MinesGameManager.js.map +1 -0
- package/dist/managers/permission/GuildPermissionManager.d.ts +2 -1
- package/dist/managers/permission/GuildPermissionManager.js +22 -212
- package/dist/managers/permission/GuildPermissionManager.js.map +1 -0
- package/dist/managers/player/PlayerManager.d.ts +2 -1
- package/dist/managers/player/PlayerManager.js +4 -87
- package/dist/managers/player/PlayerManager.js.map +1 -0
- package/dist/managers/product/ProductManager.d.ts +22 -0
- package/dist/managers/product/ProductManager.js +101 -0
- package/dist/managers/product/ProductManager.js.map +1 -0
- package/dist/managers/shop/ShopManager.d.ts +22 -0
- package/dist/managers/shop/ShopManager.js +99 -0
- package/dist/managers/shop/ShopManager.js.map +1 -0
- package/dist/managers/ticket/TicketManager.d.ts +2 -1
- package/dist/managers/ticket/TicketManager.js +25 -707
- package/dist/managers/ticket/TicketManager.js.map +1 -0
- package/dist/managers/ticketpanel/TicketPanelManager.d.ts +22 -0
- package/dist/managers/ticketpanel/TicketPanelManager.js +82 -0
- package/dist/managers/ticketpanel/TicketPanelManager.js.map +1 -0
- package/dist/managers/tournament/TournamentManager.d.ts +2 -1
- package/dist/managers/tournament/TournamentManager.js +33 -686
- package/dist/managers/tournament/TournamentManager.js.map +1 -0
- package/dist/managers/user/GuildUserManager.d.ts +2 -1
- package/dist/managers/user/GuildUserManager.js +24 -502
- package/dist/managers/user/GuildUserManager.js.map +1 -0
- package/dist/managers/vipmember/VipMemberManager.d.ts +2 -1
- package/dist/managers/vipmember/VipMemberManager.js +30 -425
- package/dist/managers/vipmember/VipMemberManager.js.map +1 -0
- package/dist/rest/APIEndpoints.js +4 -5
- package/dist/rest/APIEndpoints.js.map +1 -0
- package/dist/rest/REST.d.ts +2 -1
- package/dist/rest/REST.js +57 -3932
- package/dist/rest/REST.js.map +1 -0
- package/dist/rest/Routes.d.ts +79 -87
- package/dist/rest/Routes.js +8 -17
- package/dist/rest/Routes.js.map +1 -0
- package/dist/rest/index.d.ts +2 -1
- package/dist/rest/index.js +8 -4027
- package/dist/rest/index.js.map +1 -0
- package/dist/structures/Collection.js +6 -7
- package/dist/structures/Collection.js.map +1 -0
- package/dist/structures/automaticmessage/AutomaticMessage.d.ts +3 -2
- package/dist/structures/automaticmessage/AutomaticMessage.js +51 -531
- package/dist/structures/automaticmessage/AutomaticMessage.js.map +1 -0
- package/dist/structures/bet/GuildBet.d.ts +2 -1
- package/dist/structures/bet/GuildBet.js +21 -696
- package/dist/structures/bet/GuildBet.js.map +1 -0
- package/dist/structures/betuser/GuildBetUser.d.ts +2 -1
- package/dist/structures/betuser/GuildBetUser.js +32 -130
- package/dist/structures/betuser/GuildBetUser.js.map +1 -0
- package/dist/structures/guild/Guild.d.ts +5 -4
- package/dist/structures/guild/Guild.js +195 -3321
- package/dist/structures/guild/Guild.js.map +1 -0
- package/dist/structures/index.d.ts +2 -1
- package/dist/structures/index.js +34 -3772
- package/dist/structures/index.js.map +1 -0
- package/dist/structures/logentry/LogEntry.d.ts +2 -1
- package/dist/structures/logentry/LogEntry.js +24 -497
- package/dist/structures/logentry/LogEntry.js.map +1 -0
- package/dist/structures/match/GuildMatch.d.ts +2 -1
- package/dist/structures/match/GuildMatch.js +56 -950
- package/dist/structures/match/GuildMatch.js.map +1 -0
- package/dist/structures/mediator/GuildMediator.d.ts +2 -1
- package/dist/structures/mediator/GuildMediator.js +19 -123
- package/dist/structures/mediator/GuildMediator.js.map +1 -0
- package/dist/structures/minesgame/MinesGame.d.ts +2 -1
- package/dist/structures/minesgame/MinesGame.js +15 -496
- package/dist/structures/minesgame/MinesGame.js.map +1 -0
- package/dist/structures/product/Product.d.ts +22 -0
- package/dist/structures/product/Product.js +120 -0
- package/dist/structures/product/Product.js.map +1 -0
- package/dist/structures/shop/Shop.d.ts +22 -0
- package/dist/structures/shop/Shop.js +125 -0
- package/dist/structures/shop/Shop.js.map +1 -0
- package/dist/structures/ticket/Ticket.d.ts +3 -2
- package/dist/structures/ticket/Ticket.js +30 -517
- package/dist/structures/ticket/Ticket.js.map +1 -0
- package/dist/structures/ticketpanel/TicketPanel.d.ts +22 -0
- package/dist/structures/ticketpanel/TicketPanel.js +177 -0
- package/dist/structures/ticketpanel/TicketPanel.js.map +1 -0
- package/dist/structures/tournament/Tournament.d.ts +2 -1
- package/dist/structures/tournament/Tournament.js +14 -493
- package/dist/structures/tournament/Tournament.js.map +1 -0
- package/dist/structures/user/GuildUser.d.ts +2 -1
- package/dist/structures/user/GuildUser.js +148 -136
- package/dist/structures/user/GuildUser.js.map +1 -0
- package/dist/structures/vipmember/VipMember.d.ts +2 -1
- package/dist/structures/vipmember/VipMember.js +12 -116
- package/dist/structures/vipmember/VipMember.js.map +1 -0
- package/dist/types/RestTypes.d.ts +2 -1
- package/dist/types/RestTypes.js +1 -2
- package/dist/types/RestTypes.js.map +1 -0
- package/dist/types/api/APIAdvert.js +1 -2
- package/dist/types/api/APIAdvert.js.map +1 -0
- package/dist/types/api/APIAutomaticMessage.d.ts +2 -1
- package/dist/types/api/APIAutomaticMessage.js +1 -2
- package/dist/types/api/APIAutomaticMessage.js.map +1 -0
- package/dist/types/api/APIBaseChannel.js +1 -2
- package/dist/types/api/APIBaseChannel.js.map +1 -0
- package/dist/types/api/APIBetChannel.js +1 -2
- package/dist/types/api/APIBetChannel.js.map +1 -0
- package/dist/types/api/APICode.js +1 -2
- package/dist/types/api/APICode.js.map +1 -0
- package/dist/types/api/APIGiveaway.js +1 -2
- package/dist/types/api/APIGiveaway.js.map +1 -0
- package/dist/types/api/APIGuild.d.ts +5 -4
- package/dist/types/api/APIGuild.js +2 -2
- package/dist/types/api/APIGuild.js.map +1 -0
- package/dist/types/api/APIGuildAdvert.js +1 -2
- package/dist/types/api/APIGuildAdvert.js.map +1 -0
- package/dist/types/api/APIGuildBet.d.ts +2 -1
- package/dist/types/api/APIGuildBet.js +1 -2
- package/dist/types/api/APIGuildBet.js.map +1 -0
- package/dist/types/api/APIGuildBetUser.d.ts +2 -1
- package/dist/types/api/APIGuildBetUser.js +1 -2
- package/dist/types/api/APIGuildBetUser.js.map +1 -0
- package/dist/types/api/APIGuildChannel.js +1 -2
- package/dist/types/api/APIGuildChannel.js.map +1 -0
- package/dist/types/api/APIGuildGroupedChannel.d.ts +2 -1
- package/dist/types/api/APIGuildGroupedChannel.js +1 -2
- package/dist/types/api/APIGuildGroupedChannel.js.map +1 -0
- package/dist/types/api/APIGuildMatch.d.ts +2 -1
- package/dist/types/api/APIGuildMatch.js +1 -2
- package/dist/types/api/APIGuildMatch.js.map +1 -0
- package/dist/types/api/APIGuildMediator.js +1 -2
- package/dist/types/api/APIGuildMediator.js.map +1 -0
- package/dist/types/api/APIGuildPermissions.d.ts +18 -2
- package/dist/types/api/APIGuildPermissions.js +18 -3
- package/dist/types/api/APIGuildPermissions.js.map +1 -0
- package/dist/types/api/APIGuildShop.d.ts +6 -1
- package/dist/types/api/APIGuildShop.js +1 -2
- package/dist/types/api/APIGuildShop.js.map +1 -0
- package/dist/types/api/APIGuildTicket.js +1 -2
- package/dist/types/api/APIGuildTicket.js.map +1 -0
- package/dist/types/api/APIGuildUser.d.ts +2 -1
- package/dist/types/api/APIGuildUser.js +1 -2
- package/dist/types/api/APIGuildUser.js.map +1 -0
- package/dist/types/api/APILogEntry.d.ts +4 -2
- package/dist/types/api/APILogEntry.js +4 -3
- package/dist/types/api/APILogEntry.js.map +1 -0
- package/dist/types/api/APIMessage.d.ts +2 -0
- package/dist/types/api/APIMessage.js +1 -2
- package/dist/types/api/APIMessage.js.map +1 -0
- package/dist/types/api/APIMinesGame.js +1 -2
- package/dist/types/api/APIMinesGame.js.map +1 -0
- package/dist/types/api/APIPlayer.js +1 -2
- package/dist/types/api/APIPlayer.js.map +1 -0
- package/dist/types/api/APIProduct.d.ts +1 -1
- package/dist/types/api/APIProduct.js +2 -2
- package/dist/types/api/APIProduct.js.map +1 -0
- package/dist/types/api/APITicketPanel.d.ts +22 -0
- package/dist/types/api/APITicketPanel.js +17 -0
- package/dist/types/api/APITicketPanel.js.map +1 -0
- package/dist/types/api/APITournament.d.ts +6 -1
- package/dist/types/api/APITournament.js +1 -2
- package/dist/types/api/APITournament.js.map +1 -0
- package/dist/types/api/APIVipMember.js +1 -2
- package/dist/types/api/APIVipMember.js.map +1 -0
- package/dist/types/api/index.d.ts +2 -1
- package/dist/types/api/index.js +63 -110
- package/dist/types/api/index.js.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js +6 -154
- package/dist/types/index.js.map +1 -0
- package/dist/utils/Assertion.js +3 -4
- package/dist/utils/Assertion.js.map +1 -0
- package/dist/utils/getRandomNumber.js +1 -2
- package/dist/utils/getRandomNumber.js.map +1 -0
- package/dist/utils/isSameDayUTC.d.ts +3 -0
- package/dist/utils/isSameDayUTC.js +34 -0
- package/dist/utils/isSameDayUTC.js.map +1 -0
- package/dist/utils/randomKeyGenerator.js +1 -2
- package/dist/utils/randomKeyGenerator.js.map +1 -0
- package/package.json +4 -5
- package/dist/index-DjHimKUy.d.mts +0 -1431
- package/dist/index.d.mts +0 -23
- package/dist/index.mjs +0 -4196
- package/dist/managers/automaticmessage/AutomaticMessageManager.d.mts +0 -21
- package/dist/managers/automaticmessage/AutomaticMessageManager.mjs +0 -796
- package/dist/managers/base.d.mts +0 -21
- package/dist/managers/base.mjs +0 -107
- package/dist/managers/bet/GuildBetManager.d.mts +0 -21
- package/dist/managers/bet/GuildBetManager.mjs +0 -958
- package/dist/managers/betuser/GuildBetUserManager.d.mts +0 -21
- package/dist/managers/betuser/GuildBetUserManager.mjs +0 -502
- package/dist/managers/buffer/BufferManager.d.mts +0 -21
- package/dist/managers/buffer/BufferManager.mjs +0 -223
- package/dist/managers/guild/GuildManager.d.mts +0 -21
- package/dist/managers/guild/GuildManager.mjs +0 -3786
- package/dist/managers/index.d.mts +0 -21
- package/dist/managers/index.mjs +0 -3934
- package/dist/managers/logs/LogManager.d.mts +0 -21
- package/dist/managers/logs/LogManager.mjs +0 -738
- package/dist/managers/match/GuildMatchManager.d.mts +0 -21
- package/dist/managers/match/GuildMatchManager.mjs +0 -1305
- package/dist/managers/mediator/GuildMediatorManager.d.mts +0 -21
- package/dist/managers/mediator/GuildMediatorManager.mjs +0 -430
- package/dist/managers/message/MessagesManager.d.mts +0 -21
- package/dist/managers/message/MessagesManager.mjs +0 -134
- package/dist/managers/minesgame/MinesGameManager.d.mts +0 -21
- package/dist/managers/minesgame/MinesGameManager.mjs +0 -721
- package/dist/managers/permission/GuildPermissionManager.d.mts +0 -21
- package/dist/managers/permission/GuildPermissionManager.mjs +0 -256
- package/dist/managers/player/PlayerManager.d.mts +0 -21
- package/dist/managers/player/PlayerManager.mjs +0 -155
- package/dist/managers/ticket/TicketManager.d.mts +0 -21
- package/dist/managers/ticket/TicketManager.mjs +0 -827
- package/dist/managers/tournament/TournamentManager.d.mts +0 -21
- package/dist/managers/tournament/TournamentManager.mjs +0 -745
- package/dist/managers/user/GuildUserManager.d.mts +0 -21
- package/dist/managers/user/GuildUserManager.mjs +0 -567
- package/dist/managers/vipmember/VipMemberManager.d.mts +0 -21
- package/dist/managers/vipmember/VipMemberManager.mjs +0 -513
- package/dist/rest/APIEndpoints.d.mts +0 -12
- package/dist/rest/APIEndpoints.mjs +0 -19
- package/dist/rest/REST.d.mts +0 -21
- package/dist/rest/REST.mjs +0 -4021
- package/dist/rest/Routes.d.mts +0 -104
- package/dist/rest/Routes.mjs +0 -104
- package/dist/rest/index.d.mts +0 -23
- package/dist/rest/index.mjs +0 -4036
- package/dist/structures/Collection.d.mts +0 -19
- package/dist/structures/Collection.mjs +0 -87
- package/dist/structures/automaticmessage/AutomaticMessage.d.mts +0 -21
- package/dist/structures/automaticmessage/AutomaticMessage.mjs +0 -609
- package/dist/structures/bet/GuildBet.d.mts +0 -21
- package/dist/structures/bet/GuildBet.mjs +0 -881
- package/dist/structures/betuser/GuildBetUser.d.mts +0 -21
- package/dist/structures/betuser/GuildBetUser.mjs +0 -326
- package/dist/structures/guild/Guild.d.mts +0 -21
- package/dist/structures/guild/Guild.mjs +0 -3690
- package/dist/structures/index.d.mts +0 -21
- package/dist/structures/index.mjs +0 -3773
- package/dist/structures/logentry/LogEntry.d.mts +0 -21
- package/dist/structures/logentry/LogEntry.mjs +0 -575
- package/dist/structures/match/GuildMatch.d.mts +0 -21
- package/dist/structures/match/GuildMatch.mjs +0 -1191
- package/dist/structures/mediator/GuildMediator.d.mts +0 -21
- package/dist/structures/mediator/GuildMediator.mjs +0 -246
- package/dist/structures/minesgame/MinesGame.d.mts +0 -21
- package/dist/structures/minesgame/MinesGame.mjs +0 -579
- package/dist/structures/ticket/Ticket.d.mts +0 -21
- package/dist/structures/ticket/Ticket.mjs +0 -626
- package/dist/structures/tournament/Tournament.d.mts +0 -21
- package/dist/structures/tournament/Tournament.mjs +0 -585
- package/dist/structures/user/GuildUser.d.mts +0 -21
- package/dist/structures/user/GuildUser.mjs +0 -382
- package/dist/structures/vipmember/VipMember.d.mts +0 -21
- package/dist/structures/vipmember/VipMember.mjs +0 -250
- package/dist/types/RestTypes.d.mts +0 -21
- package/dist/types/RestTypes.mjs +0 -0
- package/dist/types/api/APIAdvert.d.mts +0 -13
- package/dist/types/api/APIAdvert.mjs +0 -0
- package/dist/types/api/APIAutomaticMessage.d.mts +0 -21
- package/dist/types/api/APIAutomaticMessage.mjs +0 -0
- package/dist/types/api/APIBaseChannel.d.mts +0 -12
- package/dist/types/api/APIBaseChannel.mjs +0 -0
- package/dist/types/api/APIBetChannel.d.mts +0 -12
- package/dist/types/api/APIBetChannel.mjs +0 -0
- package/dist/types/api/APICode.d.mts +0 -12
- package/dist/types/api/APICode.mjs +0 -0
- package/dist/types/api/APIGiveaway.d.mts +0 -29
- package/dist/types/api/APIGiveaway.mjs +0 -0
- package/dist/types/api/APIGuild.d.mts +0 -21
- package/dist/types/api/APIGuild.mjs +0 -46
- package/dist/types/api/APIGuildAdvert.d.mts +0 -10
- package/dist/types/api/APIGuildAdvert.mjs +0 -0
- package/dist/types/api/APIGuildBet.d.mts +0 -21
- package/dist/types/api/APIGuildBet.mjs +0 -8
- package/dist/types/api/APIGuildBetUser.d.mts +0 -21
- package/dist/types/api/APIGuildBetUser.mjs +0 -0
- package/dist/types/api/APIGuildChannel.d.mts +0 -12
- package/dist/types/api/APIGuildChannel.mjs +0 -0
- package/dist/types/api/APIGuildGroupedChannel.d.mts +0 -21
- package/dist/types/api/APIGuildGroupedChannel.mjs +0 -0
- package/dist/types/api/APIGuildMatch.d.mts +0 -21
- package/dist/types/api/APIGuildMatch.mjs +0 -14
- package/dist/types/api/APIGuildMediator.d.mts +0 -16
- package/dist/types/api/APIGuildMediator.mjs +0 -0
- package/dist/types/api/APIGuildPermissions.d.mts +0 -15
- package/dist/types/api/APIGuildPermissions.mjs +0 -13
- package/dist/types/api/APIGuildShop.d.mts +0 -15
- package/dist/types/api/APIGuildShop.mjs +0 -0
- package/dist/types/api/APIGuildTicket.d.mts +0 -19
- package/dist/types/api/APIGuildTicket.mjs +0 -0
- package/dist/types/api/APIGuildUser.d.mts +0 -21
- package/dist/types/api/APIGuildUser.mjs +0 -0
- package/dist/types/api/APILogEntry.d.mts +0 -32
- package/dist/types/api/APILogEntry.mjs +0 -20
- package/dist/types/api/APIMessage.d.mts +0 -13
- package/dist/types/api/APIMessage.mjs +0 -0
- package/dist/types/api/APIMinesGame.d.mts +0 -15
- package/dist/types/api/APIMinesGame.mjs +0 -0
- package/dist/types/api/APIPlayer.d.mts +0 -10
- package/dist/types/api/APIPlayer.mjs +0 -0
- package/dist/types/api/APIProduct.d.mts +0 -22
- package/dist/types/api/APIProduct.mjs +0 -0
- package/dist/types/api/APITournament.d.mts +0 -16
- package/dist/types/api/APITournament.mjs +0 -0
- package/dist/types/api/APIVipMember.d.mts +0 -22
- package/dist/types/api/APIVipMember.mjs +0 -0
- package/dist/types/api/index.d.mts +0 -21
- package/dist/types/api/index.mjs +0 -135
- package/dist/types/index.d.mts +0 -21
- package/dist/types/index.mjs +0 -135
- package/dist/utils/Assertion.d.mts +0 -34
- package/dist/utils/Assertion.mjs +0 -52
- package/dist/utils/getRandomNumber.d.mts +0 -3
- package/dist/utils/getRandomNumber.mjs +0 -7
- package/dist/utils/randomKeyGenerator.d.mts +0 -3
- package/dist/utils/randomKeyGenerator.mjs +0 -8
package/dist/index.js
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __typeError = (msg) => {
|
|
9
|
-
throw TypeError(msg);
|
|
10
|
-
};
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
13
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
14
|
-
};
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
6
|
var __copyProps = (to, from, except, desc) => {
|
|
20
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -24,4221 +11,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
24
11
|
}
|
|
25
12
|
return to;
|
|
26
13
|
};
|
|
27
|
-
var
|
|
28
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
33
|
-
mod
|
|
34
|
-
));
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
35
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
37
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
38
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
39
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
40
|
-
|
|
41
|
-
// node_modules/dotenv/package.json
|
|
42
|
-
var require_package = __commonJS({
|
|
43
|
-
"node_modules/dotenv/package.json"(exports2, module2) {
|
|
44
|
-
module2.exports = {
|
|
45
|
-
name: "dotenv",
|
|
46
|
-
version: "16.6.1",
|
|
47
|
-
description: "Loads environment variables from .env file",
|
|
48
|
-
main: "lib/main.js",
|
|
49
|
-
types: "lib/main.d.ts",
|
|
50
|
-
exports: {
|
|
51
|
-
".": {
|
|
52
|
-
types: "./lib/main.d.ts",
|
|
53
|
-
require: "./lib/main.js",
|
|
54
|
-
default: "./lib/main.js"
|
|
55
|
-
},
|
|
56
|
-
"./config": "./config.js",
|
|
57
|
-
"./config.js": "./config.js",
|
|
58
|
-
"./lib/env-options": "./lib/env-options.js",
|
|
59
|
-
"./lib/env-options.js": "./lib/env-options.js",
|
|
60
|
-
"./lib/cli-options": "./lib/cli-options.js",
|
|
61
|
-
"./lib/cli-options.js": "./lib/cli-options.js",
|
|
62
|
-
"./package.json": "./package.json"
|
|
63
|
-
},
|
|
64
|
-
scripts: {
|
|
65
|
-
"dts-check": "tsc --project tests/types/tsconfig.json",
|
|
66
|
-
lint: "standard",
|
|
67
|
-
pretest: "npm run lint && npm run dts-check",
|
|
68
|
-
test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
69
|
-
"test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=text --coverage-report=lcov",
|
|
70
|
-
prerelease: "npm test",
|
|
71
|
-
release: "standard-version"
|
|
72
|
-
},
|
|
73
|
-
repository: {
|
|
74
|
-
type: "git",
|
|
75
|
-
url: "git://github.com/motdotla/dotenv.git"
|
|
76
|
-
},
|
|
77
|
-
homepage: "https://github.com/motdotla/dotenv#readme",
|
|
78
|
-
funding: "https://dotenvx.com",
|
|
79
|
-
keywords: [
|
|
80
|
-
"dotenv",
|
|
81
|
-
"env",
|
|
82
|
-
".env",
|
|
83
|
-
"environment",
|
|
84
|
-
"variables",
|
|
85
|
-
"config",
|
|
86
|
-
"settings"
|
|
87
|
-
],
|
|
88
|
-
readmeFilename: "README.md",
|
|
89
|
-
license: "BSD-2-Clause",
|
|
90
|
-
devDependencies: {
|
|
91
|
-
"@types/node": "^18.11.3",
|
|
92
|
-
decache: "^4.6.2",
|
|
93
|
-
sinon: "^14.0.1",
|
|
94
|
-
standard: "^17.0.0",
|
|
95
|
-
"standard-version": "^9.5.0",
|
|
96
|
-
tap: "^19.2.0",
|
|
97
|
-
typescript: "^4.8.4"
|
|
98
|
-
},
|
|
99
|
-
engines: {
|
|
100
|
-
node: ">=12"
|
|
101
|
-
},
|
|
102
|
-
browser: {
|
|
103
|
-
fs: false
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// node_modules/dotenv/lib/main.js
|
|
110
|
-
var require_main = __commonJS({
|
|
111
|
-
"node_modules/dotenv/lib/main.js"(exports2, module2) {
|
|
112
|
-
"use strict";
|
|
113
|
-
var fs = require("fs");
|
|
114
|
-
var path = require("path");
|
|
115
|
-
var os = require("os");
|
|
116
|
-
var crypto = require("crypto");
|
|
117
|
-
var packageJson = require_package();
|
|
118
|
-
var version = packageJson.version;
|
|
119
|
-
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
|
120
|
-
function parse(src) {
|
|
121
|
-
const obj = {};
|
|
122
|
-
let lines = src.toString();
|
|
123
|
-
lines = lines.replace(/\r\n?/mg, "\n");
|
|
124
|
-
let match;
|
|
125
|
-
while ((match = LINE.exec(lines)) != null) {
|
|
126
|
-
const key = match[1];
|
|
127
|
-
let value = match[2] || "";
|
|
128
|
-
value = value.trim();
|
|
129
|
-
const maybeQuote = value[0];
|
|
130
|
-
value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
|
|
131
|
-
if (maybeQuote === '"') {
|
|
132
|
-
value = value.replace(/\\n/g, "\n");
|
|
133
|
-
value = value.replace(/\\r/g, "\r");
|
|
134
|
-
}
|
|
135
|
-
obj[key] = value;
|
|
136
|
-
}
|
|
137
|
-
return obj;
|
|
138
|
-
}
|
|
139
|
-
function _parseVault(options) {
|
|
140
|
-
options = options || {};
|
|
141
|
-
const vaultPath = _vaultPath(options);
|
|
142
|
-
options.path = vaultPath;
|
|
143
|
-
const result = DotenvModule.configDotenv(options);
|
|
144
|
-
if (!result.parsed) {
|
|
145
|
-
const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
|
|
146
|
-
err.code = "MISSING_DATA";
|
|
147
|
-
throw err;
|
|
148
|
-
}
|
|
149
|
-
const keys = _dotenvKey(options).split(",");
|
|
150
|
-
const length = keys.length;
|
|
151
|
-
let decrypted;
|
|
152
|
-
for (let i = 0; i < length; i++) {
|
|
153
|
-
try {
|
|
154
|
-
const key = keys[i].trim();
|
|
155
|
-
const attrs = _instructions(result, key);
|
|
156
|
-
decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
|
|
157
|
-
break;
|
|
158
|
-
} catch (error) {
|
|
159
|
-
if (i + 1 >= length) {
|
|
160
|
-
throw error;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return DotenvModule.parse(decrypted);
|
|
165
|
-
}
|
|
166
|
-
function _warn(message) {
|
|
167
|
-
console.log(`[dotenv@${version}][WARN] ${message}`);
|
|
168
|
-
}
|
|
169
|
-
function _debug(message) {
|
|
170
|
-
console.log(`[dotenv@${version}][DEBUG] ${message}`);
|
|
171
|
-
}
|
|
172
|
-
function _log(message) {
|
|
173
|
-
console.log(`[dotenv@${version}] ${message}`);
|
|
174
|
-
}
|
|
175
|
-
function _dotenvKey(options) {
|
|
176
|
-
if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
|
|
177
|
-
return options.DOTENV_KEY;
|
|
178
|
-
}
|
|
179
|
-
if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
|
|
180
|
-
return process.env.DOTENV_KEY;
|
|
181
|
-
}
|
|
182
|
-
return "";
|
|
183
|
-
}
|
|
184
|
-
function _instructions(result, dotenvKey) {
|
|
185
|
-
let uri;
|
|
186
|
-
try {
|
|
187
|
-
uri = new URL(dotenvKey);
|
|
188
|
-
} catch (error) {
|
|
189
|
-
if (error.code === "ERR_INVALID_URL") {
|
|
190
|
-
const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
|
|
191
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
192
|
-
throw err;
|
|
193
|
-
}
|
|
194
|
-
throw error;
|
|
195
|
-
}
|
|
196
|
-
const key = uri.password;
|
|
197
|
-
if (!key) {
|
|
198
|
-
const err = new Error("INVALID_DOTENV_KEY: Missing key part");
|
|
199
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
200
|
-
throw err;
|
|
201
|
-
}
|
|
202
|
-
const environment = uri.searchParams.get("environment");
|
|
203
|
-
if (!environment) {
|
|
204
|
-
const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
|
|
205
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
206
|
-
throw err;
|
|
207
|
-
}
|
|
208
|
-
const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
|
|
209
|
-
const ciphertext = result.parsed[environmentKey];
|
|
210
|
-
if (!ciphertext) {
|
|
211
|
-
const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
|
|
212
|
-
err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
|
|
213
|
-
throw err;
|
|
214
|
-
}
|
|
215
|
-
return { ciphertext, key };
|
|
216
|
-
}
|
|
217
|
-
function _vaultPath(options) {
|
|
218
|
-
let possibleVaultPath = null;
|
|
219
|
-
if (options && options.path && options.path.length > 0) {
|
|
220
|
-
if (Array.isArray(options.path)) {
|
|
221
|
-
for (const filepath of options.path) {
|
|
222
|
-
if (fs.existsSync(filepath)) {
|
|
223
|
-
possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
} else {
|
|
227
|
-
possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
|
|
228
|
-
}
|
|
229
|
-
} else {
|
|
230
|
-
possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
|
|
231
|
-
}
|
|
232
|
-
if (fs.existsSync(possibleVaultPath)) {
|
|
233
|
-
return possibleVaultPath;
|
|
234
|
-
}
|
|
235
|
-
return null;
|
|
236
|
-
}
|
|
237
|
-
function _resolveHome(envPath) {
|
|
238
|
-
return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
|
|
239
|
-
}
|
|
240
|
-
function _configVault(options) {
|
|
241
|
-
const debug = Boolean(options && options.debug);
|
|
242
|
-
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
243
|
-
if (debug || !quiet) {
|
|
244
|
-
_log("Loading env from encrypted .env.vault");
|
|
245
|
-
}
|
|
246
|
-
const parsed = DotenvModule._parseVault(options);
|
|
247
|
-
let processEnv = process.env;
|
|
248
|
-
if (options && options.processEnv != null) {
|
|
249
|
-
processEnv = options.processEnv;
|
|
250
|
-
}
|
|
251
|
-
DotenvModule.populate(processEnv, parsed, options);
|
|
252
|
-
return { parsed };
|
|
253
|
-
}
|
|
254
|
-
function configDotenv(options) {
|
|
255
|
-
const dotenvPath = path.resolve(process.cwd(), ".env");
|
|
256
|
-
let encoding = "utf8";
|
|
257
|
-
const debug = Boolean(options && options.debug);
|
|
258
|
-
const quiet = options && "quiet" in options ? options.quiet : true;
|
|
259
|
-
if (options && options.encoding) {
|
|
260
|
-
encoding = options.encoding;
|
|
261
|
-
} else {
|
|
262
|
-
if (debug) {
|
|
263
|
-
_debug("No encoding is specified. UTF-8 is used by default");
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
let optionPaths = [dotenvPath];
|
|
267
|
-
if (options && options.path) {
|
|
268
|
-
if (!Array.isArray(options.path)) {
|
|
269
|
-
optionPaths = [_resolveHome(options.path)];
|
|
270
|
-
} else {
|
|
271
|
-
optionPaths = [];
|
|
272
|
-
for (const filepath of options.path) {
|
|
273
|
-
optionPaths.push(_resolveHome(filepath));
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
let lastError;
|
|
278
|
-
const parsedAll = {};
|
|
279
|
-
for (const path2 of optionPaths) {
|
|
280
|
-
try {
|
|
281
|
-
const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
|
|
282
|
-
DotenvModule.populate(parsedAll, parsed, options);
|
|
283
|
-
} catch (e) {
|
|
284
|
-
if (debug) {
|
|
285
|
-
_debug(`Failed to load ${path2} ${e.message}`);
|
|
286
|
-
}
|
|
287
|
-
lastError = e;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
let processEnv = process.env;
|
|
291
|
-
if (options && options.processEnv != null) {
|
|
292
|
-
processEnv = options.processEnv;
|
|
293
|
-
}
|
|
294
|
-
DotenvModule.populate(processEnv, parsedAll, options);
|
|
295
|
-
if (debug || !quiet) {
|
|
296
|
-
const keysCount = Object.keys(parsedAll).length;
|
|
297
|
-
const shortPaths = [];
|
|
298
|
-
for (const filePath of optionPaths) {
|
|
299
|
-
try {
|
|
300
|
-
const relative = path.relative(process.cwd(), filePath);
|
|
301
|
-
shortPaths.push(relative);
|
|
302
|
-
} catch (e) {
|
|
303
|
-
if (debug) {
|
|
304
|
-
_debug(`Failed to load ${filePath} ${e.message}`);
|
|
305
|
-
}
|
|
306
|
-
lastError = e;
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
_log(`injecting env (${keysCount}) from ${shortPaths.join(",")}`);
|
|
310
|
-
}
|
|
311
|
-
if (lastError) {
|
|
312
|
-
return { parsed: parsedAll, error: lastError };
|
|
313
|
-
} else {
|
|
314
|
-
return { parsed: parsedAll };
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
function config(options) {
|
|
318
|
-
if (_dotenvKey(options).length === 0) {
|
|
319
|
-
return DotenvModule.configDotenv(options);
|
|
320
|
-
}
|
|
321
|
-
const vaultPath = _vaultPath(options);
|
|
322
|
-
if (!vaultPath) {
|
|
323
|
-
_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
|
|
324
|
-
return DotenvModule.configDotenv(options);
|
|
325
|
-
}
|
|
326
|
-
return DotenvModule._configVault(options);
|
|
327
|
-
}
|
|
328
|
-
function decrypt(encrypted, keyStr) {
|
|
329
|
-
const key = Buffer.from(keyStr.slice(-64), "hex");
|
|
330
|
-
let ciphertext = Buffer.from(encrypted, "base64");
|
|
331
|
-
const nonce = ciphertext.subarray(0, 12);
|
|
332
|
-
const authTag = ciphertext.subarray(-16);
|
|
333
|
-
ciphertext = ciphertext.subarray(12, -16);
|
|
334
|
-
try {
|
|
335
|
-
const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
|
|
336
|
-
aesgcm.setAuthTag(authTag);
|
|
337
|
-
return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
|
|
338
|
-
} catch (error) {
|
|
339
|
-
const isRange = error instanceof RangeError;
|
|
340
|
-
const invalidKeyLength = error.message === "Invalid key length";
|
|
341
|
-
const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
|
|
342
|
-
if (isRange || invalidKeyLength) {
|
|
343
|
-
const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
|
|
344
|
-
err.code = "INVALID_DOTENV_KEY";
|
|
345
|
-
throw err;
|
|
346
|
-
} else if (decryptionFailed) {
|
|
347
|
-
const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
|
|
348
|
-
err.code = "DECRYPTION_FAILED";
|
|
349
|
-
throw err;
|
|
350
|
-
} else {
|
|
351
|
-
throw error;
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
function populate(processEnv, parsed, options = {}) {
|
|
356
|
-
const debug = Boolean(options && options.debug);
|
|
357
|
-
const override = Boolean(options && options.override);
|
|
358
|
-
if (typeof parsed !== "object") {
|
|
359
|
-
const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
|
|
360
|
-
err.code = "OBJECT_REQUIRED";
|
|
361
|
-
throw err;
|
|
362
|
-
}
|
|
363
|
-
for (const key of Object.keys(parsed)) {
|
|
364
|
-
if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
|
|
365
|
-
if (override === true) {
|
|
366
|
-
processEnv[key] = parsed[key];
|
|
367
|
-
}
|
|
368
|
-
if (debug) {
|
|
369
|
-
if (override === true) {
|
|
370
|
-
_debug(`"${key}" is already defined and WAS overwritten`);
|
|
371
|
-
} else {
|
|
372
|
-
_debug(`"${key}" is already defined and was NOT overwritten`);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
} else {
|
|
376
|
-
processEnv[key] = parsed[key];
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
var DotenvModule = {
|
|
381
|
-
configDotenv,
|
|
382
|
-
_configVault,
|
|
383
|
-
_parseVault,
|
|
384
|
-
config,
|
|
385
|
-
decrypt,
|
|
386
|
-
parse,
|
|
387
|
-
populate
|
|
388
|
-
};
|
|
389
|
-
module2.exports.configDotenv = DotenvModule.configDotenv;
|
|
390
|
-
module2.exports._configVault = DotenvModule._configVault;
|
|
391
|
-
module2.exports._parseVault = DotenvModule._parseVault;
|
|
392
|
-
module2.exports.config = DotenvModule.config;
|
|
393
|
-
module2.exports.decrypt = DotenvModule.decrypt;
|
|
394
|
-
module2.exports.parse = DotenvModule.parse;
|
|
395
|
-
module2.exports.populate = DotenvModule.populate;
|
|
396
|
-
module2.exports = DotenvModule;
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
// src/index.ts
|
|
401
16
|
var index_exports = {};
|
|
402
|
-
__export(index_exports, {
|
|
403
|
-
APIEndpoints: () => APIEndpoints,
|
|
404
|
-
AutomaticMessageManager: () => AutomaticMessageManager,
|
|
405
|
-
AutomaticMessagesTypes: () => AutomaticMessagesTypes,
|
|
406
|
-
BETSTATUS: () => BETSTATUS,
|
|
407
|
-
BaseManager: () => BaseManager,
|
|
408
|
-
BetChannelTypes: () => BetChannelTypes,
|
|
409
|
-
BufferManager: () => BufferManager,
|
|
410
|
-
Collection: () => Collection,
|
|
411
|
-
Guild: () => Guild3,
|
|
412
|
-
GuildBet: () => GuildBet,
|
|
413
|
-
GuildBetManager: () => GuildBetManager,
|
|
414
|
-
GuildBetUser: () => GuildBetUser,
|
|
415
|
-
GuildBetUserManager: () => GuildBetUserManager,
|
|
416
|
-
GuildChannelsType: () => GuildChannelsType,
|
|
417
|
-
GuildManager: () => GuildManager,
|
|
418
|
-
GuildMatch: () => GuildMatch,
|
|
419
|
-
GuildMatchChannelsType: () => GuildMatchChannelsType,
|
|
420
|
-
GuildMatchManager: () => GuildMatchManager,
|
|
421
|
-
GuildMatchMessagesType: () => GuildMatchMessagesType,
|
|
422
|
-
GuildMediator: () => GuildMediator,
|
|
423
|
-
GuildMediatorManager: () => GuildMediatorManager,
|
|
424
|
-
GuildPermissionManager: () => GuildPermissionManager,
|
|
425
|
-
GuildPermissionsTypes: () => GuildPermissionsTypes,
|
|
426
|
-
GuildStatusEnum: () => GuildStatusEnum,
|
|
427
|
-
GuildTicket: () => GuildTicket,
|
|
428
|
-
GuildTicketManager: () => GuildTicketManager,
|
|
429
|
-
GuildUser: () => GuildUser,
|
|
430
|
-
GuildUserManager: () => GuildUserManager,
|
|
431
|
-
LogEntry: () => LogEntry,
|
|
432
|
-
LogEntryTypes: () => LogEntryTypes,
|
|
433
|
-
LogManager: () => LogManager,
|
|
434
|
-
MATCHSTATUS: () => MATCHSTATUS,
|
|
435
|
-
MATCHTYPES: () => MATCHTYPES,
|
|
436
|
-
MessagesManager: () => MessagesManager,
|
|
437
|
-
MinesGame: () => MinesGame,
|
|
438
|
-
MinesGameManager: () => MinesGameManager,
|
|
439
|
-
REST: () => REST2,
|
|
440
|
-
Routes: () => Routes,
|
|
441
|
-
STATES: () => STATES,
|
|
442
|
-
VipMember: () => VipMember,
|
|
443
|
-
VipMemberManager: () => VipMemberManager
|
|
444
|
-
});
|
|
445
17
|
module.exports = __toCommonJS(index_exports);
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
super();
|
|
451
|
-
__publicField(this, "key");
|
|
452
|
-
this.key = key;
|
|
453
|
-
if (data && Array.isArray(data) && key) {
|
|
454
|
-
if (data.length > 0) return;
|
|
455
|
-
for (let v of data) this.set(key, v);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
at(index) {
|
|
459
|
-
if (index < 0 || index >= this.size) {
|
|
460
|
-
return void 0;
|
|
461
|
-
}
|
|
462
|
-
let i = 0;
|
|
463
|
-
for (let [, value] of this) {
|
|
464
|
-
if (i === index) {
|
|
465
|
-
return value;
|
|
466
|
-
}
|
|
467
|
-
i++;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
has(key) {
|
|
471
|
-
return this.get(key) !== void 0 ? true : false;
|
|
472
|
-
}
|
|
473
|
-
get first() {
|
|
474
|
-
return this.values().next().value;
|
|
475
|
-
}
|
|
476
|
-
get last() {
|
|
477
|
-
return [...this.values()].at(-1);
|
|
478
|
-
}
|
|
479
|
-
get length() {
|
|
480
|
-
return this.toArray().length;
|
|
481
|
-
}
|
|
482
|
-
find(predicate) {
|
|
483
|
-
for (const [key, value] of this) {
|
|
484
|
-
if (predicate(value, key, this)) return value;
|
|
485
|
-
}
|
|
486
|
-
return void 0;
|
|
487
|
-
}
|
|
488
|
-
filter(predicate) {
|
|
489
|
-
const results = new _Collection(this.key, []);
|
|
490
|
-
for (const [key, value] of this) {
|
|
491
|
-
if (predicate(value, key, this)) results.set(key, value);
|
|
492
|
-
}
|
|
493
|
-
return results;
|
|
494
|
-
}
|
|
495
|
-
some(predicate) {
|
|
496
|
-
const results = new _Collection(this.key, []);
|
|
497
|
-
for (const [key, value] of this) {
|
|
498
|
-
if (predicate(value, key, this)) results.set(key, value);
|
|
499
|
-
}
|
|
500
|
-
return results;
|
|
501
|
-
}
|
|
502
|
-
map(callback) {
|
|
503
|
-
return [...this].map(([key, val]) => callback(val, key, this));
|
|
504
|
-
}
|
|
505
|
-
toArray() {
|
|
506
|
-
return [...this.values()];
|
|
507
|
-
}
|
|
508
|
-
toJSON() {
|
|
509
|
-
let obj = {};
|
|
510
|
-
for (let [k, v] of this.entries()) {
|
|
511
|
-
obj[`${k}`] = v;
|
|
512
|
-
}
|
|
513
|
-
return obj;
|
|
514
|
-
}
|
|
515
|
-
sort(compareFunction) {
|
|
516
|
-
const sortedEntries = [...this.entries()].sort((ab, ba) => {
|
|
517
|
-
return compareFunction(ab[1], ba[1], this);
|
|
518
|
-
});
|
|
519
|
-
const coll = new _Collection();
|
|
520
|
-
for (let [k, v] of sortedEntries) coll.set(k, v);
|
|
521
|
-
return coll;
|
|
522
|
-
}
|
|
523
|
-
toString() {
|
|
524
|
-
return `${this.size}`;
|
|
525
|
-
}
|
|
526
|
-
};
|
|
527
|
-
|
|
528
|
-
// src/managers/base.ts
|
|
529
|
-
var BaseManager = class {
|
|
530
|
-
constructor(guild) {
|
|
531
|
-
/** This url of the manager */
|
|
532
|
-
__publicField(this, "base_url");
|
|
533
|
-
/** The rest client */
|
|
534
|
-
__publicField(this, "rest");
|
|
535
|
-
/** The guild of the manager */
|
|
536
|
-
__publicField(this, "guild");
|
|
537
|
-
/** Cache */
|
|
538
|
-
__publicField(this, "cache");
|
|
539
|
-
this.guild = guild;
|
|
540
|
-
this.rest = guild.rest;
|
|
541
|
-
this.cache = new Collection();
|
|
542
|
-
}
|
|
543
|
-
toJSON() {
|
|
544
|
-
return [...this.cache.values()].map((m) => m && "toJSON" in m && typeof m.toJSON === "function" ? m.toJSON() : m);
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
|
|
548
|
-
// src/managers/player/PlayerManager.ts
|
|
549
|
-
var PlayerManager = class extends Collection {
|
|
550
|
-
constructor(structure, base_url) {
|
|
551
|
-
super("players");
|
|
552
|
-
__publicField(this, "base_url");
|
|
553
|
-
__publicField(this, "rest");
|
|
554
|
-
__publicField(this, "guild");
|
|
555
|
-
this.base_url = base_url;
|
|
556
|
-
this.guild = structure.guild;
|
|
557
|
-
this.rest = structure.rest;
|
|
558
|
-
}
|
|
559
|
-
_set(data) {
|
|
560
|
-
this.clear();
|
|
561
|
-
if (Array.isArray(data)) {
|
|
562
|
-
for (let p of data) {
|
|
563
|
-
if (!p.id) continue;
|
|
564
|
-
this.set(p.id, {
|
|
565
|
-
id: p.id,
|
|
566
|
-
createdAt: p.createdAt ? new Date(p.createdAt) : /* @__PURE__ */ new Date(),
|
|
567
|
-
updateAt: p.updateAt ? new Date(p.updateAt) : /* @__PURE__ */ new Date()
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
} else {
|
|
571
|
-
if (!data.id) return;
|
|
572
|
-
this.set(data.id, {
|
|
573
|
-
id: data.id,
|
|
574
|
-
createdAt: data.createdAt ? new Date(data.createdAt) : /* @__PURE__ */ new Date(),
|
|
575
|
-
updateAt: data.updateAt ? new Date(data.updateAt) : /* @__PURE__ */ new Date()
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
return this;
|
|
579
|
-
}
|
|
580
|
-
/**
|
|
581
|
-
* Adds a player or an array of players to the structure.
|
|
582
|
-
* @param player A player or an array of players to be added
|
|
583
|
-
* @returns returns a collection of players
|
|
584
|
-
*/
|
|
585
|
-
async add(player) {
|
|
586
|
-
let players = [];
|
|
587
|
-
if (Array.isArray(player)) {
|
|
588
|
-
for (let p of player) this.has(p.id) ? null : players.push(p);
|
|
589
|
-
} else this.has(player.id) ? null : players.push(player);
|
|
590
|
-
const payload = { set: players };
|
|
591
|
-
const response = await this.rest.request({
|
|
592
|
-
method: "PATCH",
|
|
593
|
-
payload,
|
|
594
|
-
url: this.base_url
|
|
595
|
-
});
|
|
596
|
-
return this._set(response.players);
|
|
597
|
-
}
|
|
598
|
-
/**
|
|
599
|
-
* Remover a player or an array of players.
|
|
600
|
-
* @param player The player or an array of players to be removed
|
|
601
|
-
* @returns Player manager
|
|
602
|
-
*/
|
|
603
|
-
async remove(player) {
|
|
604
|
-
const ids = new Set(Array.isArray(player) ? player.map((p) => p.id) : [player.id]);
|
|
605
|
-
const players = this.toArray().filter((p) => !ids.has(p.id));
|
|
606
|
-
const payload = { set: players };
|
|
607
|
-
const response = await this.rest.request({
|
|
608
|
-
method: "PATCH",
|
|
609
|
-
payload,
|
|
610
|
-
url: this.base_url
|
|
611
|
-
});
|
|
612
|
-
return this._set(response.players);
|
|
613
|
-
}
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
// src/rest/APIEndpoints.ts
|
|
617
|
-
var Guild = class {
|
|
618
|
-
constructor() {
|
|
619
|
-
__publicField(this, "id");
|
|
620
|
-
__publicField(this, "tickets");
|
|
621
|
-
}
|
|
622
|
-
};
|
|
623
|
-
var APIEndpoints = {
|
|
624
|
-
"guilds/get": {
|
|
625
|
-
response: Guild
|
|
626
|
-
}
|
|
627
|
-
};
|
|
628
|
-
|
|
629
|
-
// src/rest/Routes.ts
|
|
630
|
-
var Routes = {
|
|
631
|
-
//base: "http://localhost:80/api/v1",
|
|
632
|
-
base: "https://duqueapi.shardweb.app/api/v1",
|
|
633
|
-
field: (field) => `/${field}`,
|
|
634
|
-
fields: (...fields) => `${fields.join("/")}`,
|
|
635
|
-
guilds: {
|
|
636
|
-
create: () => `/guilds`,
|
|
637
|
-
get: (guildId) => `/guilds/${guildId}`,
|
|
638
|
-
getAll: () => `/guilds`,
|
|
639
|
-
delete: (guildId) => `/guilds/${guildId}`,
|
|
640
|
-
deleteAll: () => `/guilds`,
|
|
641
|
-
resource: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
|
|
642
|
-
resources: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
|
|
643
|
-
users: {
|
|
644
|
-
create: (guildId) => `/guilds/${guildId}/users`,
|
|
645
|
-
update: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
|
646
|
-
getAll: (guildId) => `/guilds/${guildId}/users`,
|
|
647
|
-
get: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
|
648
|
-
delete: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
|
649
|
-
deleteAll: (guildId) => `/guilds/${guildId}/users`,
|
|
650
|
-
resource: (guildId, userId, ...resource) => `/guilds/${guildId}/users/${userId}/${resource.join("/")}`
|
|
651
|
-
},
|
|
652
|
-
betusers: {
|
|
653
|
-
getAll: (guildId) => `/guilds/${guildId}/betusers`,
|
|
654
|
-
get: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
|
|
655
|
-
create: (guildId) => `/guilds/${guildId}/betusers`,
|
|
656
|
-
update: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
|
|
657
|
-
delete: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
|
|
658
|
-
deleteAll: (guildId) => `/guilds/${guildId}/betusers`,
|
|
659
|
-
resource: (guildId, userId, resourceName) => `/guilds/${guildId}/betusers/${userId}/${resourceName}`
|
|
660
|
-
},
|
|
661
|
-
matches: {
|
|
662
|
-
getAll: (guildId) => `/guilds/${guildId}/matches`,
|
|
663
|
-
get: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
|
|
664
|
-
create: (guildId) => `/guilds/${guildId}/matches`,
|
|
665
|
-
update: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
|
|
666
|
-
delete: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
|
|
667
|
-
deleteAll: (guildId) => `/guilds/${guildId}/matches`,
|
|
668
|
-
resource: (guildId, matchId, ...resources) => `/guilds/${guildId}/matches/${matchId}/${resources.join("/")}`
|
|
669
|
-
},
|
|
670
|
-
bets: {
|
|
671
|
-
getAll: (guildId) => `/guilds/${guildId}/bets`,
|
|
672
|
-
get: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
|
|
673
|
-
create: (guildId) => `/guilds/${guildId}/bets`,
|
|
674
|
-
update: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
|
|
675
|
-
delete: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
|
|
676
|
-
deleteAll: (guildId) => `/guilds/${guildId}/bets`,
|
|
677
|
-
resource: (guildId, betId, ...resources) => `/guilds/${guildId}/bets/${betId}/${resources.join("/")}`
|
|
678
|
-
},
|
|
679
|
-
tickets: {
|
|
680
|
-
getAll: (guildId) => `/guilds/${guildId}/tickets`,
|
|
681
|
-
get: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
|
|
682
|
-
create: (guildId) => `/guilds/${guildId}/tickets`,
|
|
683
|
-
update: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
|
|
684
|
-
delete: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
|
|
685
|
-
deleteAll: (guildId) => `/guilds/${guildId}/tickets`,
|
|
686
|
-
resource: (guildId, ticketId, ...resources) => `/guilds/${guildId}/tickets/${ticketId}/${resources.join("/")}`
|
|
687
|
-
},
|
|
688
|
-
mediators: {
|
|
689
|
-
getAll: (guildId) => `/guilds/${guildId}/mediators`,
|
|
690
|
-
get: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
|
|
691
|
-
create: (guildId) => `/guilds/${guildId}/mediators`,
|
|
692
|
-
update: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
|
|
693
|
-
delete: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
|
|
694
|
-
deleteAll: (guildId) => `/guilds/${guildId}/mediators`,
|
|
695
|
-
resource: (guildId, mediatorId, ...resources) => `/guilds/${guildId}/mediators/${mediatorId}/${resources.join("/")}`
|
|
696
|
-
},
|
|
697
|
-
shop: {
|
|
698
|
-
get: (guildId) => `/guilds/${guildId}/manage/shop`,
|
|
699
|
-
update: (guildId) => `/guilds/${guildId}/manage/shop`,
|
|
700
|
-
delete: (guildId) => `/guilds/${guildId}/manage/shop/ `,
|
|
701
|
-
resource: (guildId, ...resources) => `/guilds/${guildId}/manage/shop/${resources.join("/")}`,
|
|
702
|
-
products: {
|
|
703
|
-
getAll: (guildId) => `/guilds/${guildId}/manage/shop/products`,
|
|
704
|
-
get: (guildId, productId) => `/guilds/${guildId}/manage/shop/${productId}/products`,
|
|
705
|
-
create: (guildId) => `/guilds/${guildId}/manage/shop/products`,
|
|
706
|
-
update: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
|
|
707
|
-
delete: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
|
|
708
|
-
deleteAll: (guildId) => `/guilds/${guildId}/products/shop`,
|
|
709
|
-
resource: (guildId, productId, ...resources) => `/guilds/${guildId}/manage/shop/products/${productId}/${resources.join("/")}`
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
},
|
|
713
|
-
vipmembers: {
|
|
714
|
-
get: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
|
|
715
|
-
getAll: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
716
|
-
deleteAll: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
717
|
-
create: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
718
|
-
update: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
|
|
719
|
-
delete: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`
|
|
720
|
-
},
|
|
721
|
-
giveaways: {
|
|
722
|
-
get: (giveawayId) => `/giveaways/${giveawayId}`,
|
|
723
|
-
getAll: () => `/giveaways`,
|
|
724
|
-
deleteAll: () => `/giveaways`,
|
|
725
|
-
create: () => `/giveaways`,
|
|
726
|
-
update: (giveawayId) => `/giveaways/${giveawayId}`,
|
|
727
|
-
delete: (giveawayId) => `/giveaways/${giveawayId}`
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
// src/rest/REST.ts
|
|
732
|
-
var import_dotenv = __toESM(require_main());
|
|
733
|
-
var import_events = __toESM(require("events"));
|
|
734
|
-
|
|
735
|
-
// src/utils/Assertion.ts
|
|
736
|
-
var Assertion = class {
|
|
737
|
-
constructor() {
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Tests if given key is a string
|
|
741
|
-
* @param key Key to test
|
|
742
|
-
*/
|
|
743
|
-
static assertString(key) {
|
|
744
|
-
if (typeof key !== "string") throw new Error(`${key} must be a string`);
|
|
745
|
-
if (!key || key === "") throw new Error(`${key} must be a string`);
|
|
746
|
-
return true;
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* Tests if given key is a number
|
|
750
|
-
* @param key Key to test
|
|
751
|
-
*/
|
|
752
|
-
static assertNumber(key) {
|
|
753
|
-
if (typeof key !== "number") throw new Error(`${key} must be a number`);
|
|
754
|
-
return true;
|
|
755
|
-
}
|
|
756
|
-
/**
|
|
757
|
-
* Tests if given key is a boolean
|
|
758
|
-
* @param key Key to test
|
|
759
|
-
*/
|
|
760
|
-
static assertBoolean(key) {
|
|
761
|
-
if (typeof key !== "boolean") throw new Error(`${key} must be a boolean`);
|
|
762
|
-
return true;
|
|
763
|
-
}
|
|
764
|
-
/**
|
|
765
|
-
* Tests if given key is an array
|
|
766
|
-
* @param key Key to test
|
|
767
|
-
*/
|
|
768
|
-
static assertArray(key) {
|
|
769
|
-
if (!Array.isArray(key)) throw new Error(`${key} must be an array`);
|
|
770
|
-
return true;
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* Tests if given key is an object
|
|
774
|
-
* @param key Key to test
|
|
775
|
-
*/
|
|
776
|
-
static assertObject(key) {
|
|
777
|
-
if (typeof key !== "object") throw new Error(`${key} must be an object`);
|
|
778
|
-
return true;
|
|
779
|
-
}
|
|
780
|
-
toString() {
|
|
781
|
-
return "string, number, boolean, array, object";
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
|
|
785
|
-
// src/rest/REST.ts
|
|
786
|
-
var import_undici = require("undici");
|
|
787
|
-
|
|
788
|
-
// src/structures/betuser/GuildBetUser.ts
|
|
789
|
-
var _GuildBetUser_instances, updateInternals_fn;
|
|
790
|
-
var _GuildBetUser = class _GuildBetUser {
|
|
791
|
-
/**
|
|
792
|
-
* Bet user
|
|
793
|
-
* @param data The user's data
|
|
794
|
-
* @param manager The manager
|
|
795
|
-
* @param rest The rest client
|
|
796
|
-
*/
|
|
797
|
-
constructor(data, manager) {
|
|
798
|
-
__privateAdd(this, _GuildBetUser_instances);
|
|
799
|
-
/** User daily */
|
|
800
|
-
__publicField(this, "daily");
|
|
801
|
-
__publicField(this, "profile");
|
|
802
|
-
/** User's name */
|
|
803
|
-
__publicField(this, "id");
|
|
804
|
-
__publicField(this, "guild_id");
|
|
805
|
-
/** User's credit */
|
|
806
|
-
__publicField(this, "credit");
|
|
807
|
-
/** User's wins */
|
|
808
|
-
__publicField(this, "wins");
|
|
809
|
-
/** User's mvps */
|
|
810
|
-
__publicField(this, "mvps");
|
|
811
|
-
/** User's losses */
|
|
812
|
-
__publicField(this, "losses");
|
|
813
|
-
/** User's games */
|
|
814
|
-
__publicField(this, "games");
|
|
815
|
-
/** User's blacklist */
|
|
816
|
-
__publicField(this, "blacklist");
|
|
817
|
-
/** User's coins */
|
|
818
|
-
__publicField(this, "coins");
|
|
819
|
-
__publicField(this, "spins");
|
|
820
|
-
/** Creation Date */
|
|
821
|
-
__publicField(this, "createdAt");
|
|
822
|
-
/** Updated Date */
|
|
823
|
-
__publicField(this, "updatedAt");
|
|
824
|
-
__publicField(this, "consecutive_wins");
|
|
825
|
-
/** The given manager */
|
|
826
|
-
__publicField(this, "manager");
|
|
827
|
-
/** The rest client */
|
|
828
|
-
__publicField(this, "rest");
|
|
829
|
-
__publicField(this, "guild");
|
|
830
|
-
this.id = data?.id;
|
|
831
|
-
this.guild_id = data?.guild_id;
|
|
832
|
-
this.manager = manager;
|
|
833
|
-
this.rest = manager.rest;
|
|
834
|
-
this.guild = manager.guild;
|
|
835
|
-
this.wins = data?.wins;
|
|
836
|
-
this.coins = data?.coins;
|
|
837
|
-
this.losses = data?.losses;
|
|
838
|
-
this.credit = data?.credit;
|
|
839
|
-
this.spins = data?.spins;
|
|
840
|
-
this.daily = data?.daily;
|
|
841
|
-
this.games = data?.games;
|
|
842
|
-
this.blacklist = data?.blacklist;
|
|
843
|
-
this.consecutive_wins = data?.consecutive_wins;
|
|
844
|
-
this.profile = data?.profile;
|
|
845
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
846
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
847
|
-
}
|
|
848
|
-
/** String representation of this user */
|
|
849
|
-
toString() {
|
|
850
|
-
return `<@${this.id}>`;
|
|
851
|
-
}
|
|
852
|
-
/**
|
|
853
|
-
* Fetches the user
|
|
854
|
-
* @returns New Instance of the user
|
|
855
|
-
*/
|
|
856
|
-
async fetch() {
|
|
857
|
-
const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
|
|
858
|
-
const response = await this.rest.request({
|
|
859
|
-
method: "get",
|
|
860
|
-
url: route
|
|
861
|
-
});
|
|
862
|
-
const user = new _GuildBetUser(response, this.manager);
|
|
863
|
-
this.manager.cache.set(user.id, user);
|
|
864
|
-
this.rest.betusers.set(user.id, user);
|
|
865
|
-
return user;
|
|
866
|
-
}
|
|
867
|
-
/**
|
|
868
|
-
* Set the user blacklist
|
|
869
|
-
* @param value Value to set to
|
|
870
|
-
* @returns GuildBetUser
|
|
871
|
-
*/
|
|
872
|
-
async setBlacklist(value) {
|
|
873
|
-
const route = Routes.guilds.betusers.resource(this.manager.guild.id, this.id, "blacklist");
|
|
874
|
-
const payload = { set: value };
|
|
875
|
-
await this.rest.request({
|
|
876
|
-
method: "patch",
|
|
877
|
-
url: route,
|
|
878
|
-
payload
|
|
879
|
-
});
|
|
880
|
-
this.blacklist = value;
|
|
881
|
-
this.manager.cache.set(this.id, this);
|
|
882
|
-
this.rest.betusers.set(this.id, this);
|
|
883
|
-
return this;
|
|
884
|
-
}
|
|
885
|
-
async reset() {
|
|
886
|
-
const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
|
|
887
|
-
const payload = { reset: true };
|
|
888
|
-
const response = await this.rest.request({
|
|
889
|
-
method: "DELETE",
|
|
890
|
-
url: route,
|
|
891
|
-
payload
|
|
892
|
-
});
|
|
893
|
-
return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn).call(this, response);
|
|
894
|
-
}
|
|
895
|
-
async updateProfile(data) {
|
|
896
|
-
const _data = {
|
|
897
|
-
profile: {
|
|
898
|
-
avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
|
|
899
|
-
bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
|
|
900
|
-
bio: data.bio || this.profile.bio || "Melhor da minha aldeia (use !bio para alterar)",
|
|
901
|
-
name: data.name || this.profile.name || "",
|
|
902
|
-
textColor: data.textColor || this.profile.textColor || "#ffffff",
|
|
903
|
-
primaryColor: data.primaryColor || this.profile.primaryColor || "#272727",
|
|
904
|
-
secondaryColor: data.secondaryColor || this.profile.secondaryColor || "#151515"
|
|
905
|
-
}
|
|
906
|
-
};
|
|
907
|
-
const route = Routes.guilds.betusers.update(this.manager.guild.id, this.id);
|
|
908
|
-
const response = await this.rest.request({
|
|
909
|
-
method: "patch",
|
|
910
|
-
url: route,
|
|
911
|
-
payload: _data
|
|
912
|
-
});
|
|
913
|
-
return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn).call(this, response);
|
|
914
|
-
}
|
|
915
|
-
/**
|
|
916
|
-
* Update certain property
|
|
917
|
-
* @param data The new data to update with
|
|
918
|
-
* @returns
|
|
919
|
-
*/
|
|
920
|
-
async update(data) {
|
|
921
|
-
if (!data?.type) data.type = "add";
|
|
922
|
-
const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
|
|
923
|
-
let payload = {};
|
|
924
|
-
const numericFields = ["wins", "credit", "losses", "mvps", "games", "coins", "spins", "consecutive_wins"];
|
|
925
|
-
const arrayFields = ["items", "original_channels", "adverts", "accessories"];
|
|
926
|
-
if (data?.type === "add" || data?.type === "remove") {
|
|
927
|
-
for (const key in data) {
|
|
928
|
-
if (key === "type") continue;
|
|
929
|
-
const value = data[key];
|
|
930
|
-
if (numericFields.includes(key)) {
|
|
931
|
-
const current = this[key] || 0;
|
|
932
|
-
const num = value || 0;
|
|
933
|
-
payload[key] = Math.max(0, data?.type === "add" ? current + num : current - num);
|
|
934
|
-
} else if (key === "blacklist") {
|
|
935
|
-
payload["blacklist"] = value;
|
|
936
|
-
} else if (key === "profile") {
|
|
937
|
-
payload["profile"] = value;
|
|
938
|
-
} else if (arrayFields.includes(key)) {
|
|
939
|
-
const current = this[key];
|
|
940
|
-
const incoming = value;
|
|
941
|
-
payload[key] = data?.type === "add" ? [.../* @__PURE__ */ new Set([...current, ...incoming])] : current.filter((x) => !incoming.includes(x));
|
|
942
|
-
}
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
const response = await this.rest.request({
|
|
946
|
-
method: "patch",
|
|
947
|
-
url: route,
|
|
948
|
-
payload
|
|
949
|
-
});
|
|
950
|
-
return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn).call(this, response);
|
|
951
|
-
}
|
|
952
|
-
async _update(data) {
|
|
953
|
-
const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
|
|
954
|
-
let payload = {};
|
|
955
|
-
const response = await this.rest.request({
|
|
956
|
-
method: "put",
|
|
957
|
-
url: route,
|
|
958
|
-
payload
|
|
959
|
-
});
|
|
960
|
-
return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn).call(this, response);
|
|
961
|
-
}
|
|
962
|
-
async delete() {
|
|
963
|
-
const route = Routes.guilds.betusers.delete(this.manager.guild.id, this.id);
|
|
964
|
-
const response = await this.rest.request({
|
|
965
|
-
method: "DELETE",
|
|
966
|
-
url: route
|
|
967
|
-
});
|
|
968
|
-
this.rest.emit("betuserDelete", this);
|
|
969
|
-
this.manager.cache.delete(this.id);
|
|
970
|
-
return response;
|
|
971
|
-
}
|
|
972
|
-
toJSON() {
|
|
973
|
-
let json = {};
|
|
974
|
-
for (const [key, value] of Object.entries(this)) {
|
|
975
|
-
const exclude = ["rest", "guilds", "guild", "manager"];
|
|
976
|
-
if (exclude.includes(key)) continue;
|
|
977
|
-
if (typeof value !== "function") {
|
|
978
|
-
json[key] = value;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
|
-
return json;
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
_GuildBetUser_instances = new WeakSet();
|
|
985
|
-
updateInternals_fn = function(data) {
|
|
986
|
-
for (let key in data) {
|
|
987
|
-
if (key === "id" || key === "createdAt") continue;
|
|
988
|
-
if (key in this) {
|
|
989
|
-
this[key] = data[key];
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
993
|
-
this.createdAt = new Date(data.createdAt);
|
|
994
|
-
this.manager.set(this);
|
|
995
|
-
this.rest.emit("betuserUpdate", this);
|
|
996
|
-
return this;
|
|
997
|
-
};
|
|
998
|
-
var GuildBetUser = _GuildBetUser;
|
|
999
|
-
|
|
1000
|
-
// src/managers/betuser/GuildBetUserManager.ts
|
|
1001
|
-
var GuildBetUserManager = class extends BaseManager {
|
|
1002
|
-
constructor(guild) {
|
|
1003
|
-
super(guild);
|
|
1004
|
-
this.guild = guild;
|
|
1005
|
-
this.rest = guild.rest;
|
|
1006
|
-
this.base_url = Routes.guilds.betusers.getAll(guild.id);
|
|
1007
|
-
this.cache = new Collection("betusers");
|
|
1008
|
-
}
|
|
1009
|
-
async fetch(options) {
|
|
1010
|
-
if (options && options.cache) return this.cache;
|
|
1011
|
-
if (options && options.userId) {
|
|
1012
|
-
const route2 = Routes.fields(this.base_url, options.userId);
|
|
1013
|
-
const response2 = await this.rest.request({
|
|
1014
|
-
method: "GET",
|
|
1015
|
-
url: route2
|
|
1016
|
-
});
|
|
1017
|
-
const user = new GuildBetUser(response2, this);
|
|
1018
|
-
this.set(user);
|
|
1019
|
-
return user;
|
|
1020
|
-
}
|
|
1021
|
-
const route = this.base_url;
|
|
1022
|
-
const response = await this.rest.request({
|
|
1023
|
-
method: "GET",
|
|
1024
|
-
url: route
|
|
1025
|
-
});
|
|
1026
|
-
this.set(response);
|
|
1027
|
-
return this.cache;
|
|
1028
|
-
}
|
|
1029
|
-
async updateMany(...betusers) {
|
|
1030
|
-
const route = this.base_url;
|
|
1031
|
-
const response = await this.rest.request({
|
|
1032
|
-
method: "PATCH",
|
|
1033
|
-
url: route,
|
|
1034
|
-
payload: { betusers }
|
|
1035
|
-
});
|
|
1036
|
-
return this.set(response);
|
|
1037
|
-
}
|
|
1038
|
-
async deleteAll() {
|
|
1039
|
-
const route = this.base_url;
|
|
1040
|
-
await this.rest.request({
|
|
1041
|
-
method: "DELETE",
|
|
1042
|
-
url: route
|
|
1043
|
-
});
|
|
1044
|
-
this.cache.clear();
|
|
1045
|
-
}
|
|
1046
|
-
async resetAll() {
|
|
1047
|
-
const route = this.base_url;
|
|
1048
|
-
const response = await this.rest.request({
|
|
1049
|
-
method: "put",
|
|
1050
|
-
url: route
|
|
1051
|
-
});
|
|
1052
|
-
this.cache.clear();
|
|
1053
|
-
return this.set(response);
|
|
1054
|
-
}
|
|
1055
|
-
set(data) {
|
|
1056
|
-
if (!data) return this.cache;
|
|
1057
|
-
if (Array.isArray(data)) {
|
|
1058
|
-
for (let _user of data) {
|
|
1059
|
-
if (!_user.id) return;
|
|
1060
|
-
const user = new GuildBetUser(_user, this);
|
|
1061
|
-
this.cache.set(user.id, user);
|
|
1062
|
-
this.rest.betusers.set(user.id, user);
|
|
1063
|
-
}
|
|
1064
|
-
return this.cache;
|
|
1065
|
-
} else {
|
|
1066
|
-
if (!data.id) return;
|
|
1067
|
-
const user = new GuildBetUser(data, this);
|
|
1068
|
-
this.cache.set(user.id, user);
|
|
1069
|
-
this.rest.betusers.set(user.id, user);
|
|
1070
|
-
return user;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
|
|
1075
|
-
// src/structures/mediator/GuildMediator.ts
|
|
1076
|
-
var _GuildMediator_instances, updateInternals_fn2;
|
|
1077
|
-
var _GuildMediator = class _GuildMediator {
|
|
1078
|
-
/**
|
|
1079
|
-
* Bet user
|
|
1080
|
-
* @param data The user's data
|
|
1081
|
-
* @param manager The manager
|
|
1082
|
-
* @param rest The rest client
|
|
1083
|
-
*/
|
|
1084
|
-
constructor(data, manager) {
|
|
1085
|
-
__privateAdd(this, _GuildMediator_instances);
|
|
1086
|
-
/** User's name */
|
|
1087
|
-
__publicField(this, "id");
|
|
1088
|
-
__publicField(this, "guild_id");
|
|
1089
|
-
/** User's games */
|
|
1090
|
-
__publicField(this, "games");
|
|
1091
|
-
__publicField(this, "paypal");
|
|
1092
|
-
__publicField(this, "revolut");
|
|
1093
|
-
__publicField(this, "mbway");
|
|
1094
|
-
__publicField(this, "external_links");
|
|
1095
|
-
/** Creation Date */
|
|
1096
|
-
__publicField(this, "createdAt");
|
|
1097
|
-
/** Updated Date */
|
|
1098
|
-
__publicField(this, "updatedAt");
|
|
1099
|
-
/** The given manager */
|
|
1100
|
-
__publicField(this, "manager");
|
|
1101
|
-
/** The rest client */
|
|
1102
|
-
__publicField(this, "rest");
|
|
1103
|
-
__publicField(this, "guild");
|
|
1104
|
-
this.id = data?.id;
|
|
1105
|
-
this.guild_id = data?.guild_id;
|
|
1106
|
-
this.manager = manager;
|
|
1107
|
-
this.rest = manager.rest;
|
|
1108
|
-
this.guild = manager.guild;
|
|
1109
|
-
this.games = data?.games;
|
|
1110
|
-
this.paypal = data?.paypal;
|
|
1111
|
-
this.revolut = data?.revolut;
|
|
1112
|
-
this.mbway = data?.mbway;
|
|
1113
|
-
this.external_links = data?.external_links;
|
|
1114
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
1115
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1116
|
-
}
|
|
1117
|
-
/** String representation of this user */
|
|
1118
|
-
toString() {
|
|
1119
|
-
return `<@${this.id}>`;
|
|
1120
|
-
}
|
|
1121
|
-
/**
|
|
1122
|
-
* Fetches the user
|
|
1123
|
-
* @returns New Instance of the user
|
|
1124
|
-
*/
|
|
1125
|
-
async fetch() {
|
|
1126
|
-
const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
|
|
1127
|
-
const response = await this.rest.request({
|
|
1128
|
-
method: "get",
|
|
1129
|
-
url: route
|
|
1130
|
-
});
|
|
1131
|
-
const user = new _GuildMediator(response, this.manager);
|
|
1132
|
-
this.manager.cache.set(user.id, user);
|
|
1133
|
-
this.rest.mediators.set(user.id, user);
|
|
1134
|
-
return user;
|
|
1135
|
-
}
|
|
1136
|
-
async reset() {
|
|
1137
|
-
const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
|
|
1138
|
-
const payload = { reset: true };
|
|
1139
|
-
const response = await this.rest.request({
|
|
1140
|
-
method: "DELETE",
|
|
1141
|
-
url: route,
|
|
1142
|
-
payload
|
|
1143
|
-
});
|
|
1144
|
-
return __privateMethod(this, _GuildMediator_instances, updateInternals_fn2).call(this, response);
|
|
1145
|
-
}
|
|
1146
|
-
/**
|
|
1147
|
-
* Update certain property
|
|
1148
|
-
* @param data The new data to update with
|
|
1149
|
-
* @returns
|
|
1150
|
-
*/
|
|
1151
|
-
async update(data) {
|
|
1152
|
-
const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
|
|
1153
|
-
let payload = data;
|
|
1154
|
-
const response = await this.rest.request({
|
|
1155
|
-
method: "patch",
|
|
1156
|
-
url: route,
|
|
1157
|
-
payload
|
|
1158
|
-
});
|
|
1159
|
-
return __privateMethod(this, _GuildMediator_instances, updateInternals_fn2).call(this, response);
|
|
1160
|
-
}
|
|
1161
|
-
async setPaymentlink(type, link) {
|
|
1162
|
-
const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
|
|
1163
|
-
let payload = { [type]: link };
|
|
1164
|
-
const response = await this.rest.request({
|
|
1165
|
-
method: "patch",
|
|
1166
|
-
url: route,
|
|
1167
|
-
payload
|
|
1168
|
-
});
|
|
1169
|
-
return __privateMethod(this, _GuildMediator_instances, updateInternals_fn2).call(this, response);
|
|
1170
|
-
}
|
|
1171
|
-
async delete() {
|
|
1172
|
-
const route = Routes.guilds.mediators.delete(this.manager.guild.id, this.id);
|
|
1173
|
-
const response = await this.rest.request({
|
|
1174
|
-
method: "DELETE",
|
|
1175
|
-
url: route
|
|
1176
|
-
});
|
|
1177
|
-
this.manager.cache.delete(this.id);
|
|
1178
|
-
return response;
|
|
1179
|
-
}
|
|
1180
|
-
toJSON() {
|
|
1181
|
-
let json = {};
|
|
1182
|
-
for (const [key, value] of Object.entries(this)) {
|
|
1183
|
-
const exclude = ["rest", "guilds", "guild", "manager"];
|
|
1184
|
-
if (exclude.includes(key)) continue;
|
|
1185
|
-
if (typeof value !== "function") {
|
|
1186
|
-
json[key] = value;
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
return json;
|
|
1190
|
-
}
|
|
1191
|
-
};
|
|
1192
|
-
_GuildMediator_instances = new WeakSet();
|
|
1193
|
-
updateInternals_fn2 = function(data) {
|
|
1194
|
-
for (let key in data) {
|
|
1195
|
-
if (key === "id" || key === "createdAt") continue;
|
|
1196
|
-
if (key in this) {
|
|
1197
|
-
this[key] = data[key];
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
1201
|
-
this.createdAt = new Date(data.createdAt);
|
|
1202
|
-
this.manager.set(this);
|
|
1203
|
-
return this;
|
|
1204
|
-
};
|
|
1205
|
-
var GuildMediator = _GuildMediator;
|
|
1206
|
-
|
|
1207
|
-
// src/managers/mediator/GuildMediatorManager.ts
|
|
1208
|
-
var GuildMediatorManager = class extends BaseManager {
|
|
1209
|
-
constructor(guild) {
|
|
1210
|
-
super(guild);
|
|
1211
|
-
this.guild = guild;
|
|
1212
|
-
this.rest = guild.rest;
|
|
1213
|
-
this.base_url = Routes.guilds.mediators.getAll(guild.id);
|
|
1214
|
-
this.cache = new Collection("mediators");
|
|
1215
|
-
}
|
|
1216
|
-
async fetch(options) {
|
|
1217
|
-
if (options && options.cache) return this.cache;
|
|
1218
|
-
if (options && options.mediatorId) {
|
|
1219
|
-
const route2 = Routes.fields(this.base_url, options.mediatorId);
|
|
1220
|
-
const response2 = await this.rest.request({
|
|
1221
|
-
method: "GET",
|
|
1222
|
-
url: route2
|
|
1223
|
-
});
|
|
1224
|
-
return this.set(response2);
|
|
1225
|
-
}
|
|
1226
|
-
const route = this.base_url;
|
|
1227
|
-
const response = await this.rest.request({
|
|
1228
|
-
method: "GET",
|
|
1229
|
-
url: route
|
|
1230
|
-
});
|
|
1231
|
-
this.set(response);
|
|
1232
|
-
return this.cache;
|
|
1233
|
-
}
|
|
1234
|
-
async updateMany(...mediators) {
|
|
1235
|
-
const route = this.base_url;
|
|
1236
|
-
const response = await this.rest.request({
|
|
1237
|
-
method: "PATCH",
|
|
1238
|
-
url: route,
|
|
1239
|
-
payload: { mediators }
|
|
1240
|
-
});
|
|
1241
|
-
return this.set(response);
|
|
1242
|
-
}
|
|
1243
|
-
async create(payload) {
|
|
1244
|
-
const route = Routes.guilds.mediators.create(this.guild.id);
|
|
1245
|
-
const response = await this.rest.request({
|
|
1246
|
-
method: "POST",
|
|
1247
|
-
url: route,
|
|
1248
|
-
payload
|
|
1249
|
-
});
|
|
1250
|
-
return this.set(response);
|
|
1251
|
-
}
|
|
1252
|
-
async deleteAll() {
|
|
1253
|
-
const route = this.base_url;
|
|
1254
|
-
await this.rest.request({
|
|
1255
|
-
method: "DELETE",
|
|
1256
|
-
url: route
|
|
1257
|
-
});
|
|
1258
|
-
this.cache.clear();
|
|
1259
|
-
}
|
|
1260
|
-
async resetAll() {
|
|
1261
|
-
const route = this.base_url;
|
|
1262
|
-
const response = await this.rest.request({
|
|
1263
|
-
method: "put",
|
|
1264
|
-
url: route
|
|
1265
|
-
});
|
|
1266
|
-
this.cache.clear();
|
|
1267
|
-
this.set(response);
|
|
1268
|
-
return this.cache;
|
|
1269
|
-
}
|
|
1270
|
-
set(data) {
|
|
1271
|
-
if (!data) return this.cache;
|
|
1272
|
-
if (Array.isArray(data)) {
|
|
1273
|
-
for (let _mediator of data) {
|
|
1274
|
-
if (!_mediator.id) return;
|
|
1275
|
-
const mediator = new GuildMediator(_mediator, this);
|
|
1276
|
-
this.cache.set(mediator.id, mediator);
|
|
1277
|
-
this.rest.mediators.set(mediator.id, mediator);
|
|
1278
|
-
}
|
|
1279
|
-
return this.cache;
|
|
1280
|
-
} else {
|
|
1281
|
-
if (!data.id) return;
|
|
1282
|
-
const mediator = new GuildMediator(data, this);
|
|
1283
|
-
this.cache.set(mediator.id, mediator);
|
|
1284
|
-
this.rest.mediators.set(mediator.id, mediator);
|
|
1285
|
-
return mediator;
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
};
|
|
1289
|
-
|
|
1290
|
-
// src/structures/tournament/Tournament.ts
|
|
1291
|
-
var _Tournament_instances, updateInternals_fn3;
|
|
1292
|
-
var Tournament = class {
|
|
1293
|
-
constructor(data, manager) {
|
|
1294
|
-
__privateAdd(this, _Tournament_instances);
|
|
1295
|
-
__publicField(this, "_id");
|
|
1296
|
-
__publicField(this, "guild_id");
|
|
1297
|
-
__publicField(this, "type");
|
|
1298
|
-
__publicField(this, "max_teams");
|
|
1299
|
-
__publicField(this, "teams");
|
|
1300
|
-
__publicField(this, "message");
|
|
1301
|
-
__publicField(this, "message_id");
|
|
1302
|
-
__publicField(this, "status");
|
|
1303
|
-
__publicField(this, "createdAt");
|
|
1304
|
-
__publicField(this, "updatedAt");
|
|
1305
|
-
__publicField(this, "guild");
|
|
1306
|
-
__publicField(this, "rest");
|
|
1307
|
-
__publicField(this, "manager");
|
|
1308
|
-
__publicField(this, "data");
|
|
1309
|
-
this.manager = manager;
|
|
1310
|
-
this.guild = manager.guild;
|
|
1311
|
-
this.rest = manager.rest;
|
|
1312
|
-
this.guild_id = data?.guild_id;
|
|
1313
|
-
this.type = data?.type;
|
|
1314
|
-
this.teams = data?.teams;
|
|
1315
|
-
this.message = data?.message;
|
|
1316
|
-
this.message_id = data?.message_id;
|
|
1317
|
-
this.status = data?.status;
|
|
1318
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
1319
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1320
|
-
this.data = data;
|
|
1321
|
-
}
|
|
1322
|
-
async fetch() {
|
|
1323
|
-
const route = Routes.fields("guilds", this.guild.id, "tournaments", this._id);
|
|
1324
|
-
const response = await this.rest.request({
|
|
1325
|
-
method: "get",
|
|
1326
|
-
url: route
|
|
1327
|
-
});
|
|
1328
|
-
return __privateMethod(this, _Tournament_instances, updateInternals_fn3).call(this, response);
|
|
1329
|
-
}
|
|
1330
|
-
async update(data) {
|
|
1331
|
-
const route = Routes.fields("guilds", this.guild.id, "tournaments", this._id);
|
|
1332
|
-
const response = await this.rest.request({
|
|
1333
|
-
method: "patch",
|
|
1334
|
-
url: route,
|
|
1335
|
-
payload: data
|
|
1336
|
-
});
|
|
1337
|
-
return __privateMethod(this, _Tournament_instances, updateInternals_fn3).call(this, response);
|
|
1338
|
-
}
|
|
1339
|
-
toJSON() {
|
|
1340
|
-
return {
|
|
1341
|
-
guild_id: this.guild_id,
|
|
1342
|
-
type: this.type,
|
|
1343
|
-
max_teams: this.max_teams,
|
|
1344
|
-
teams: this.teams,
|
|
1345
|
-
message: this.message,
|
|
1346
|
-
message_id: this.message_id,
|
|
1347
|
-
status: this.status,
|
|
1348
|
-
createdAt: this.createdAt ? new Date(this?.createdAt) : /* @__PURE__ */ new Date(),
|
|
1349
|
-
updatedAt: this.updatedAt ? new Date(this?.updatedAt) : /* @__PURE__ */ new Date()
|
|
1350
|
-
};
|
|
1351
|
-
}
|
|
1352
|
-
};
|
|
1353
|
-
_Tournament_instances = new WeakSet();
|
|
1354
|
-
updateInternals_fn3 = function(data) {
|
|
1355
|
-
for (let key in data) {
|
|
1356
|
-
if (key === "id" || key === "createdAt") continue;
|
|
1357
|
-
if (key in this) {
|
|
1358
|
-
this[key] = data[key];
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
1362
|
-
this.createdAt = new Date(data.createdAt);
|
|
1363
|
-
this.manager._add(this);
|
|
1364
|
-
return this;
|
|
1365
|
-
};
|
|
1366
|
-
|
|
1367
|
-
// src/managers/tournament/TournamentManager.ts
|
|
1368
|
-
var TournamentManager = class extends BaseManager {
|
|
1369
|
-
constructor(guild) {
|
|
1370
|
-
super(guild);
|
|
1371
|
-
this.guild = guild;
|
|
1372
|
-
this.rest = guild.rest;
|
|
1373
|
-
this.base_url = Routes.guilds.resource(guild.id, "tournaments");
|
|
1374
|
-
this.cache = new Collection();
|
|
1375
|
-
}
|
|
1376
|
-
async fetch(options) {
|
|
1377
|
-
if (options && options.cache) return this.cache;
|
|
1378
|
-
if (options && options.tournamentId) {
|
|
1379
|
-
const response2 = await this.rest.request({
|
|
1380
|
-
method: "GET",
|
|
1381
|
-
url: Routes.fields(this.base_url, options.tournamentId)
|
|
1382
|
-
});
|
|
1383
|
-
const tournament = new Tournament(response2, this);
|
|
1384
|
-
this._add(tournament);
|
|
1385
|
-
return tournament;
|
|
1386
|
-
}
|
|
1387
|
-
const response = await this.rest.request({
|
|
1388
|
-
method: "GET",
|
|
1389
|
-
url: this.base_url
|
|
1390
|
-
});
|
|
1391
|
-
return this.set(response);
|
|
1392
|
-
}
|
|
1393
|
-
set(data) {
|
|
1394
|
-
this.cache.clear();
|
|
1395
|
-
if (Array.isArray(data)) {
|
|
1396
|
-
for (let _m of data) {
|
|
1397
|
-
if (!_m._id) continue;
|
|
1398
|
-
if (_m instanceof Tournament) this.cache.set(_m._id, _m);
|
|
1399
|
-
else this.cache.set(_m._id, new Tournament(_m, this));
|
|
1400
|
-
}
|
|
1401
|
-
} else {
|
|
1402
|
-
if (!data._id) return this.cache;
|
|
1403
|
-
if (data instanceof Tournament) this.cache.set(data._id, data);
|
|
1404
|
-
else this.cache.set(data._id, new Tournament(data, this));
|
|
1405
|
-
}
|
|
1406
|
-
return this.cache;
|
|
1407
|
-
}
|
|
1408
|
-
_add(data) {
|
|
1409
|
-
if (Array.isArray(data)) {
|
|
1410
|
-
for (let _m of data) {
|
|
1411
|
-
if (!_m._id) continue;
|
|
1412
|
-
if (_m instanceof Tournament) this.cache.set(_m._id, _m);
|
|
1413
|
-
else this.cache.set(_m._id, new Tournament(_m, this));
|
|
1414
|
-
}
|
|
1415
|
-
} else {
|
|
1416
|
-
if (!data._id) return this.cache;
|
|
1417
|
-
if (data instanceof Tournament) this.cache.set(data._id, data);
|
|
1418
|
-
else this.cache.set(data._id, new Tournament(data, this));
|
|
1419
|
-
}
|
|
1420
|
-
return this.cache;
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
|
|
1424
|
-
// src/structures/guild/Guild.ts
|
|
1425
|
-
var _Guild_instances, updateInternals_fn4;
|
|
1426
|
-
var Guild3 = class {
|
|
1427
|
-
/**
|
|
1428
|
-
* The guild structure
|
|
1429
|
-
* @param data The guild's data
|
|
1430
|
-
* @param rest The rest client
|
|
1431
|
-
*/
|
|
1432
|
-
constructor(data, rest) {
|
|
1433
|
-
__privateAdd(this, _Guild_instances);
|
|
1434
|
-
/** The data of this guild */
|
|
1435
|
-
__publicField(this, "data");
|
|
1436
|
-
/** The rest client */
|
|
1437
|
-
__publicField(this, "rest");
|
|
1438
|
-
/** The guild's id */
|
|
1439
|
-
__publicField(this, "id");
|
|
1440
|
-
__publicField(this, "modes");
|
|
1441
|
-
/** Guild's client key */
|
|
1442
|
-
__publicField(this, "client_key");
|
|
1443
|
-
/** Guild Permissions */
|
|
1444
|
-
__publicField(this, "permissions");
|
|
1445
|
-
/** Guild Ticket */
|
|
1446
|
-
__publicField(this, "tickets");
|
|
1447
|
-
/** Guild Ticket Configuration */
|
|
1448
|
-
__publicField(this, "tickets_configuration");
|
|
1449
|
-
/** Guild Daily Categories */
|
|
1450
|
-
__publicField(this, "daily_categories");
|
|
1451
|
-
/** Guild Scores */
|
|
1452
|
-
__publicField(this, "scores");
|
|
1453
|
-
/** Guild Status */
|
|
1454
|
-
__publicField(this, "status");
|
|
1455
|
-
__publicField(this, "channels");
|
|
1456
|
-
__publicField(this, "roulette_settings");
|
|
1457
|
-
/** Guild Prefix */
|
|
1458
|
-
__publicField(this, "prefix");
|
|
1459
|
-
__publicField(this, "prefixes");
|
|
1460
|
-
/** Guild Creation Date */
|
|
1461
|
-
__publicField(this, "createdAt");
|
|
1462
|
-
/** Guild Updated Date */
|
|
1463
|
-
__publicField(this, "updatedAt");
|
|
1464
|
-
/** Guild Matches */
|
|
1465
|
-
__publicField(this, "matches");
|
|
1466
|
-
/** Guild Prices Used */
|
|
1467
|
-
__publicField(this, "prices");
|
|
1468
|
-
__publicField(this, "permissionsManager");
|
|
1469
|
-
__publicField(this, "buffer");
|
|
1470
|
-
__publicField(this, "vipMembers");
|
|
1471
|
-
__publicField(this, "users");
|
|
1472
|
-
__publicField(this, "logEntries");
|
|
1473
|
-
__publicField(this, "shop");
|
|
1474
|
-
__publicField(this, "betusers");
|
|
1475
|
-
__publicField(this, "bets");
|
|
1476
|
-
__publicField(this, "mediators");
|
|
1477
|
-
__publicField(this, "automatic_messages");
|
|
1478
|
-
__publicField(this, "automaticMessagesManager");
|
|
1479
|
-
__publicField(this, "tournaments");
|
|
1480
|
-
__publicField(this, "adverts");
|
|
1481
|
-
__publicField(this, "codes");
|
|
1482
|
-
__publicField(this, "coin_symbol");
|
|
1483
|
-
this.data = data;
|
|
1484
|
-
this.rest = rest;
|
|
1485
|
-
this.id = data?.id;
|
|
1486
|
-
this.client_key = data?.client_key;
|
|
1487
|
-
this.daily_categories = data?.daily_categories;
|
|
1488
|
-
this.permissions = data?.permissions;
|
|
1489
|
-
this.modes = data?.modes;
|
|
1490
|
-
this.prices = data?.prices;
|
|
1491
|
-
this.scores = data?.scores;
|
|
1492
|
-
this.codes = data?.codes;
|
|
1493
|
-
this.prefix = data?.prefix;
|
|
1494
|
-
this.prefixes = data?.prefixes;
|
|
1495
|
-
this.status = data?.status;
|
|
1496
|
-
this.tickets_configuration = data?.tickets_configuration;
|
|
1497
|
-
this.automatic_messages = data?.automatic_messages;
|
|
1498
|
-
this.channels = data?.channels;
|
|
1499
|
-
this.shop = data?.shop;
|
|
1500
|
-
this.coin_symbol = data?.coin_symbol;
|
|
1501
|
-
this.roulette_settings = data?.roulette_settings;
|
|
1502
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
1503
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1504
|
-
this.permissionsManager = new GuildPermissionManager(this);
|
|
1505
|
-
this.buffer = new BufferManager(this);
|
|
1506
|
-
this.users = new GuildUserManager(this);
|
|
1507
|
-
this.matches = new GuildMatchManager(this);
|
|
1508
|
-
this.tickets = new GuildTicketManager(this);
|
|
1509
|
-
this.vipMembers = new VipMemberManager(this);
|
|
1510
|
-
this.logEntries = new LogManager(this);
|
|
1511
|
-
this.betusers = new GuildBetUserManager(this);
|
|
1512
|
-
this.bets = new GuildBetManager(this);
|
|
1513
|
-
this.mediators = new GuildMediatorManager(this);
|
|
1514
|
-
this.automaticMessagesManager = new AutomaticMessageManager(this);
|
|
1515
|
-
this.tournaments = new TournamentManager(this);
|
|
1516
|
-
this.adverts = [];
|
|
1517
|
-
for (let _adv of data?.adverts || []) {
|
|
1518
|
-
this.adverts.push({
|
|
1519
|
-
_id: _adv._id,
|
|
1520
|
-
admin_id: _adv.admin_id,
|
|
1521
|
-
points_to_remove: _adv.points_to_remove,
|
|
1522
|
-
role_id: _adv.role_id,
|
|
1523
|
-
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
|
|
1524
|
-
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
|
|
1525
|
-
});
|
|
1526
|
-
}
|
|
1527
|
-
this.codes = [];
|
|
1528
|
-
for (let _adv of data?.codes || []) {
|
|
1529
|
-
this.codes.push({
|
|
1530
|
-
_id: _adv._id,
|
|
1531
|
-
admin_id: _adv.admin_id,
|
|
1532
|
-
type: _adv.type,
|
|
1533
|
-
add: _adv.add,
|
|
1534
|
-
code: _adv.code,
|
|
1535
|
-
expire: _adv.expire ? new Date(_adv.expire) : /* @__PURE__ */ new Date(),
|
|
1536
|
-
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
|
|
1537
|
-
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
|
|
1538
|
-
});
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
async getChannel(type) {
|
|
1542
|
-
const channel = this.channels.find((c) => c.type === type);
|
|
1543
|
-
if (channel) return channel;
|
|
1544
|
-
else {
|
|
1545
|
-
const channels = [...this.channels, { type, ids: [] }];
|
|
1546
|
-
const route = Routes.guilds.get(this.id);
|
|
1547
|
-
const response = await this.rest.request({
|
|
1548
|
-
method: "PATCH",
|
|
1549
|
-
url: route,
|
|
1550
|
-
payload: { channels }
|
|
1551
|
-
});
|
|
1552
|
-
__privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1553
|
-
return response.channels.find((t) => t.type === type);
|
|
1554
|
-
}
|
|
1555
|
-
}
|
|
1556
|
-
async getPermission(type) {
|
|
1557
|
-
const permission = this.permissions.find((c) => c.type === type);
|
|
1558
|
-
if (permission) return permission;
|
|
1559
|
-
else {
|
|
1560
|
-
const permissions = [...this.permissions, { type, ids: [] }];
|
|
1561
|
-
const route = Routes.guilds.get(this.id);
|
|
1562
|
-
const response = await this.rest.request({
|
|
1563
|
-
method: "PATCH",
|
|
1564
|
-
url: route,
|
|
1565
|
-
payload: { permissions }
|
|
1566
|
-
});
|
|
1567
|
-
__privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1568
|
-
return response.permissions.find((t) => t.type === type);
|
|
1569
|
-
}
|
|
1570
|
-
}
|
|
1571
|
-
async createAdvert(data) {
|
|
1572
|
-
this.adverts.push(data);
|
|
1573
|
-
const route = Routes.guilds.get(this.id);
|
|
1574
|
-
const payload = { adverts: this.adverts };
|
|
1575
|
-
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
1576
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1577
|
-
}
|
|
1578
|
-
async removeAdvert(advertId) {
|
|
1579
|
-
const route = Routes.guilds.get(this.id);
|
|
1580
|
-
const payload = { adverts: this.adverts.filter((a) => a._id !== advertId) };
|
|
1581
|
-
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
1582
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1583
|
-
}
|
|
1584
|
-
async createCode(data) {
|
|
1585
|
-
this.codes.push(data);
|
|
1586
|
-
const route = Routes.guilds.get(this.id);
|
|
1587
|
-
const payload = { codes: this.codes };
|
|
1588
|
-
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
1589
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1590
|
-
}
|
|
1591
|
-
async removeCode(codeId) {
|
|
1592
|
-
const route = Routes.guilds.get(this.id);
|
|
1593
|
-
const payload = { codes: this.codes.filter((a) => a._id !== codeId) };
|
|
1594
|
-
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
1595
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1596
|
-
}
|
|
1597
|
-
async addIdToChannel(type, id) {
|
|
1598
|
-
const channel = this.channels.find((c) => c.type === type);
|
|
1599
|
-
const idsToAdd = Array.isArray(id) ? id : [id];
|
|
1600
|
-
if (!channel) {
|
|
1601
|
-
this.channels.push({ type, ids: [...idsToAdd] });
|
|
1602
|
-
} else {
|
|
1603
|
-
const chIndex = this.channels.findIndex((ch) => ch.type === type);
|
|
1604
|
-
const mergedIds = [.../* @__PURE__ */ new Set([...channel.ids || [], ...idsToAdd])];
|
|
1605
|
-
this.channels[chIndex] = { ...channel, ids: mergedIds };
|
|
1606
|
-
}
|
|
1607
|
-
const route = Routes.guilds.get(this.id);
|
|
1608
|
-
const payload = { channels: this.channels };
|
|
1609
|
-
const response = await this.rest.request({
|
|
1610
|
-
method: "PATCH",
|
|
1611
|
-
url: route,
|
|
1612
|
-
payload
|
|
1613
|
-
});
|
|
1614
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1615
|
-
}
|
|
1616
|
-
async setChannelIds(type, ...ids) {
|
|
1617
|
-
const channel = this.channels.find((c) => c.type === type);
|
|
1618
|
-
if (!ids || ids.length === 0) return;
|
|
1619
|
-
if (!channel) {
|
|
1620
|
-
this.channels.push({ type, ids });
|
|
1621
|
-
} else {
|
|
1622
|
-
const chIndex = this.channels.findIndex((ch) => ch.type === type);
|
|
1623
|
-
const mergedIds = [.../* @__PURE__ */ new Set([...ids])];
|
|
1624
|
-
this.channels[chIndex] = { ...channel, ids: mergedIds };
|
|
1625
|
-
}
|
|
1626
|
-
const route = Routes.guilds.get(this.id);
|
|
1627
|
-
const payload = { channels: this.channels };
|
|
1628
|
-
const response = await this.rest.request({
|
|
1629
|
-
method: "PATCH",
|
|
1630
|
-
url: route,
|
|
1631
|
-
payload
|
|
1632
|
-
});
|
|
1633
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1634
|
-
}
|
|
1635
|
-
async removeIdInChannel(type, id) {
|
|
1636
|
-
const chIndex = this.channels.findIndex((c) => c.type === type);
|
|
1637
|
-
if (chIndex !== -1) {
|
|
1638
|
-
const existing = this.channels[chIndex];
|
|
1639
|
-
const idsToRemove = Array.isArray(id) ? id : [id];
|
|
1640
|
-
existing.ids = existing.ids.filter((i) => !idsToRemove.includes(i));
|
|
1641
|
-
this.channels[chIndex] = existing;
|
|
1642
|
-
} else {
|
|
1643
|
-
this.channels.push({
|
|
1644
|
-
type,
|
|
1645
|
-
ids: []
|
|
1646
|
-
});
|
|
1647
|
-
}
|
|
1648
|
-
const route = Routes.guilds.get(this.id);
|
|
1649
|
-
const payload = { channels: this.channels };
|
|
1650
|
-
const response = await this.rest.request({
|
|
1651
|
-
method: "PATCH",
|
|
1652
|
-
url: route,
|
|
1653
|
-
payload
|
|
1654
|
-
});
|
|
1655
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1656
|
-
}
|
|
1657
|
-
async updateRouletteSettings(data) {
|
|
1658
|
-
const _data = {
|
|
1659
|
-
roulette_settings: {
|
|
1660
|
-
primary_color: !data.default ? data.primary_color || this.roulette_settings.primary_color || "#161616" : "#161616",
|
|
1661
|
-
secondary_color: !data.default ? data.secondary_color || this.roulette_settings.secondary_color || "#1A1A1A" : "#1A1A1A",
|
|
1662
|
-
tertiary_color: !data.default ? data.tertiary_color || this.roulette_settings.tertiary_color || "#2D2D2D" : "#2D2D2D",
|
|
1663
|
-
text_color: !data.default ? data.text_color || this.roulette_settings.text_color || "#ffffff" : "#ffffff",
|
|
1664
|
-
prizes: data.prizes || this.roulette_settings.prizes || []
|
|
1665
|
-
}
|
|
1666
|
-
};
|
|
1667
|
-
return this.update(_data);
|
|
1668
|
-
}
|
|
1669
|
-
getActive(key) {
|
|
1670
|
-
return this[key].cache.filter((o) => o.status === "created" || o.status === "on");
|
|
1671
|
-
}
|
|
1672
|
-
async addRoulettePrize(prize) {
|
|
1673
|
-
if (!prize.label) {
|
|
1674
|
-
throw new Error("Prize label is required");
|
|
1675
|
-
}
|
|
1676
|
-
const prizes = this.roulette_settings.prizes;
|
|
1677
|
-
const prizeIndex = prize._id ? prizes.findIndex((p) => p._id === prize._id) : prizes.findIndex((p) => p.label === prize.label);
|
|
1678
|
-
const defaultProbability = prizes.length > 0 ? 1 / prizes.length : 0.1;
|
|
1679
|
-
if (prizeIndex !== -1) {
|
|
1680
|
-
const existing = prizes[prizeIndex];
|
|
1681
|
-
prizes[prizeIndex] = {
|
|
1682
|
-
label: prize.label,
|
|
1683
|
-
custom_color: prize.custom_color ?? existing.custom_color,
|
|
1684
|
-
custom_probability: prize.custom_probability ?? existing.custom_probability ?? defaultProbability,
|
|
1685
|
-
_id: existing._id
|
|
1686
|
-
};
|
|
1687
|
-
} else {
|
|
1688
|
-
prizes.push({
|
|
1689
|
-
label: prize.label,
|
|
1690
|
-
custom_color: prize.custom_color ?? "",
|
|
1691
|
-
custom_probability: prize.custom_probability ?? defaultProbability
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
|
-
await this.updateRouletteSettings({ prizes });
|
|
1695
|
-
return this.roulette_settings.prizes.find((p) => p.label === prize.label);
|
|
1696
|
-
}
|
|
1697
|
-
async removeRoulettePrize(id) {
|
|
1698
|
-
let prizes = this.roulette_settings.prizes;
|
|
1699
|
-
if (!prizes.find((p) => p._id === id)) return this;
|
|
1700
|
-
prizes = prizes.filter((p) => p._id !== id);
|
|
1701
|
-
return this.updateRouletteSettings({ prizes });
|
|
1702
|
-
}
|
|
1703
|
-
async _start() {
|
|
1704
|
-
await Promise.all([
|
|
1705
|
-
this.users.fetch(),
|
|
1706
|
-
this.matches.fetch(),
|
|
1707
|
-
this.tickets.fetch(),
|
|
1708
|
-
this.vipMembers.fetch(),
|
|
1709
|
-
this.logEntries.fetch(),
|
|
1710
|
-
this.betusers.fetch(),
|
|
1711
|
-
this.bets.fetch(),
|
|
1712
|
-
this.mediators.fetch(),
|
|
1713
|
-
this.tournaments.fetch()
|
|
1714
|
-
]);
|
|
1715
|
-
return this;
|
|
1716
|
-
}
|
|
1717
|
-
async fetch() {
|
|
1718
|
-
const route = Routes.guilds.get(this.id);
|
|
1719
|
-
const response = await this.rest.request({
|
|
1720
|
-
method: "get",
|
|
1721
|
-
url: route
|
|
1722
|
-
});
|
|
1723
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1724
|
-
}
|
|
1725
|
-
async reset() {
|
|
1726
|
-
return this.update({ reset: true });
|
|
1727
|
-
}
|
|
1728
|
-
async update(data) {
|
|
1729
|
-
const route = Routes.guilds.get(this.id);
|
|
1730
|
-
const response = await this.rest.request({
|
|
1731
|
-
method: "patch",
|
|
1732
|
-
url: route,
|
|
1733
|
-
payload: data
|
|
1734
|
-
});
|
|
1735
|
-
return __privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1736
|
-
}
|
|
1737
|
-
async setStatus(key, status) {
|
|
1738
|
-
Assertion.assertString(key);
|
|
1739
|
-
this.status[key] = status;
|
|
1740
|
-
const route = Routes.guilds.resource(this.id, "status");
|
|
1741
|
-
const payload = { set: this.status };
|
|
1742
|
-
const response = await this.rest.request({
|
|
1743
|
-
method: "PATCH",
|
|
1744
|
-
url: route,
|
|
1745
|
-
payload
|
|
1746
|
-
});
|
|
1747
|
-
this.status = response.status;
|
|
1748
|
-
this.rest.guilds.cache.set(this.id, this);
|
|
1749
|
-
this.rest.emit("guildUpdate", this);
|
|
1750
|
-
return this;
|
|
1751
|
-
}
|
|
1752
|
-
async togglePrice(price) {
|
|
1753
|
-
Assertion.assertNumber(price);
|
|
1754
|
-
const includesPrice = this.prices.includes(price);
|
|
1755
|
-
if (includesPrice) this.prices = this.prices.filter((p) => p !== price);
|
|
1756
|
-
else this.prices.push(price);
|
|
1757
|
-
await this.update({ prices: this.prices });
|
|
1758
|
-
return this;
|
|
1759
|
-
}
|
|
1760
|
-
async addPrefix(prefixes) {
|
|
1761
|
-
const route = Routes.fields(Routes.guilds.resource(this.id, "prefixes"));
|
|
1762
|
-
const _p = Array.isArray(prefixes) ? prefixes : [prefixes];
|
|
1763
|
-
const payload = { set: [.../* @__PURE__ */ new Set([...this.prefixes, ..._p])] };
|
|
1764
|
-
const response = await this.rest.request({
|
|
1765
|
-
method: "PATCH",
|
|
1766
|
-
url: route,
|
|
1767
|
-
payload
|
|
1768
|
-
});
|
|
1769
|
-
__privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1770
|
-
return this;
|
|
1771
|
-
}
|
|
1772
|
-
async setPrefix(prefixes) {
|
|
1773
|
-
const route = Routes.fields(Routes.guilds.resource(this.id, "prefixes"));
|
|
1774
|
-
const payload = { set: Array.isArray(prefixes) ? prefixes : [prefixes] };
|
|
1775
|
-
const response = await this.rest.request({
|
|
1776
|
-
method: "PATCH",
|
|
1777
|
-
url: route,
|
|
1778
|
-
payload
|
|
1779
|
-
});
|
|
1780
|
-
__privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1781
|
-
return this;
|
|
1782
|
-
}
|
|
1783
|
-
async toggleDailyCategory(category) {
|
|
1784
|
-
Assertion.assertString(category);
|
|
1785
|
-
let categories = this.daily_categories;
|
|
1786
|
-
const returnCategories = () => {
|
|
1787
|
-
const isCategoryOn = categories.includes(category);
|
|
1788
|
-
if (isCategoryOn) categories = categories.filter((m) => m !== category);
|
|
1789
|
-
else categories = [...categories, category];
|
|
1790
|
-
return categories;
|
|
1791
|
-
};
|
|
1792
|
-
const _categories = returnCategories();
|
|
1793
|
-
const payload = { daily_categories: _categories };
|
|
1794
|
-
const route = Routes.guilds.get(this.id);
|
|
1795
|
-
const response = await this.rest.request({
|
|
1796
|
-
method: "patch",
|
|
1797
|
-
url: route,
|
|
1798
|
-
payload
|
|
1799
|
-
});
|
|
1800
|
-
__privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1801
|
-
return this;
|
|
1802
|
-
}
|
|
1803
|
-
async setScores(name, amount) {
|
|
1804
|
-
const route = Routes.guilds.get(this.id);
|
|
1805
|
-
let scores = this.scores;
|
|
1806
|
-
scores[name] = amount;
|
|
1807
|
-
const payload = { scores };
|
|
1808
|
-
const response = await this.rest.request({
|
|
1809
|
-
method: "patch",
|
|
1810
|
-
url: route,
|
|
1811
|
-
payload
|
|
1812
|
-
});
|
|
1813
|
-
__privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1814
|
-
return this;
|
|
1815
|
-
}
|
|
1816
|
-
async toggleMode(mode) {
|
|
1817
|
-
const route = Routes.guilds.get(this.id);
|
|
1818
|
-
let modes = this.modes;
|
|
1819
|
-
const returnModes = () => {
|
|
1820
|
-
const isModeOn = modes.on.includes(mode);
|
|
1821
|
-
if (isModeOn) {
|
|
1822
|
-
modes.on = modes.on.filter((m) => m !== mode);
|
|
1823
|
-
modes.off.push(mode);
|
|
1824
|
-
return modes;
|
|
1825
|
-
} else {
|
|
1826
|
-
modes.off = modes.off.filter((m) => m !== mode);
|
|
1827
|
-
modes.on.push(mode);
|
|
1828
|
-
return modes;
|
|
1829
|
-
}
|
|
1830
|
-
};
|
|
1831
|
-
const md = returnModes();
|
|
1832
|
-
const payload = { modes: md };
|
|
1833
|
-
const response = await this.rest.request({
|
|
1834
|
-
method: "patch",
|
|
1835
|
-
url: route,
|
|
1836
|
-
payload
|
|
1837
|
-
});
|
|
1838
|
-
__privateMethod(this, _Guild_instances, updateInternals_fn4).call(this, response);
|
|
1839
|
-
return this;
|
|
1840
|
-
}
|
|
1841
|
-
};
|
|
1842
|
-
_Guild_instances = new WeakSet();
|
|
1843
|
-
updateInternals_fn4 = function(data) {
|
|
1844
|
-
for (let key in data) {
|
|
1845
|
-
if (key === "id" || key === "createdAt") continue;
|
|
1846
|
-
if (key in this) {
|
|
1847
|
-
this[key] = data[key];
|
|
1848
|
-
}
|
|
1849
|
-
if (key === "adverts") {
|
|
1850
|
-
this.adverts = [];
|
|
1851
|
-
for (let _adv of data.adverts) {
|
|
1852
|
-
this.adverts.push({
|
|
1853
|
-
_id: _adv._id,
|
|
1854
|
-
admin_id: _adv.admin_id,
|
|
1855
|
-
points_to_remove: _adv.points_to_remove,
|
|
1856
|
-
role_id: _adv.role_id,
|
|
1857
|
-
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
|
|
1858
|
-
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
|
|
1859
|
-
});
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
if (key === "code") {
|
|
1863
|
-
this.codes = [];
|
|
1864
|
-
for (let _adv of data.codes) {
|
|
1865
|
-
this.codes.push({
|
|
1866
|
-
_id: _adv._id,
|
|
1867
|
-
admin_id: _adv.admin_id,
|
|
1868
|
-
type: _adv.type,
|
|
1869
|
-
add: _adv.add,
|
|
1870
|
-
code: _adv.code,
|
|
1871
|
-
expire: _adv.expire ? new Date(_adv.expire) : /* @__PURE__ */ new Date(),
|
|
1872
|
-
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
|
|
1873
|
-
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
|
|
1874
|
-
});
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
this.automaticMessagesManager.set(this.automatic_messages);
|
|
1879
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
1880
|
-
this.rest.guilds.cache.set(this.id, this);
|
|
1881
|
-
this.rest.emit("guildUpdate", this);
|
|
1882
|
-
return this;
|
|
1883
|
-
};
|
|
1884
|
-
|
|
1885
|
-
// src/managers/guild/GuildManager.ts
|
|
1886
|
-
var GuildManager = class {
|
|
1887
|
-
/**
|
|
1888
|
-
* Manage guilds with the given client
|
|
1889
|
-
* @param guilds An array of guilds
|
|
1890
|
-
* @param rest The rest client
|
|
1891
|
-
*/
|
|
1892
|
-
constructor(rest) {
|
|
1893
|
-
/** A cache of guilds */
|
|
1894
|
-
__publicField(this, "cache");
|
|
1895
|
-
/** The rest client */
|
|
1896
|
-
__publicField(this, "rest");
|
|
1897
|
-
this.cache = new Collection("guilds");
|
|
1898
|
-
this.rest = rest;
|
|
1899
|
-
}
|
|
1900
|
-
/**
|
|
1901
|
-
* Fetch a guild
|
|
1902
|
-
* @param id Id of the guild to fetch
|
|
1903
|
-
* @returns APIGuild
|
|
1904
|
-
*/
|
|
1905
|
-
async fetch(options) {
|
|
1906
|
-
if (options && options.cache) return this.cache;
|
|
1907
|
-
if (options && options.guildId) {
|
|
1908
|
-
const route2 = Routes.guilds.get(options.guildId);
|
|
1909
|
-
const response2 = await this.rest.request({
|
|
1910
|
-
method: "get",
|
|
1911
|
-
url: route2
|
|
1912
|
-
});
|
|
1913
|
-
const guild = new Guild3(response2, this.rest);
|
|
1914
|
-
await guild._start().then((g) => {
|
|
1915
|
-
this.cache.set(g.id, g);
|
|
1916
|
-
});
|
|
1917
|
-
this.cache.set(guild.id, guild);
|
|
1918
|
-
return guild;
|
|
1919
|
-
}
|
|
1920
|
-
const route = Routes.guilds.getAll();
|
|
1921
|
-
const response = await this.rest.request({
|
|
1922
|
-
method: "get",
|
|
1923
|
-
url: route
|
|
1924
|
-
});
|
|
1925
|
-
for (let _guild of response) {
|
|
1926
|
-
if (!_guild.id) continue;
|
|
1927
|
-
const guild = new Guild3(_guild, this.rest);
|
|
1928
|
-
await guild._start().then((g) => {
|
|
1929
|
-
this.cache.set(g.id, g);
|
|
1930
|
-
});
|
|
1931
|
-
}
|
|
1932
|
-
return this.cache;
|
|
1933
|
-
}
|
|
1934
|
-
async reset(guildId) {
|
|
1935
|
-
if (guildId) {
|
|
1936
|
-
return await this.cache.get(guildId).reset();
|
|
1937
|
-
}
|
|
1938
|
-
for (let [_, g] of this.cache) {
|
|
1939
|
-
await g.reset();
|
|
1940
|
-
}
|
|
1941
|
-
return this.cache;
|
|
1942
|
-
}
|
|
1943
|
-
async delete(options) {
|
|
1944
|
-
if (options && options.guildId) {
|
|
1945
|
-
Assertion.assertString(options.guildId);
|
|
1946
|
-
const route2 = Routes.guilds.delete(options.guildId);
|
|
1947
|
-
const guild = this.cache.get(options.guildId);
|
|
1948
|
-
this.rest.emit("guildDelete", guild);
|
|
1949
|
-
await this.rest.request({
|
|
1950
|
-
method: "DELETE",
|
|
1951
|
-
url: route2
|
|
1952
|
-
});
|
|
1953
|
-
this.cache.delete(options.guildId);
|
|
1954
|
-
return this.cache;
|
|
1955
|
-
}
|
|
1956
|
-
const route = Routes.guilds.deleteAll();
|
|
1957
|
-
this.rest.emit("guildsDelete", this.cache);
|
|
1958
|
-
const value = await this.rest.request({
|
|
1959
|
-
method: "DELETE",
|
|
1960
|
-
url: route
|
|
1961
|
-
});
|
|
1962
|
-
this.cache.clear();
|
|
1963
|
-
return value;
|
|
1964
|
-
}
|
|
1965
|
-
set(data) {
|
|
1966
|
-
if (!data) return this.cache;
|
|
1967
|
-
if (Array.isArray(data)) {
|
|
1968
|
-
for (let _guild of data) {
|
|
1969
|
-
const guild = new Guild3(_guild, this.rest);
|
|
1970
|
-
this.cache.set(guild.id, guild);
|
|
1971
|
-
}
|
|
1972
|
-
return this.cache;
|
|
1973
|
-
} else {
|
|
1974
|
-
const guild = new Guild3(data, this.rest);
|
|
1975
|
-
this.cache.set(guild.id, guild);
|
|
1976
|
-
return guild;
|
|
1977
|
-
}
|
|
1978
|
-
}
|
|
1979
|
-
};
|
|
1980
|
-
|
|
1981
|
-
// src/rest/REST.ts
|
|
1982
|
-
import_dotenv.default.config();
|
|
1983
|
-
var Reset = "\x1B[0m";
|
|
1984
|
-
var FgGreen = "\x1B[32m";
|
|
1985
|
-
var FgRed = "\x1B[31m";
|
|
1986
|
-
var FgBlue = "\x1B[34m";
|
|
1987
|
-
var FgCyan = "\x1B[36m";
|
|
1988
|
-
var REST2 = class extends import_events.default {
|
|
1989
|
-
/**
|
|
1990
|
-
*
|
|
1991
|
-
* @param key The unique key for he client
|
|
1992
|
-
*/
|
|
1993
|
-
constructor(options) {
|
|
1994
|
-
super({ captureRejections: true });
|
|
1995
|
-
/**
|
|
1996
|
-
* The unique key for client
|
|
1997
|
-
*/
|
|
1998
|
-
__publicField(this, "clientKey");
|
|
1999
|
-
__publicField(this, "authKey");
|
|
2000
|
-
__publicField(this, "guildId");
|
|
2001
|
-
/** The guild manager */
|
|
2002
|
-
__publicField(this, "guilds");
|
|
2003
|
-
__publicField(this, "minesGames");
|
|
2004
|
-
__publicField(this, "users");
|
|
2005
|
-
__publicField(this, "betusers");
|
|
2006
|
-
__publicField(this, "matches");
|
|
2007
|
-
__publicField(this, "bets");
|
|
2008
|
-
__publicField(this, "tickets");
|
|
2009
|
-
__publicField(this, "vipmembers");
|
|
2010
|
-
__publicField(this, "mediators");
|
|
2011
|
-
this.clientKey = options.clientKey ?? "";
|
|
2012
|
-
this.authKey = options.authKey ?? "";
|
|
2013
|
-
this.guildId = options.guildId ?? "";
|
|
2014
|
-
this.guilds = new GuildManager(this);
|
|
2015
|
-
this.minesGames = new MinesGameManager(this);
|
|
2016
|
-
this.users = new Collection("rest:users");
|
|
2017
|
-
this.matches = new Collection("rest:matches");
|
|
2018
|
-
this.bets = new Collection("rest:bets");
|
|
2019
|
-
this.betusers = new Collection("rest:betusers");
|
|
2020
|
-
this.tickets = new Collection("rest:tickets");
|
|
2021
|
-
this.vipmembers = new Collection("rest:vipmembers");
|
|
2022
|
-
this.mediators = new Collection("rest:mediators");
|
|
2023
|
-
this.setMaxListeners(999);
|
|
2024
|
-
}
|
|
2025
|
-
/** Initialize the caching sistem */
|
|
2026
|
-
async init() {
|
|
2027
|
-
if (!this.clientKey || !this.authKey || !this.guildId)
|
|
2028
|
-
throw new Error("Client key, auth key, and guildId is necessary");
|
|
2029
|
-
await Promise.all([this.guilds.fetch({ guildId: this.guildId }), this.minesGames.fetch()]);
|
|
2030
|
-
return this;
|
|
2031
|
-
}
|
|
2032
|
-
formatUrl(url) {
|
|
2033
|
-
return (url.endsWith("/") ? url.slice(0, url.length - 1) : url) ?? "/status";
|
|
2034
|
-
}
|
|
2035
|
-
/**
|
|
2036
|
-
* Request Data from a certain url
|
|
2037
|
-
* @param options
|
|
2038
|
-
* @returns
|
|
2039
|
-
*/
|
|
2040
|
-
async request(options) {
|
|
2041
|
-
let { method, url, payload } = options;
|
|
2042
|
-
Assertion.assertString(method);
|
|
2043
|
-
Assertion.assertString(this.clientKey);
|
|
2044
|
-
Assertion.assertString(url);
|
|
2045
|
-
url = this.formatUrl(Routes.base + url);
|
|
2046
|
-
const headers = new import_undici.Headers();
|
|
2047
|
-
headers.append("authorization", this.authKey);
|
|
2048
|
-
headers.append("client_key", this.clientKey);
|
|
2049
|
-
headers.append("Content-Type", "application/json");
|
|
2050
|
-
const before = Date.now();
|
|
2051
|
-
this.emit("debug", [`[Request] ${FgBlue}${method} ${FgCyan}${url}`, Reset].join("\n"));
|
|
2052
|
-
const body = { ...payload };
|
|
2053
|
-
const res = await (0, import_undici.request)(url, {
|
|
2054
|
-
method: method.toUpperCase(),
|
|
2055
|
-
headers,
|
|
2056
|
-
body: JSON.stringify(body)
|
|
2057
|
-
});
|
|
2058
|
-
const responseBody = await res.body.json();
|
|
2059
|
-
const { data, message } = responseBody;
|
|
2060
|
-
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
2061
|
-
if (!data || res.body.errored) {
|
|
2062
|
-
if (message) this.emit("debug", `${FgRed}${message}${Reset}`);
|
|
2063
|
-
this.emit("debug", `[No data]${FgGreen} ${(now - before) / 1e3}${Reset}`);
|
|
2064
|
-
return "No data available.";
|
|
2065
|
-
}
|
|
2066
|
-
if (message) this.emit("debug", `${FgRed}${message}${Reset}`);
|
|
2067
|
-
this.emit("debug", `[Request]${FgGreen} ${(now - before) / 1e3}s done.${Reset}`);
|
|
2068
|
-
return data;
|
|
2069
|
-
}
|
|
2070
|
-
async getStatus() {
|
|
2071
|
-
return await this.request({ method: "GET", url: "/status" });
|
|
2072
|
-
}
|
|
2073
|
-
emit(event, ...args) {
|
|
2074
|
-
return super.emit(event, ...args);
|
|
2075
|
-
}
|
|
2076
|
-
on(event, listener) {
|
|
2077
|
-
return super.on(event, listener);
|
|
2078
|
-
}
|
|
2079
|
-
once(event, listener) {
|
|
2080
|
-
return super.once(event, listener);
|
|
2081
|
-
}
|
|
2082
|
-
};
|
|
2083
|
-
|
|
2084
|
-
// src/structures/bet/GuildBet.ts
|
|
2085
|
-
var _GuildBet_instances, updateInternals_fn5;
|
|
2086
|
-
var GuildBet = class {
|
|
2087
|
-
constructor(data, manager) {
|
|
2088
|
-
__privateAdd(this, _GuildBet_instances);
|
|
2089
|
-
/** The bet's type */
|
|
2090
|
-
__publicField(this, "type");
|
|
2091
|
-
/** The bet's mode */
|
|
2092
|
-
__publicField(this, "mode");
|
|
2093
|
-
/** The bet's status */
|
|
2094
|
-
__publicField(this, "status");
|
|
2095
|
-
/** The bet's maximum size */
|
|
2096
|
-
__publicField(this, "maximumSize");
|
|
2097
|
-
/** The bet's price */
|
|
2098
|
-
__publicField(this, "price");
|
|
2099
|
-
/** The bet's players */
|
|
2100
|
-
__publicField(this, "players");
|
|
2101
|
-
__publicField(this, "teams");
|
|
2102
|
-
/** The bet's channel */
|
|
2103
|
-
__publicField(this, "channels");
|
|
2104
|
-
/** The bet's messages */
|
|
2105
|
-
__publicField(this, "messages");
|
|
2106
|
-
/** The id of the winner */
|
|
2107
|
-
__publicField(this, "winners");
|
|
2108
|
-
/** The id of the loser */
|
|
2109
|
-
__publicField(this, "losers");
|
|
2110
|
-
/** The bet's creator id */
|
|
2111
|
-
__publicField(this, "creatorId");
|
|
2112
|
-
/** The bet's mediator */
|
|
2113
|
-
__publicField(this, "mediatorId");
|
|
2114
|
-
/** The bet's confirmers */
|
|
2115
|
-
__publicField(this, "confirmed");
|
|
2116
|
-
/** Creation Date */
|
|
2117
|
-
__publicField(this, "createdAt");
|
|
2118
|
-
/** Updated Date */
|
|
2119
|
-
__publicField(this, "updatedAt");
|
|
2120
|
-
/** Bet's id */
|
|
2121
|
-
__publicField(this, "_id");
|
|
2122
|
-
__publicField(this, "queues");
|
|
2123
|
-
__publicField(this, "guild_id");
|
|
2124
|
-
__publicField(this, "rest");
|
|
2125
|
-
__publicField(this, "guild");
|
|
2126
|
-
__publicField(this, "manager");
|
|
2127
|
-
this.manager = manager;
|
|
2128
|
-
this.guild = manager.guild;
|
|
2129
|
-
this.rest = manager.rest;
|
|
2130
|
-
this._id = data?._id;
|
|
2131
|
-
this.guild_id = data?.guild_id;
|
|
2132
|
-
this.type = data?.type;
|
|
2133
|
-
this.mode = data?.mode;
|
|
2134
|
-
this.status = data?.status;
|
|
2135
|
-
this.maximumSize = data?.maximumSize;
|
|
2136
|
-
this.price = data?.price;
|
|
2137
|
-
this.teams = data?.teams;
|
|
2138
|
-
this.channels = data?.channels;
|
|
2139
|
-
this.players = new PlayerManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "players"));
|
|
2140
|
-
this.messages = new MessagesManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "messages"));
|
|
2141
|
-
this.winners = data?.winners;
|
|
2142
|
-
this.losers = data?.losers;
|
|
2143
|
-
this.creatorId = data?.creatorId;
|
|
2144
|
-
this.mediatorId = data?.mediatorId;
|
|
2145
|
-
this.confirmed = data?.confirmed;
|
|
2146
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
2147
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
2148
|
-
this.queues = [];
|
|
2149
|
-
for (let queue of data.queues ?? []) {
|
|
2150
|
-
this.queues.push({
|
|
2151
|
-
_id: queue?._id,
|
|
2152
|
-
type: queue?.type,
|
|
2153
|
-
players: queue?.players,
|
|
2154
|
-
updatedAt: queue?.updatedAt ? new Date(queue?.updatedAt) : /* @__PURE__ */ new Date(),
|
|
2155
|
-
createdAt: queue?.createdAt ? new Date(queue?.createdAt) : /* @__PURE__ */ new Date()
|
|
2156
|
-
});
|
|
2157
|
-
}
|
|
2158
|
-
if (data?.messages?.length !== 0) this.messages.set(data.messages);
|
|
2159
|
-
if (data?.players.length !== 0) this.players._set(data.players);
|
|
2160
|
-
}
|
|
2161
|
-
toString() {
|
|
2162
|
-
return this._id;
|
|
2163
|
-
}
|
|
2164
|
-
async fetch() {
|
|
2165
|
-
const route = Routes.guilds.bets.get(this.guild.id, this._id);
|
|
2166
|
-
const response = await this.rest.request({ url: route, method: "GET" });
|
|
2167
|
-
return __privateMethod(this, _GuildBet_instances, updateInternals_fn5).call(this, response);
|
|
2168
|
-
}
|
|
2169
|
-
async addPlayer(player, queue_type) {
|
|
2170
|
-
if (this.players.length === 2) return this;
|
|
2171
|
-
if (this.players.has(player.id)) return this;
|
|
2172
|
-
this.players.set(player.id, player);
|
|
2173
|
-
if (queue_type) {
|
|
2174
|
-
const queue = this.queues.find((q) => q.type === queue_type);
|
|
2175
|
-
if (!queue) return this;
|
|
2176
|
-
for (const q of this.queues) {
|
|
2177
|
-
q.players = q.players.filter((p) => p.id !== player.id);
|
|
2178
|
-
}
|
|
2179
|
-
if (!queue.players.some((p) => p.id === player.id)) {
|
|
2180
|
-
queue.players.push({ id: player.id });
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
return await this.update({
|
|
2184
|
-
players: this.players.toArray(),
|
|
2185
|
-
queues: this.queues
|
|
2186
|
-
});
|
|
2187
|
-
}
|
|
2188
|
-
async removePlayer(player) {
|
|
2189
|
-
if (!this.players.some((p) => p.id === player.id)) return this;
|
|
2190
|
-
let players = this.players.toArray();
|
|
2191
|
-
players = this.players.filter((p) => p.id !== player.id).toArray();
|
|
2192
|
-
for (const q of this.queues) {
|
|
2193
|
-
q.players = q.players.filter((p) => p.id !== player.id);
|
|
2194
|
-
}
|
|
2195
|
-
return await this.update({
|
|
2196
|
-
players,
|
|
2197
|
-
queues: this.queues
|
|
2198
|
-
});
|
|
2199
|
-
}
|
|
2200
|
-
async update(data) {
|
|
2201
|
-
const payload = data;
|
|
2202
|
-
const route = Routes.guilds.bets.update(this.guild.id, this._id);
|
|
2203
|
-
const response = await this.rest.request({ method: "patch", url: route, payload });
|
|
2204
|
-
return __privateMethod(this, _GuildBet_instances, updateInternals_fn5).call(this, response);
|
|
2205
|
-
}
|
|
2206
|
-
async delete() {
|
|
2207
|
-
const route = Routes.guilds.bets.delete(this.manager.guild.id, this._id);
|
|
2208
|
-
const response = await this.rest.request({
|
|
2209
|
-
method: "DELETE",
|
|
2210
|
-
url: route
|
|
2211
|
-
});
|
|
2212
|
-
this.rest.emit("betDelete", this);
|
|
2213
|
-
this.manager.cache.delete(this._id);
|
|
2214
|
-
return response;
|
|
2215
|
-
}
|
|
2216
|
-
toJSON() {
|
|
2217
|
-
let json = {};
|
|
2218
|
-
for (const [key, value] of Object.entries(this)) {
|
|
2219
|
-
const exclude = ["rest", "guild", "manager"];
|
|
2220
|
-
if (exclude.includes(key)) continue;
|
|
2221
|
-
if (typeof value !== "function") {
|
|
2222
|
-
json[key] = value;
|
|
2223
|
-
}
|
|
2224
|
-
}
|
|
2225
|
-
return {
|
|
2226
|
-
...json,
|
|
2227
|
-
messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : [],
|
|
2228
|
-
players: this.players.toArray()
|
|
2229
|
-
};
|
|
2230
|
-
}
|
|
2231
|
-
};
|
|
2232
|
-
_GuildBet_instances = new WeakSet();
|
|
2233
|
-
updateInternals_fn5 = function(data) {
|
|
2234
|
-
for (let key in data) {
|
|
2235
|
-
if (key === "_id" || key === "createdAt") continue;
|
|
2236
|
-
if (key === "messages") {
|
|
2237
|
-
this.messages.set(data[key]);
|
|
2238
|
-
continue;
|
|
2239
|
-
}
|
|
2240
|
-
if (key === "players") {
|
|
2241
|
-
this.players._set(data[key]);
|
|
2242
|
-
continue;
|
|
2243
|
-
}
|
|
2244
|
-
if (key in this) {
|
|
2245
|
-
this[key] = data[key];
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
if (data?.messages?.length !== 0) {
|
|
2249
|
-
if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
|
|
2250
|
-
else {
|
|
2251
|
-
this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
|
|
2252
|
-
this.messages.set(data.messages);
|
|
2253
|
-
}
|
|
2254
|
-
}
|
|
2255
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
2256
|
-
this.createdAt = new Date(data.createdAt);
|
|
2257
|
-
this.manager.set(this);
|
|
2258
|
-
return this;
|
|
2259
|
-
};
|
|
2260
|
-
|
|
2261
|
-
// src/structures/logentry/LogEntry.ts
|
|
2262
|
-
var _LogEntry_instances, updateInternals_fn6;
|
|
2263
|
-
var LogEntry = class {
|
|
2264
|
-
constructor(data, manager) {
|
|
2265
|
-
__privateAdd(this, _LogEntry_instances);
|
|
2266
|
-
__publicField(this, "_id");
|
|
2267
|
-
__publicField(this, "guild_id");
|
|
2268
|
-
__publicField(this, "user_id");
|
|
2269
|
-
__publicField(this, "admin_id");
|
|
2270
|
-
__publicField(this, "object_id");
|
|
2271
|
-
__publicField(this, "type");
|
|
2272
|
-
__publicField(this, "description");
|
|
2273
|
-
__publicField(this, "change");
|
|
2274
|
-
__publicField(this, "before");
|
|
2275
|
-
__publicField(this, "after");
|
|
2276
|
-
__publicField(this, "logs_channel_id");
|
|
2277
|
-
__publicField(this, "createdAt");
|
|
2278
|
-
__publicField(this, "updatedAt");
|
|
2279
|
-
__publicField(this, "manager");
|
|
2280
|
-
/** The given guild */
|
|
2281
|
-
__publicField(this, "guild");
|
|
2282
|
-
/** The rest client */
|
|
2283
|
-
__publicField(this, "rest");
|
|
2284
|
-
this.manager = manager;
|
|
2285
|
-
this.guild = manager.guild;
|
|
2286
|
-
this._id = data?._id;
|
|
2287
|
-
this.guild_id = data?.guild_id;
|
|
2288
|
-
this.user_id = data?.user_id;
|
|
2289
|
-
this.admin_id = data?.admin_id;
|
|
2290
|
-
this.object_id = data?.object_id;
|
|
2291
|
-
this.type = data?.type;
|
|
2292
|
-
this.description = data?.description;
|
|
2293
|
-
this.change = data?.change;
|
|
2294
|
-
this.before = data?.before;
|
|
2295
|
-
this.after = data?.after;
|
|
2296
|
-
this.logs_channel_id = data?.logs_channel_id;
|
|
2297
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
2298
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
2299
|
-
}
|
|
2300
|
-
async fetch() {
|
|
2301
|
-
const route = Routes.fields("guilds", this.guild.id, "logentries", this._id);
|
|
2302
|
-
const response = await this.rest.request({ url: route, method: "GET" });
|
|
2303
|
-
return __privateMethod(this, _LogEntry_instances, updateInternals_fn6).call(this, response);
|
|
2304
|
-
}
|
|
2305
|
-
toJSON() {
|
|
2306
|
-
const json = {};
|
|
2307
|
-
for (const [key, value] of Object.entries(this)) {
|
|
2308
|
-
if (typeof value !== "function") {
|
|
2309
|
-
json[key] = value;
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
return json;
|
|
2313
|
-
}
|
|
2314
|
-
};
|
|
2315
|
-
_LogEntry_instances = new WeakSet();
|
|
2316
|
-
updateInternals_fn6 = function(data) {
|
|
2317
|
-
for (let key in data) {
|
|
2318
|
-
if (key === "id" || key === "createdAt") continue;
|
|
2319
|
-
if (key in this) {
|
|
2320
|
-
this[key] = data[key];
|
|
2321
|
-
}
|
|
2322
|
-
}
|
|
2323
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
2324
|
-
this.manager.set(this);
|
|
2325
|
-
return this;
|
|
2326
|
-
};
|
|
2327
|
-
|
|
2328
|
-
// src/structures/match/GuildMatch.ts
|
|
2329
|
-
var _GuildMatch_instances, updateInternals_fn7;
|
|
2330
|
-
var _GuildMatch = class _GuildMatch {
|
|
2331
|
-
/**
|
|
2332
|
-
* GuildMatch match
|
|
2333
|
-
* @param data The match's data
|
|
2334
|
-
* @param guild The guild
|
|
2335
|
-
* @param rest The rest client
|
|
2336
|
-
*/
|
|
2337
|
-
constructor(data, manager) {
|
|
2338
|
-
__privateAdd(this, _GuildMatch_instances);
|
|
2339
|
-
__publicField(this, "_id");
|
|
2340
|
-
__publicField(this, "selections");
|
|
2341
|
-
/** Match's type */
|
|
2342
|
-
__publicField(this, "type");
|
|
2343
|
-
__publicField(this, "channels");
|
|
2344
|
-
__publicField(this, "guild_id");
|
|
2345
|
-
/** Match's status */
|
|
2346
|
-
__publicField(this, "status");
|
|
2347
|
-
/** Match's challenge */
|
|
2348
|
-
__publicField(this, "challenge");
|
|
2349
|
-
/** Match's players */
|
|
2350
|
-
__publicField(this, "players");
|
|
2351
|
-
__publicField(this, "teams");
|
|
2352
|
-
/** Match's winners */
|
|
2353
|
-
__publicField(this, "winners");
|
|
2354
|
-
/** Match's losers */
|
|
2355
|
-
__publicField(this, "losers");
|
|
2356
|
-
/** Match's maximum size */
|
|
2357
|
-
__publicField(this, "maximumSize");
|
|
2358
|
-
/** Match's kicked out */
|
|
2359
|
-
__publicField(this, "kickedOut");
|
|
2360
|
-
/** Match's confirmed */
|
|
2361
|
-
__publicField(this, "confirmed");
|
|
2362
|
-
/** Match's leaders */
|
|
2363
|
-
__publicField(this, "leaders");
|
|
2364
|
-
/** Match's creator id */
|
|
2365
|
-
__publicField(this, "creatorId");
|
|
2366
|
-
/** Match's room creator id */
|
|
2367
|
-
__publicField(this, "roomCreatorId");
|
|
2368
|
-
/** Creation Date */
|
|
2369
|
-
__publicField(this, "createdAt");
|
|
2370
|
-
/** Updated Date */
|
|
2371
|
-
__publicField(this, "updatedAt");
|
|
2372
|
-
__publicField(this, "messages");
|
|
2373
|
-
/** Match's id */
|
|
2374
|
-
__publicField(this, "mvps");
|
|
2375
|
-
__publicField(this, "manager");
|
|
2376
|
-
__publicField(this, "bet");
|
|
2377
|
-
__publicField(this, "admin_id");
|
|
2378
|
-
/** The given guild */
|
|
2379
|
-
__publicField(this, "guild");
|
|
2380
|
-
/** The rest client */
|
|
2381
|
-
__publicField(this, "rest");
|
|
2382
|
-
__publicField(this, "key");
|
|
2383
|
-
this._id = data?._id;
|
|
2384
|
-
this.guild_id = data?.guild_id;
|
|
2385
|
-
this.manager = manager;
|
|
2386
|
-
this.guild = manager.guild;
|
|
2387
|
-
this.rest = manager.rest;
|
|
2388
|
-
this.admin_id = data?.admin_id;
|
|
2389
|
-
this.challenge = data?.challenge;
|
|
2390
|
-
this.players = data?.players;
|
|
2391
|
-
this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
|
|
2392
|
-
this.channels = data?.channels;
|
|
2393
|
-
this.type = data?.type;
|
|
2394
|
-
this.status = data?.status;
|
|
2395
|
-
this.bet = this.guild.bets.cache.get(data?.bet?._id);
|
|
2396
|
-
this.mvps = data?.mvps;
|
|
2397
|
-
this.winners = data?.winners;
|
|
2398
|
-
this.losers = data?.losers;
|
|
2399
|
-
this.maximumSize = data?.maximumSize;
|
|
2400
|
-
this.kickedOut = data?.kickedOut;
|
|
2401
|
-
this.confirmed = data?.confirmed;
|
|
2402
|
-
this.teams = data?.teams;
|
|
2403
|
-
this.leaders = data?.leaders;
|
|
2404
|
-
this.creatorId = data?.creatorId;
|
|
2405
|
-
this.roomCreatorId = data?.roomCreatorId;
|
|
2406
|
-
this.selections = data?.selections;
|
|
2407
|
-
this.key = "matches";
|
|
2408
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
2409
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
2410
|
-
if (data?.messages?.length !== 0) this.messages.set(data.messages);
|
|
2411
|
-
}
|
|
2412
|
-
/**
|
|
2413
|
-
* Fetches the match
|
|
2414
|
-
* @returns New Instance of the match
|
|
2415
|
-
*/
|
|
2416
|
-
async fetch() {
|
|
2417
|
-
const route = Routes.guilds.matches.get(this.guild.id, this._id);
|
|
2418
|
-
const response = await this.rest.request({
|
|
2419
|
-
method: "get",
|
|
2420
|
-
url: route
|
|
2421
|
-
});
|
|
2422
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2423
|
-
}
|
|
2424
|
-
async addConfirmed(type, id) {
|
|
2425
|
-
const confirmed = this.confirmed.find((c) => c.type === type);
|
|
2426
|
-
const idsToAdd = Array.isArray(id) ? id : [id];
|
|
2427
|
-
if (!confirmed) {
|
|
2428
|
-
this.confirmed.push({ type, ids: [...idsToAdd], count: idsToAdd.length });
|
|
2429
|
-
} else {
|
|
2430
|
-
const chIndex = this.confirmed.findIndex((ch) => ch.type === type);
|
|
2431
|
-
const mergedIds = [.../* @__PURE__ */ new Set([...confirmed.ids || [], ...idsToAdd])];
|
|
2432
|
-
this.confirmed[chIndex] = { ...confirmed, ids: mergedIds, count: mergedIds.length };
|
|
2433
|
-
}
|
|
2434
|
-
return this.update({ confirmed: this.confirmed });
|
|
2435
|
-
}
|
|
2436
|
-
async setConfirmed(set) {
|
|
2437
|
-
Assertion.assertObject(set);
|
|
2438
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "confirmed");
|
|
2439
|
-
const response = await this.rest.request({
|
|
2440
|
-
method: "PATCH",
|
|
2441
|
-
url: route,
|
|
2442
|
-
payload: set
|
|
2443
|
-
});
|
|
2444
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2445
|
-
}
|
|
2446
|
-
async setStatus(status) {
|
|
2447
|
-
Assertion.assertString(status);
|
|
2448
|
-
const payload = { set: status.toLowerCase() };
|
|
2449
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "status");
|
|
2450
|
-
const response = await this.rest.request({
|
|
2451
|
-
method: "PATCH",
|
|
2452
|
-
url: route,
|
|
2453
|
-
payload
|
|
2454
|
-
});
|
|
2455
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2456
|
-
}
|
|
2457
|
-
async setWinners(players) {
|
|
2458
|
-
if (!Array.isArray(players)) players = [players];
|
|
2459
|
-
const payload = { set: players };
|
|
2460
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "winners");
|
|
2461
|
-
const response = await this.rest.request({
|
|
2462
|
-
method: "PATCH",
|
|
2463
|
-
url: route,
|
|
2464
|
-
payload
|
|
2465
|
-
});
|
|
2466
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2467
|
-
}
|
|
2468
|
-
async setLoser(players) {
|
|
2469
|
-
if (!Array.isArray(players)) players = [players];
|
|
2470
|
-
const payload = { set: players };
|
|
2471
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "losers");
|
|
2472
|
-
const response = await this.rest.request({
|
|
2473
|
-
method: "PATCH",
|
|
2474
|
-
url: route,
|
|
2475
|
-
payload
|
|
2476
|
-
});
|
|
2477
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2478
|
-
}
|
|
2479
|
-
async setMvps(...usersId) {
|
|
2480
|
-
const payload = { set: usersId };
|
|
2481
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "mvps");
|
|
2482
|
-
const response = await this.rest.request({
|
|
2483
|
-
method: "PATCH",
|
|
2484
|
-
url: route,
|
|
2485
|
-
payload
|
|
2486
|
-
});
|
|
2487
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2488
|
-
}
|
|
2489
|
-
async setRoomCreatorId(userId) {
|
|
2490
|
-
Assertion.assertString(userId);
|
|
2491
|
-
const payload = { set: userId };
|
|
2492
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "roomCreatorId");
|
|
2493
|
-
const response = await this.rest.request({
|
|
2494
|
-
method: "PATCH",
|
|
2495
|
-
url: route,
|
|
2496
|
-
payload
|
|
2497
|
-
});
|
|
2498
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2499
|
-
}
|
|
2500
|
-
async setRoomAdminId(userId) {
|
|
2501
|
-
Assertion.assertString(userId);
|
|
2502
|
-
const payload = { set: userId };
|
|
2503
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "admin_id");
|
|
2504
|
-
const response = await this.rest.request({
|
|
2505
|
-
method: "PATCH",
|
|
2506
|
-
url: route,
|
|
2507
|
-
payload
|
|
2508
|
-
});
|
|
2509
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2510
|
-
}
|
|
2511
|
-
async kick(player) {
|
|
2512
|
-
this.players = this.players.filter((p) => p.id !== player.id);
|
|
2513
|
-
this.leaders = this.leaders.filter((p) => p.id !== player.id);
|
|
2514
|
-
const teamIndex = this.teams.findIndex((t) => t.some((p) => p.id === player.id));
|
|
2515
|
-
if (teamIndex !== -1) {
|
|
2516
|
-
let team = this.teams.find((t) => t.some((p) => p.id === player.id));
|
|
2517
|
-
team = team.filter((p) => p.id === player.id);
|
|
2518
|
-
this.teams[teamIndex] = team;
|
|
2519
|
-
}
|
|
2520
|
-
return await this.update(this.toJSON());
|
|
2521
|
-
}
|
|
2522
|
-
async update(data) {
|
|
2523
|
-
const route = Routes.guilds.matches.get(this.guild.id, this._id);
|
|
2524
|
-
if (data?.bet && data?.bet instanceof GuildBet) {
|
|
2525
|
-
data.bet = data.bet.toJSON();
|
|
2526
|
-
}
|
|
2527
|
-
const response = await this.rest.request({
|
|
2528
|
-
method: "patch",
|
|
2529
|
-
url: route,
|
|
2530
|
-
payload: data
|
|
2531
|
-
});
|
|
2532
|
-
this.rest.emit("matchUpdate", this, new _GuildMatch(response, this.manager));
|
|
2533
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn7).call(this, response);
|
|
2534
|
-
}
|
|
2535
|
-
async delete() {
|
|
2536
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id);
|
|
2537
|
-
const response = await this.rest.request({
|
|
2538
|
-
method: "DELETE",
|
|
2539
|
-
url: route
|
|
2540
|
-
});
|
|
2541
|
-
this.manager.cache.delete(this?._id);
|
|
2542
|
-
this.rest.matches.delete(this?._id);
|
|
2543
|
-
return response;
|
|
2544
|
-
}
|
|
2545
|
-
toJSON() {
|
|
2546
|
-
let json = {};
|
|
2547
|
-
for (const [key, value] of Object.entries(this)) {
|
|
2548
|
-
const exclude = ["rest", "guilds", "guild", "manager"];
|
|
2549
|
-
if (exclude.includes(key)) continue;
|
|
2550
|
-
if (typeof value !== "function") {
|
|
2551
|
-
json[key] = value;
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
return {
|
|
2555
|
-
...json,
|
|
2556
|
-
messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : []
|
|
2557
|
-
};
|
|
2558
|
-
}
|
|
2559
|
-
};
|
|
2560
|
-
_GuildMatch_instances = new WeakSet();
|
|
2561
|
-
updateInternals_fn7 = async function(data) {
|
|
2562
|
-
if (!data) return;
|
|
2563
|
-
for (let key in data) {
|
|
2564
|
-
if (key === "id" || key === "createdAt" || key === "messages") continue;
|
|
2565
|
-
if (key in this) {
|
|
2566
|
-
this[key] = data[key];
|
|
2567
|
-
}
|
|
2568
|
-
if (key === "bet") {
|
|
2569
|
-
this.bet = this.guild.bets.set(data.bet);
|
|
2570
|
-
}
|
|
2571
|
-
}
|
|
2572
|
-
if (data?.messages?.length !== 0) {
|
|
2573
|
-
if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
|
|
2574
|
-
else {
|
|
2575
|
-
this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
|
|
2576
|
-
this.messages.set(data.messages);
|
|
2577
|
-
}
|
|
2578
|
-
}
|
|
2579
|
-
if (!(this.bet instanceof GuildBet) && data?.bet) {
|
|
2580
|
-
this.bet = this.guild.bets.cache.get(data._id) ?? await this.guild.bets.fetch({ betId: data?.bet?._id });
|
|
2581
|
-
}
|
|
2582
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
2583
|
-
this.manager.set(this);
|
|
2584
|
-
return this;
|
|
2585
|
-
};
|
|
2586
|
-
var GuildMatch = _GuildMatch;
|
|
2587
|
-
|
|
2588
|
-
// src/structures/user/GuildUser.ts
|
|
2589
|
-
var _GuildUser_instances, updateInternals_fn8;
|
|
2590
|
-
var _GuildUser = class _GuildUser {
|
|
2591
|
-
/**
|
|
2592
|
-
* Bet user
|
|
2593
|
-
* @param data The user's data
|
|
2594
|
-
* @param manager The manager
|
|
2595
|
-
* @param rest The rest client
|
|
2596
|
-
*/
|
|
2597
|
-
constructor(data, manager) {
|
|
2598
|
-
__privateAdd(this, _GuildUser_instances);
|
|
2599
|
-
/** User's id */
|
|
2600
|
-
__publicField(this, "id");
|
|
2601
|
-
__publicField(this, "guild_id");
|
|
2602
|
-
/** User's daily */
|
|
2603
|
-
__publicField(this, "daily");
|
|
2604
|
-
/** User's points */
|
|
2605
|
-
__publicField(this, "points");
|
|
2606
|
-
/** User's wins */
|
|
2607
|
-
__publicField(this, "wins");
|
|
2608
|
-
/** User's mvps */
|
|
2609
|
-
__publicField(this, "mvps");
|
|
2610
|
-
/** User's losses */
|
|
2611
|
-
__publicField(this, "losses");
|
|
2612
|
-
/** User's games */
|
|
2613
|
-
__publicField(this, "games");
|
|
2614
|
-
/** If user is blacklisted */
|
|
2615
|
-
__publicField(this, "blacklist");
|
|
2616
|
-
/** User's accessories such as double point */
|
|
2617
|
-
__publicField(this, "accessories");
|
|
2618
|
-
/** User's original channels */
|
|
2619
|
-
__publicField(this, "original_channels");
|
|
2620
|
-
__publicField(this, "profile");
|
|
2621
|
-
__publicField(this, "creations");
|
|
2622
|
-
/** User's items */
|
|
2623
|
-
__publicField(this, "adverts");
|
|
2624
|
-
__publicField(this, "spins");
|
|
2625
|
-
/** Creation Date */
|
|
2626
|
-
__publicField(this, "createdAt");
|
|
2627
|
-
/** Updated Date */
|
|
2628
|
-
__publicField(this, "updatedAt");
|
|
2629
|
-
/** The given manager */
|
|
2630
|
-
__publicField(this, "manager");
|
|
2631
|
-
/** The rest client */
|
|
2632
|
-
__publicField(this, "rest");
|
|
2633
|
-
this.id = data?.id;
|
|
2634
|
-
this.guild_id = data?.guild_id;
|
|
2635
|
-
this.manager = manager;
|
|
2636
|
-
this.rest = manager.rest;
|
|
2637
|
-
this.wins = data?.wins;
|
|
2638
|
-
this.losses = data?.losses;
|
|
2639
|
-
this.mvps = data?.mvps;
|
|
2640
|
-
this.points = data?.points;
|
|
2641
|
-
this.creations = data?.creations;
|
|
2642
|
-
this.spins = data.spins;
|
|
2643
|
-
this.daily = data?.daily;
|
|
2644
|
-
this.games = data?.games;
|
|
2645
|
-
this.blacklist = data?.blacklist;
|
|
2646
|
-
this.accessories = data?.accessories;
|
|
2647
|
-
this.original_channels = data?.original_channels;
|
|
2648
|
-
this.profile = data?.profile;
|
|
2649
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
2650
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
2651
|
-
this.adverts = [];
|
|
2652
|
-
for (let _adv of data?.adverts || []) {
|
|
2653
|
-
this.adverts.push({
|
|
2654
|
-
_id: _adv._id,
|
|
2655
|
-
admin_id: _adv.admin_id,
|
|
2656
|
-
role_id: _adv.role_id,
|
|
2657
|
-
reason: _adv.reason,
|
|
2658
|
-
points_removed: _adv.points_removed,
|
|
2659
|
-
proof: _adv.proof,
|
|
2660
|
-
proof_ext: _adv.proof_ext,
|
|
2661
|
-
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
|
|
2662
|
-
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
|
|
2663
|
-
});
|
|
2664
|
-
}
|
|
2665
|
-
}
|
|
2666
|
-
/** String representation of this user */
|
|
2667
|
-
toString() {
|
|
2668
|
-
return `<@${this.id}>`;
|
|
2669
|
-
}
|
|
2670
|
-
/**
|
|
2671
|
-
* Fetches the user
|
|
2672
|
-
* @returns New Instance of the user
|
|
2673
|
-
*/
|
|
2674
|
-
async fetch() {
|
|
2675
|
-
const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
2676
|
-
const response = await this.rest.request({
|
|
2677
|
-
method: "get",
|
|
2678
|
-
url: route
|
|
2679
|
-
});
|
|
2680
|
-
const user = new _GuildUser(response, this.manager);
|
|
2681
|
-
this.manager.cache.set(user.id, user);
|
|
2682
|
-
this.rest.users.set(user.id, user);
|
|
2683
|
-
return user;
|
|
2684
|
-
}
|
|
2685
|
-
/**
|
|
2686
|
-
* Set the user blacklist
|
|
2687
|
-
* @param value Value to set to
|
|
2688
|
-
* @returns GuildUser
|
|
2689
|
-
*/
|
|
2690
|
-
async setBlacklist(value) {
|
|
2691
|
-
const route = Routes.guilds.users.resource(this.manager.guild.id, this.id, "blacklist");
|
|
2692
|
-
const payload = { set: value };
|
|
2693
|
-
await this.rest.request({
|
|
2694
|
-
method: "patch",
|
|
2695
|
-
url: route,
|
|
2696
|
-
payload
|
|
2697
|
-
});
|
|
2698
|
-
this.blacklist = value;
|
|
2699
|
-
this.manager.cache.set(this.id, this);
|
|
2700
|
-
this.rest.users.set(this.id, this);
|
|
2701
|
-
return this;
|
|
2702
|
-
}
|
|
2703
|
-
async reset() {
|
|
2704
|
-
const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
2705
|
-
const payload = { reset: true };
|
|
2706
|
-
const response = await this.rest.request({
|
|
2707
|
-
method: "DELETE",
|
|
2708
|
-
url: route,
|
|
2709
|
-
payload
|
|
2710
|
-
});
|
|
2711
|
-
__privateMethod(this, _GuildUser_instances, updateInternals_fn8).call(this, response);
|
|
2712
|
-
return this;
|
|
2713
|
-
}
|
|
2714
|
-
async updateProfile(data) {
|
|
2715
|
-
const _data = {
|
|
2716
|
-
profile: {
|
|
2717
|
-
avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
|
|
2718
|
-
bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
|
|
2719
|
-
bio: data.bio || this.profile.bio || "Melhor da minha aldeia (use !bio para alterar)",
|
|
2720
|
-
name: data.name || this.profile.name || "",
|
|
2721
|
-
textColor: data.textColor || this.profile.textColor || "#ffffff",
|
|
2722
|
-
primaryColor: data.primaryColor || this.profile.primaryColor || "#272727",
|
|
2723
|
-
secondaryColor: data.secondaryColor || this.profile.secondaryColor || "#151515"
|
|
2724
|
-
}
|
|
2725
|
-
};
|
|
2726
|
-
const route = Routes.guilds.users.update(this.manager.guild.id, this.id);
|
|
2727
|
-
const response = await this.rest.request({
|
|
2728
|
-
method: "patch",
|
|
2729
|
-
url: route,
|
|
2730
|
-
payload: _data
|
|
2731
|
-
});
|
|
2732
|
-
__privateMethod(this, _GuildUser_instances, updateInternals_fn8).call(this, response);
|
|
2733
|
-
return this;
|
|
2734
|
-
}
|
|
2735
|
-
async addAdvert(data) {
|
|
2736
|
-
const route = Routes.guilds.users.resource(this.manager.guild.id, this.id, "adverts");
|
|
2737
|
-
const payload = data;
|
|
2738
|
-
const response = await this.rest.request({ method: "POST", url: route, payload });
|
|
2739
|
-
return __privateMethod(this, _GuildUser_instances, updateInternals_fn8).call(this, response);
|
|
2740
|
-
}
|
|
2741
|
-
async removeAdvert(advertId) {
|
|
2742
|
-
let advs = this.adverts;
|
|
2743
|
-
if (advertId) advs = advs.filter((a) => a._id !== advertId);
|
|
2744
|
-
else advs.pop();
|
|
2745
|
-
const payload = { adverts: advs };
|
|
2746
|
-
const route = Routes.guilds.users.update(this.manager.guild.id, this.id);
|
|
2747
|
-
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
2748
|
-
return __privateMethod(this, _GuildUser_instances, updateInternals_fn8).call(this, response);
|
|
2749
|
-
}
|
|
2750
|
-
/**
|
|
2751
|
-
* Update certain property
|
|
2752
|
-
* @param data The new data to update with
|
|
2753
|
-
* @returns
|
|
2754
|
-
*/
|
|
2755
|
-
async update(data) {
|
|
2756
|
-
if (!data?.type) data.type = "add";
|
|
2757
|
-
const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
2758
|
-
let payload = {};
|
|
2759
|
-
const numericFields = ["wins", "points", "losses", "mvps", "games", "creations", "spins"];
|
|
2760
|
-
const arrayFields = ["items", "original_channels", "adverts", "accessories"];
|
|
2761
|
-
if (data?.type === "add" || data?.type === "remove") {
|
|
2762
|
-
for (const key in data) {
|
|
2763
|
-
if (key === "type") continue;
|
|
2764
|
-
const value = data[key];
|
|
2765
|
-
if (numericFields.includes(key)) {
|
|
2766
|
-
const current = this[key] || 0;
|
|
2767
|
-
const num = value || 0;
|
|
2768
|
-
payload[key] = Math.max(0, data?.type === "add" ? current + num : current - num);
|
|
2769
|
-
} else if (key === "blacklist") {
|
|
2770
|
-
payload["blacklist"] = value;
|
|
2771
|
-
} else if (key === "profile") {
|
|
2772
|
-
payload["profile"] = value;
|
|
2773
|
-
} else if (arrayFields.includes(key)) {
|
|
2774
|
-
if (key === "original_channels") {
|
|
2775
|
-
const current2 = this.original_channels;
|
|
2776
|
-
const fromData = data["original_channels"];
|
|
2777
|
-
let channels = [];
|
|
2778
|
-
if (data?.type === "add") {
|
|
2779
|
-
const existingIds = new Set(current2.map((ch) => ch.matchId));
|
|
2780
|
-
channels = [...current2, ...fromData.filter((ch) => !existingIds.has(ch.matchId))];
|
|
2781
|
-
} else if (data?.type === "remove") {
|
|
2782
|
-
const idsToRemove = new Set(fromData.map((ch) => ch.matchId));
|
|
2783
|
-
channels = current2.filter((ch) => !idsToRemove.has(ch.matchId));
|
|
2784
|
-
}
|
|
2785
|
-
payload["original_channels"] = channels;
|
|
2786
|
-
continue;
|
|
2787
|
-
}
|
|
2788
|
-
const current = this[key];
|
|
2789
|
-
const incoming = value;
|
|
2790
|
-
payload[key] = data?.type === "add" ? [.../* @__PURE__ */ new Set([...current, ...incoming])] : current.filter((x) => !incoming.includes(x));
|
|
2791
|
-
}
|
|
2792
|
-
}
|
|
2793
|
-
}
|
|
2794
|
-
const response = await this.rest.request({
|
|
2795
|
-
method: "patch",
|
|
2796
|
-
url: route,
|
|
2797
|
-
payload
|
|
2798
|
-
});
|
|
2799
|
-
__privateMethod(this, _GuildUser_instances, updateInternals_fn8).call(this, response);
|
|
2800
|
-
return this;
|
|
2801
|
-
}
|
|
2802
|
-
async delete() {
|
|
2803
|
-
const route = Routes.guilds.users.delete(this.manager.guild.id, this.id);
|
|
2804
|
-
const response = await this.rest.request({
|
|
2805
|
-
method: "DELETE",
|
|
2806
|
-
url: route
|
|
2807
|
-
});
|
|
2808
|
-
this.rest.emit("userDelete", this);
|
|
2809
|
-
this.manager.cache.delete(this.id);
|
|
2810
|
-
return response;
|
|
2811
|
-
}
|
|
2812
|
-
toJSON() {
|
|
2813
|
-
let json = {};
|
|
2814
|
-
for (const [key, value] of Object.entries(this)) {
|
|
2815
|
-
const exclude = ["rest", "guilds", "guild", "manager"];
|
|
2816
|
-
if (exclude.includes(key)) continue;
|
|
2817
|
-
if (typeof value !== "function") {
|
|
2818
|
-
json[key] = value;
|
|
2819
|
-
}
|
|
2820
|
-
}
|
|
2821
|
-
return json;
|
|
2822
|
-
}
|
|
2823
|
-
};
|
|
2824
|
-
_GuildUser_instances = new WeakSet();
|
|
2825
|
-
updateInternals_fn8 = function(data) {
|
|
2826
|
-
for (let key in data) {
|
|
2827
|
-
if (key === "id" || key === "createdAt") continue;
|
|
2828
|
-
if (key in this) {
|
|
2829
|
-
this[key] = data[key];
|
|
2830
|
-
}
|
|
2831
|
-
if (key === "adverts") {
|
|
2832
|
-
this.adverts = [];
|
|
2833
|
-
for (let _adv of data.adverts) {
|
|
2834
|
-
this.adverts.push({
|
|
2835
|
-
_id: _adv._id,
|
|
2836
|
-
admin_id: _adv.admin_id,
|
|
2837
|
-
role_id: _adv.role_id,
|
|
2838
|
-
reason: _adv.reason,
|
|
2839
|
-
points_removed: _adv.points_removed,
|
|
2840
|
-
proof: _adv.proof,
|
|
2841
|
-
proof_ext: _adv.proof_ext,
|
|
2842
|
-
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
|
|
2843
|
-
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
|
|
2844
|
-
});
|
|
2845
|
-
}
|
|
2846
|
-
}
|
|
2847
|
-
}
|
|
2848
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
2849
|
-
this.createdAt = new Date(data.createdAt);
|
|
2850
|
-
this.manager.set(this);
|
|
2851
|
-
this.rest.emit("userUpdate", this);
|
|
2852
|
-
return this;
|
|
2853
|
-
};
|
|
2854
|
-
var GuildUser = _GuildUser;
|
|
2855
|
-
|
|
2856
|
-
// src/structures/vipmember/VipMember.ts
|
|
2857
|
-
var _VipMember_instances, updateData_fn;
|
|
2858
|
-
var _VipMember = class _VipMember {
|
|
2859
|
-
/**
|
|
2860
|
-
* Bet member
|
|
2861
|
-
* @param data The member's data
|
|
2862
|
-
* @param manager The manager
|
|
2863
|
-
* @param rest The rest client
|
|
2864
|
-
*/
|
|
2865
|
-
constructor(data, manager) {
|
|
2866
|
-
__privateAdd(this, _VipMember_instances);
|
|
2867
|
-
/** member's id */
|
|
2868
|
-
__publicField(this, "id");
|
|
2869
|
-
/** member name */
|
|
2870
|
-
__publicField(this, "name");
|
|
2871
|
-
/** Members's roleId */
|
|
2872
|
-
__publicField(this, "roleId");
|
|
2873
|
-
/** Members's voiceChannelId */
|
|
2874
|
-
__publicField(this, "voiceChannelId");
|
|
2875
|
-
/** Vip's type */
|
|
2876
|
-
__publicField(this, "type");
|
|
2877
|
-
/** Member's Guild Id */
|
|
2878
|
-
__publicField(this, "guild_id");
|
|
2879
|
-
__publicField(this, "duration");
|
|
2880
|
-
__publicField(this, "status");
|
|
2881
|
-
/** member's daily */
|
|
2882
|
-
__publicField(this, "createdAt");
|
|
2883
|
-
/** Updated Date */
|
|
2884
|
-
__publicField(this, "updatedAt");
|
|
2885
|
-
/** The given manager */
|
|
2886
|
-
__publicField(this, "manager");
|
|
2887
|
-
/** The rest client */
|
|
2888
|
-
__publicField(this, "rest");
|
|
2889
|
-
__publicField(this, "guild");
|
|
2890
|
-
this.name = data?.name;
|
|
2891
|
-
this.id = data?.id;
|
|
2892
|
-
this.manager = manager;
|
|
2893
|
-
this.rest = manager.rest;
|
|
2894
|
-
this.guild = manager.guild;
|
|
2895
|
-
this.duration = data?.duration ? new Date(data?.duration) : /* @__PURE__ */ new Date();
|
|
2896
|
-
this.status = data?.status;
|
|
2897
|
-
this.type = data?.type;
|
|
2898
|
-
this.roleId = data?.roleId;
|
|
2899
|
-
this.voiceChannelId = data?.voiceChannelId;
|
|
2900
|
-
this.guild_id = data?.guild_id;
|
|
2901
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
2902
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
2903
|
-
}
|
|
2904
|
-
/** String representation of this member */
|
|
2905
|
-
toString() {
|
|
2906
|
-
return `<@${this.id}>`;
|
|
2907
|
-
}
|
|
2908
|
-
/**
|
|
2909
|
-
* Fetches the member
|
|
2910
|
-
* @returns New Instance of the member
|
|
2911
|
-
*/
|
|
2912
|
-
async fetch() {
|
|
2913
|
-
const route = Routes.vipmembers.get(this.guild_id, this.id);
|
|
2914
|
-
const response = await this.rest.request({
|
|
2915
|
-
method: "get",
|
|
2916
|
-
url: route
|
|
2917
|
-
});
|
|
2918
|
-
const member = new _VipMember(response, this.manager);
|
|
2919
|
-
this.manager.cache.set(member.id, member);
|
|
2920
|
-
return member;
|
|
2921
|
-
}
|
|
2922
|
-
async reset() {
|
|
2923
|
-
const route = Routes.vipmembers.get(this.guild_id, this.id);
|
|
2924
|
-
const payload = { reset: true };
|
|
2925
|
-
const response = await this.rest.request({
|
|
2926
|
-
method: "DELETE",
|
|
2927
|
-
url: route,
|
|
2928
|
-
payload
|
|
2929
|
-
});
|
|
2930
|
-
__privateMethod(this, _VipMember_instances, updateData_fn).call(this, response);
|
|
2931
|
-
this.type = response.type;
|
|
2932
|
-
this.manager.set(response);
|
|
2933
|
-
return this;
|
|
2934
|
-
}
|
|
2935
|
-
/**
|
|
2936
|
-
* Update certain property
|
|
2937
|
-
* @param data The new data to update with
|
|
2938
|
-
* @returns
|
|
2939
|
-
*/
|
|
2940
|
-
async update(data) {
|
|
2941
|
-
const route = Routes.vipmembers.get(this.guild.id, this.id);
|
|
2942
|
-
const payload = data;
|
|
2943
|
-
const response = await this.rest.request({
|
|
2944
|
-
method: "patch",
|
|
2945
|
-
url: route,
|
|
2946
|
-
payload
|
|
2947
|
-
});
|
|
2948
|
-
for (const k in response) {
|
|
2949
|
-
if (k === "id") continue;
|
|
2950
|
-
if (Object.hasOwn(this, k)) {
|
|
2951
|
-
this[k] = response[k];
|
|
2952
|
-
}
|
|
2953
|
-
}
|
|
2954
|
-
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : /* @__PURE__ */ new Date();
|
|
2955
|
-
this.duration = response?.duration ? new Date(response?.duration) : /* @__PURE__ */ new Date();
|
|
2956
|
-
this.createdAt = response?.createdAt ? new Date(response?.createdAt) : /* @__PURE__ */ new Date();
|
|
2957
|
-
this.type = response.type;
|
|
2958
|
-
this.manager.cache.set(this.id, this);
|
|
2959
|
-
return this;
|
|
2960
|
-
}
|
|
2961
|
-
async delete() {
|
|
2962
|
-
const route = Routes.vipmembers.delete(this.guild_id, this.id);
|
|
2963
|
-
const response = await this.rest.request({
|
|
2964
|
-
method: "DELETE",
|
|
2965
|
-
url: route
|
|
2966
|
-
});
|
|
2967
|
-
this.manager.cache.delete(this.id);
|
|
2968
|
-
return response;
|
|
2969
|
-
}
|
|
2970
|
-
toJSON() {
|
|
2971
|
-
let json;
|
|
2972
|
-
for (const [key, value] of Object.entries(this)) {
|
|
2973
|
-
if (typeof value !== "function") {
|
|
2974
|
-
json[key] = value;
|
|
2975
|
-
}
|
|
2976
|
-
}
|
|
2977
|
-
return json;
|
|
2978
|
-
}
|
|
2979
|
-
};
|
|
2980
|
-
_VipMember_instances = new WeakSet();
|
|
2981
|
-
updateData_fn = function(data) {
|
|
2982
|
-
for (const k in data) {
|
|
2983
|
-
if (k === "id") continue;
|
|
2984
|
-
if (Object.hasOwn(this, k)) {
|
|
2985
|
-
this[k] = data[k];
|
|
2986
|
-
this.data[k] = data[k];
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
};
|
|
2990
|
-
var VipMember = _VipMember;
|
|
2991
|
-
|
|
2992
|
-
// src/structures/ticket/Ticket.ts
|
|
2993
|
-
var _GuildTicket_instances, updateInternals_fn9;
|
|
2994
|
-
var GuildTicket = class {
|
|
2995
|
-
constructor(data, manager) {
|
|
2996
|
-
__privateAdd(this, _GuildTicket_instances);
|
|
2997
|
-
__publicField(this, "_id");
|
|
2998
|
-
__publicField(this, "guild_id");
|
|
2999
|
-
__publicField(this, "type");
|
|
3000
|
-
__publicField(this, "status");
|
|
3001
|
-
__publicField(this, "admin_id");
|
|
3002
|
-
__publicField(this, "channel_id");
|
|
3003
|
-
__publicField(this, "closed_by_id");
|
|
3004
|
-
__publicField(this, "creator_id");
|
|
3005
|
-
__publicField(this, "customer_rating");
|
|
3006
|
-
__publicField(this, "messages");
|
|
3007
|
-
__publicField(this, "createdAt");
|
|
3008
|
-
__publicField(this, "updatedAt");
|
|
3009
|
-
__publicField(this, "rest");
|
|
3010
|
-
__publicField(this, "guild");
|
|
3011
|
-
__publicField(this, "manager");
|
|
3012
|
-
this.manager = manager;
|
|
3013
|
-
this.guild = manager.guild;
|
|
3014
|
-
this.rest = manager.rest;
|
|
3015
|
-
this._id = data?._id;
|
|
3016
|
-
this.type = data?.type;
|
|
3017
|
-
this.admin_id = data?.admin_id;
|
|
3018
|
-
this.guild_id = data?.guild_id;
|
|
3019
|
-
this.channel_id = data?.channel_id;
|
|
3020
|
-
this.creator_id = data?.creator_id;
|
|
3021
|
-
this.status = data?.status;
|
|
3022
|
-
this.customer_rating = data?.customer_rating;
|
|
3023
|
-
this.messages = data?.messages;
|
|
3024
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
3025
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
3026
|
-
}
|
|
3027
|
-
async fetch() {
|
|
3028
|
-
const route = Routes.guilds.tickets.get(this.guild.id, this._id);
|
|
3029
|
-
const response = await this.rest.request({
|
|
3030
|
-
method: "GET",
|
|
3031
|
-
url: route
|
|
3032
|
-
});
|
|
3033
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn9).call(this, response);
|
|
3034
|
-
}
|
|
3035
|
-
async setCustomerRating(rating) {
|
|
3036
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "customer_rating");
|
|
3037
|
-
const payload = { set: rating };
|
|
3038
|
-
const response = await this.rest.request({
|
|
3039
|
-
method: "PATCH",
|
|
3040
|
-
url: route,
|
|
3041
|
-
payload
|
|
3042
|
-
});
|
|
3043
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn9).call(this, response);
|
|
3044
|
-
}
|
|
3045
|
-
async setAdminId(id) {
|
|
3046
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "admin_id");
|
|
3047
|
-
const payload = { set: id };
|
|
3048
|
-
const response = await this.rest.request({
|
|
3049
|
-
method: "PATCH",
|
|
3050
|
-
url: route,
|
|
3051
|
-
payload
|
|
3052
|
-
});
|
|
3053
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn9).call(this, response);
|
|
3054
|
-
}
|
|
3055
|
-
async setChannelId(id) {
|
|
3056
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "channel_id");
|
|
3057
|
-
const payload = { set: id };
|
|
3058
|
-
const response = await this.rest.request({
|
|
3059
|
-
method: "PATCH",
|
|
3060
|
-
url: route,
|
|
3061
|
-
payload
|
|
3062
|
-
});
|
|
3063
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn9).call(this, response);
|
|
3064
|
-
}
|
|
3065
|
-
async setClosedById(id) {
|
|
3066
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "closed_by_id");
|
|
3067
|
-
const payload = { set: id };
|
|
3068
|
-
const response = await this.rest.request({
|
|
3069
|
-
method: "PATCH",
|
|
3070
|
-
url: route,
|
|
3071
|
-
payload
|
|
3072
|
-
});
|
|
3073
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn9).call(this, response);
|
|
3074
|
-
}
|
|
3075
|
-
async setStatus(status) {
|
|
3076
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "status");
|
|
3077
|
-
const payload = { set: status };
|
|
3078
|
-
const response = await this.rest.request({
|
|
3079
|
-
method: "PATCH",
|
|
3080
|
-
url: route,
|
|
3081
|
-
payload
|
|
3082
|
-
});
|
|
3083
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn9).call(this, response);
|
|
3084
|
-
}
|
|
3085
|
-
async addMessage(message) {
|
|
3086
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "messages");
|
|
3087
|
-
const payload = { set: [...this.messages, message] };
|
|
3088
|
-
const response = await this.rest.request({
|
|
3089
|
-
method: "PATCH",
|
|
3090
|
-
url: route,
|
|
3091
|
-
payload
|
|
3092
|
-
});
|
|
3093
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn9).call(this, response);
|
|
3094
|
-
}
|
|
3095
|
-
};
|
|
3096
|
-
_GuildTicket_instances = new WeakSet();
|
|
3097
|
-
updateInternals_fn9 = function(data) {
|
|
3098
|
-
for (let key in data) {
|
|
3099
|
-
if (key === "id" || key === "createdAt") continue;
|
|
3100
|
-
if (key in this) {
|
|
3101
|
-
this[key] = data[key];
|
|
3102
|
-
}
|
|
3103
|
-
}
|
|
3104
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
3105
|
-
this.createdAt = new Date(data.createdAt);
|
|
3106
|
-
this.manager.set(this);
|
|
3107
|
-
return this;
|
|
3108
|
-
};
|
|
3109
|
-
|
|
3110
|
-
// src/structures/minesgame/MinesGame.ts
|
|
3111
|
-
var _MinesGame_instances, updateInternals_fn10;
|
|
3112
|
-
var MinesGame = class {
|
|
3113
|
-
constructor(data, manager) {
|
|
3114
|
-
__privateAdd(this, _MinesGame_instances);
|
|
3115
|
-
__publicField(this, "guild_id");
|
|
3116
|
-
__publicField(this, "_id");
|
|
3117
|
-
__publicField(this, "creatorId");
|
|
3118
|
-
__publicField(this, "maxMines");
|
|
3119
|
-
__publicField(this, "bombs");
|
|
3120
|
-
__publicField(this, "bombsPosition");
|
|
3121
|
-
__publicField(this, "bet");
|
|
3122
|
-
__publicField(this, "multiplier");
|
|
3123
|
-
__publicField(this, "status");
|
|
3124
|
-
__publicField(this, "createdAt");
|
|
3125
|
-
__publicField(this, "updatedAt");
|
|
3126
|
-
__publicField(this, "rest");
|
|
3127
|
-
__publicField(this, "manager");
|
|
3128
|
-
this.manager = manager;
|
|
3129
|
-
this.rest = manager.rest;
|
|
3130
|
-
this.guild_id = data?.guild_id;
|
|
3131
|
-
this.bombsPosition = data?.bombsPosition;
|
|
3132
|
-
this._id = data?._id;
|
|
3133
|
-
this.multiplier = data?.multiplier;
|
|
3134
|
-
this.creatorId = data?.creatorId;
|
|
3135
|
-
this.maxMines = data?.maxMines;
|
|
3136
|
-
this.bombs = data?.bombs;
|
|
3137
|
-
this.bet = data?.bet;
|
|
3138
|
-
this.status = data?.status;
|
|
3139
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
3140
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
3141
|
-
}
|
|
3142
|
-
async fetch() {
|
|
3143
|
-
const route = `/${Routes.fields("minesgames", this._id)}`;
|
|
3144
|
-
const response = await this.rest.request({
|
|
3145
|
-
method: "GET",
|
|
3146
|
-
url: route
|
|
3147
|
-
});
|
|
3148
|
-
return __privateMethod(this, _MinesGame_instances, updateInternals_fn10).call(this, response);
|
|
3149
|
-
}
|
|
3150
|
-
async delete() {
|
|
3151
|
-
const route = `/${Routes.fields("minesgames", this._id)}`;
|
|
3152
|
-
const response = await this.rest.request({
|
|
3153
|
-
method: "delete",
|
|
3154
|
-
url: route
|
|
3155
|
-
});
|
|
3156
|
-
return __privateMethod(this, _MinesGame_instances, updateInternals_fn10).call(this, response);
|
|
3157
|
-
}
|
|
3158
|
-
async update(data) {
|
|
3159
|
-
const route = `/${Routes.fields("minesgames", this._id)}`;
|
|
3160
|
-
const response = await this.rest.request({
|
|
3161
|
-
method: "PATCH",
|
|
3162
|
-
url: route,
|
|
3163
|
-
payload: data
|
|
3164
|
-
});
|
|
3165
|
-
return __privateMethod(this, _MinesGame_instances, updateInternals_fn10).call(this, response);
|
|
3166
|
-
}
|
|
3167
|
-
};
|
|
3168
|
-
_MinesGame_instances = new WeakSet();
|
|
3169
|
-
updateInternals_fn10 = function(data) {
|
|
3170
|
-
for (let key in data) {
|
|
3171
|
-
if (key === "id" || key === "createdAt") continue;
|
|
3172
|
-
if (key in this) {
|
|
3173
|
-
this[key] = data[key];
|
|
3174
|
-
}
|
|
3175
|
-
}
|
|
3176
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
3177
|
-
this.manager.set(this);
|
|
3178
|
-
return this;
|
|
3179
|
-
};
|
|
3180
|
-
|
|
3181
|
-
// src/structures/automaticmessage/AutomaticMessage.ts
|
|
3182
|
-
var _AutomaticMessage_instances, updateInternals_fn11;
|
|
3183
|
-
var AutomaticMessage = class {
|
|
3184
|
-
constructor(data, manager) {
|
|
3185
|
-
__privateAdd(this, _AutomaticMessage_instances);
|
|
3186
|
-
__publicField(this, "id");
|
|
3187
|
-
__publicField(this, "type");
|
|
3188
|
-
__publicField(this, "admin_id");
|
|
3189
|
-
__publicField(this, "channel_ids");
|
|
3190
|
-
__publicField(this, "content");
|
|
3191
|
-
__publicField(this, "embeds");
|
|
3192
|
-
__publicField(this, "components");
|
|
3193
|
-
__publicField(this, "attachments");
|
|
3194
|
-
__publicField(this, "flags");
|
|
3195
|
-
__publicField(this, "interval_ms");
|
|
3196
|
-
__publicField(this, "createdAt");
|
|
3197
|
-
__publicField(this, "updatedAt");
|
|
3198
|
-
__publicField(this, "guild");
|
|
3199
|
-
__publicField(this, "manager");
|
|
3200
|
-
__publicField(this, "rest");
|
|
3201
|
-
this.manager = manager;
|
|
3202
|
-
this.guild = manager.guild;
|
|
3203
|
-
this.rest = manager.rest;
|
|
3204
|
-
this.id = data?.id;
|
|
3205
|
-
this.type = data?.type;
|
|
3206
|
-
this.admin_id = data?.admin_id;
|
|
3207
|
-
this.channel_ids = data?.channel_ids;
|
|
3208
|
-
this.content = data?.content;
|
|
3209
|
-
this.embeds = data?.embeds;
|
|
3210
|
-
this.components = data?.components;
|
|
3211
|
-
this.attachments = data?.attachments;
|
|
3212
|
-
this.flags = data?.flags;
|
|
3213
|
-
this.interval_ms = data?.interval_ms;
|
|
3214
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
3215
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
3216
|
-
}
|
|
3217
|
-
async fetch() {
|
|
3218
|
-
return this.manager.fetch(this.id);
|
|
3219
|
-
}
|
|
3220
|
-
async addChannelId(...id) {
|
|
3221
|
-
const ids = [.../* @__PURE__ */ new Set([...this.channel_ids, ...id])];
|
|
3222
|
-
return this.update({ channel_ids: ids });
|
|
3223
|
-
}
|
|
3224
|
-
async removeChannelId(...id) {
|
|
3225
|
-
const remove = new Set(id);
|
|
3226
|
-
const ids = this.channel_ids.filter((i) => !remove.has(i));
|
|
3227
|
-
return this.update({ channel_ids: ids });
|
|
3228
|
-
}
|
|
3229
|
-
async update(data) {
|
|
3230
|
-
this.manager.cache.set(this.id, { ...this, ...data, id: this.id });
|
|
3231
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
3232
|
-
const response = await this.rest.request({
|
|
3233
|
-
method: "patch",
|
|
3234
|
-
url: route,
|
|
3235
|
-
payload: { automatic_messages: this.manager.toJSON() }
|
|
3236
|
-
});
|
|
3237
|
-
return __privateMethod(this, _AutomaticMessage_instances, updateInternals_fn11).call(this, response);
|
|
3238
|
-
}
|
|
3239
|
-
async delete() {
|
|
3240
|
-
this.manager.cache.delete(this.id);
|
|
3241
|
-
this.guild.automatic_messages = this.manager.cache.toArray();
|
|
3242
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
3243
|
-
const response = await this.rest.request({
|
|
3244
|
-
method: "patch",
|
|
3245
|
-
url: route,
|
|
3246
|
-
payload: { automatic_messages: this.manager.toJSON() }
|
|
3247
|
-
});
|
|
3248
|
-
return this.manager.set(response.automatic_messages);
|
|
3249
|
-
}
|
|
3250
|
-
toJSON() {
|
|
3251
|
-
return {
|
|
3252
|
-
id: this.id,
|
|
3253
|
-
type: this.type,
|
|
3254
|
-
admin_id: this.admin_id,
|
|
3255
|
-
attachments: this.attachments,
|
|
3256
|
-
channel_ids: this.channel_ids,
|
|
3257
|
-
content: this.content,
|
|
3258
|
-
embeds: this.embeds,
|
|
3259
|
-
flags: this.flags,
|
|
3260
|
-
interval_ms: this.interval_ms,
|
|
3261
|
-
components: this.components,
|
|
3262
|
-
createdAt: this.createdAt,
|
|
3263
|
-
updatedAt: this.updatedAt
|
|
3264
|
-
};
|
|
3265
|
-
}
|
|
3266
|
-
};
|
|
3267
|
-
_AutomaticMessage_instances = new WeakSet();
|
|
3268
|
-
updateInternals_fn11 = function(data) {
|
|
3269
|
-
const _this = data?.automatic_messages?.find((m) => m.id === this.id);
|
|
3270
|
-
for (let key in _this) {
|
|
3271
|
-
if (key === "id" || key === "createdAt") continue;
|
|
3272
|
-
if (key in this) {
|
|
3273
|
-
this[key] = _this[key];
|
|
3274
|
-
}
|
|
3275
|
-
}
|
|
3276
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
3277
|
-
this.createdAt = new Date(data.createdAt);
|
|
3278
|
-
this.manager._add(data.automatic_messages);
|
|
3279
|
-
return this;
|
|
3280
|
-
};
|
|
3281
|
-
|
|
3282
|
-
// src/utils/randomKeyGenerator.ts
|
|
3283
|
-
var import_crypto = require("crypto");
|
|
3284
|
-
function randomKeyGenerator(max, enconding) {
|
|
3285
|
-
return (0, import_crypto.randomBytes)(24).toString(enconding ?? "base64").slice(0, max || 24).toUpperCase();
|
|
3286
|
-
}
|
|
3287
|
-
|
|
3288
|
-
// src/managers/automaticmessage/AutomaticMessageManager.ts
|
|
3289
|
-
var AutomaticMessageManager = class extends BaseManager {
|
|
3290
|
-
constructor(guild) {
|
|
3291
|
-
super(guild);
|
|
3292
|
-
this.guild = guild;
|
|
3293
|
-
this.rest = guild.rest;
|
|
3294
|
-
this.base_url = Routes.guilds.resource(guild.id);
|
|
3295
|
-
this.cache = new Collection();
|
|
3296
|
-
if (guild.automatic_messages && guild.automatic_messages.length !== 0) this.set(guild.automatic_messages);
|
|
3297
|
-
else this.guild.automatic_messages = [];
|
|
3298
|
-
}
|
|
3299
|
-
async fetch(messageId) {
|
|
3300
|
-
const route = this.base_url;
|
|
3301
|
-
const response = await this.rest.request({
|
|
3302
|
-
method: "get",
|
|
3303
|
-
url: route
|
|
3304
|
-
});
|
|
3305
|
-
this._add(response.automatic_messages);
|
|
3306
|
-
return this.cache;
|
|
3307
|
-
}
|
|
3308
|
-
async create(data) {
|
|
3309
|
-
if (!data.type) throw new Error(`Missing message's type.`);
|
|
3310
|
-
const id = randomKeyGenerator(9).replace(/-/g, "0").replace(/_/g, "Y");
|
|
3311
|
-
const m = { ...data, id };
|
|
3312
|
-
this.guild.automatic_messages.push(m);
|
|
3313
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
3314
|
-
const response = await this.rest.request({
|
|
3315
|
-
method: "patch",
|
|
3316
|
-
url: route,
|
|
3317
|
-
payload: { automatic_messages: this.guild.automatic_messages }
|
|
3318
|
-
});
|
|
3319
|
-
return this._add(response.automatic_messages).find((m2) => m2.id === id);
|
|
3320
|
-
}
|
|
3321
|
-
_add(data) {
|
|
3322
|
-
if (Array.isArray(data)) {
|
|
3323
|
-
for (let _m of data) {
|
|
3324
|
-
if (!_m.id) continue;
|
|
3325
|
-
if (_m instanceof AutomaticMessage) this.cache.set(_m.id, _m);
|
|
3326
|
-
else this.cache.set(_m.id, new AutomaticMessage(_m, this));
|
|
3327
|
-
}
|
|
3328
|
-
} else {
|
|
3329
|
-
if (!data.id) return this.cache;
|
|
3330
|
-
if (data instanceof AutomaticMessage) this.cache.set(data.id, data);
|
|
3331
|
-
else this.cache.set(data.id, new AutomaticMessage(data, this));
|
|
3332
|
-
}
|
|
3333
|
-
this.guild.automatic_messages = this.cache.toArray();
|
|
3334
|
-
return this.cache;
|
|
3335
|
-
}
|
|
3336
|
-
set(data) {
|
|
3337
|
-
this.cache.clear();
|
|
3338
|
-
if (Array.isArray(data)) {
|
|
3339
|
-
for (let _m of data) {
|
|
3340
|
-
if (!_m.id) continue;
|
|
3341
|
-
if (_m instanceof AutomaticMessage) this.cache.set(_m.id, _m);
|
|
3342
|
-
else this.cache.set(_m.id, new AutomaticMessage(_m, this));
|
|
3343
|
-
}
|
|
3344
|
-
} else {
|
|
3345
|
-
if (!data.id) return this.cache;
|
|
3346
|
-
if (data instanceof AutomaticMessage) this.cache.set(data.id, data);
|
|
3347
|
-
else this.cache.set(data.id, new AutomaticMessage(data, this));
|
|
3348
|
-
}
|
|
3349
|
-
return this.cache;
|
|
3350
|
-
}
|
|
3351
|
-
async delete(messageId) {
|
|
3352
|
-
if (messageId) return await this.cache.get(messageId).delete();
|
|
3353
|
-
this.cache.clear();
|
|
3354
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
3355
|
-
const response = await this.rest.request({
|
|
3356
|
-
method: "patch",
|
|
3357
|
-
url: route,
|
|
3358
|
-
payload: { automatic_messages: [] }
|
|
3359
|
-
});
|
|
3360
|
-
return response;
|
|
3361
|
-
}
|
|
3362
|
-
toJSON() {
|
|
3363
|
-
[...this.cache.values()].map((m) => console.log(m instanceof AutomaticMessage));
|
|
3364
|
-
return this.cache.toArray();
|
|
3365
|
-
}
|
|
3366
|
-
};
|
|
3367
|
-
|
|
3368
|
-
// src/managers/bet/GuildBetManager.ts
|
|
3369
|
-
var GuildBetManager = class extends BaseManager {
|
|
3370
|
-
constructor(guild) {
|
|
3371
|
-
super(guild);
|
|
3372
|
-
this.guild = guild;
|
|
3373
|
-
this.rest = guild.rest;
|
|
3374
|
-
this.base_url = Routes.guilds.bets.getAll(guild.id);
|
|
3375
|
-
this.cache = new Collection("bets");
|
|
3376
|
-
}
|
|
3377
|
-
toString() {
|
|
3378
|
-
return this.cache.size;
|
|
3379
|
-
}
|
|
3380
|
-
async fetch(options) {
|
|
3381
|
-
const route = this.base_url;
|
|
3382
|
-
if (options && options.cache) return this.cache;
|
|
3383
|
-
if (options && options.betId) {
|
|
3384
|
-
const response2 = await this.rest.request({ url: `${route}/${options.betId}`, method: "GET" });
|
|
3385
|
-
return this.set(response2);
|
|
3386
|
-
}
|
|
3387
|
-
const response = await this.rest.request({ url: route, method: "GET" });
|
|
3388
|
-
return this.set(response);
|
|
3389
|
-
}
|
|
3390
|
-
async create(data) {
|
|
3391
|
-
const route = Routes.guilds.bets.create(this.guild.id);
|
|
3392
|
-
const response = await this.rest.request({ url: route, method: "POST", payload: data });
|
|
3393
|
-
return this.set(response);
|
|
3394
|
-
}
|
|
3395
|
-
async delete(betId) {
|
|
3396
|
-
const route = Routes.fields(this.base_url, betId);
|
|
3397
|
-
const response = await this.rest.request({ url: route, method: "DELETE" });
|
|
3398
|
-
return this.set(response);
|
|
3399
|
-
}
|
|
3400
|
-
set(data) {
|
|
3401
|
-
if (!data) return;
|
|
3402
|
-
if (Array.isArray(data)) {
|
|
3403
|
-
for (let _bet of data) {
|
|
3404
|
-
if (!_bet._id) continue;
|
|
3405
|
-
const bet = new GuildBet(_bet, this);
|
|
3406
|
-
this.cache.set(bet._id, bet);
|
|
3407
|
-
this.rest.bets.set(bet._id, bet);
|
|
3408
|
-
}
|
|
3409
|
-
} else {
|
|
3410
|
-
if (!data._id) return;
|
|
3411
|
-
if (data instanceof GuildBet) {
|
|
3412
|
-
this.cache.set(data._id, data);
|
|
3413
|
-
return data;
|
|
3414
|
-
}
|
|
3415
|
-
const bet = new GuildBet(data, this);
|
|
3416
|
-
this.cache.set(bet._id, bet);
|
|
3417
|
-
this.rest.bets.set(bet._id, bet);
|
|
3418
|
-
return bet;
|
|
3419
|
-
}
|
|
3420
|
-
}
|
|
3421
|
-
};
|
|
3422
|
-
|
|
3423
|
-
// src/managers/buffer/BufferManager.ts
|
|
3424
|
-
var BufferManager = class {
|
|
3425
|
-
constructor(guild) {
|
|
3426
|
-
__publicField(this, "matches");
|
|
3427
|
-
__publicField(this, "tickets");
|
|
3428
|
-
__publicField(this, "guild");
|
|
3429
|
-
this.matches = new Collection("buffer:matches");
|
|
3430
|
-
this.tickets = new Collection("buffer:tickets");
|
|
3431
|
-
this.guild = guild;
|
|
3432
|
-
}
|
|
3433
|
-
async flush(key) {
|
|
3434
|
-
const { rest } = this.guild;
|
|
3435
|
-
const cache = this[key];
|
|
3436
|
-
const { size, clear } = cache;
|
|
3437
|
-
if (size >= 2) {
|
|
3438
|
-
const response = await rest.request({
|
|
3439
|
-
method: "POST",
|
|
3440
|
-
url: Routes.guilds.resources(this.guild.id, key, "bulk"),
|
|
3441
|
-
payload: { [key]: this[key].toArray() }
|
|
3442
|
-
});
|
|
3443
|
-
this.guild[key].set(response);
|
|
3444
|
-
clear();
|
|
3445
|
-
return response;
|
|
3446
|
-
}
|
|
3447
|
-
return;
|
|
3448
|
-
}
|
|
3449
|
-
createMatch(id, data) {
|
|
3450
|
-
this.matches.set(id, data);
|
|
3451
|
-
}
|
|
3452
|
-
createTicket(id, data) {
|
|
3453
|
-
this.tickets.set(id, data);
|
|
3454
|
-
}
|
|
3455
|
-
};
|
|
3456
|
-
|
|
3457
|
-
// src/managers/logs/LogManager.ts
|
|
3458
|
-
var LogManager = class extends BaseManager {
|
|
3459
|
-
constructor(guild) {
|
|
3460
|
-
super(guild);
|
|
3461
|
-
this.guild = guild;
|
|
3462
|
-
this.rest = guild.rest;
|
|
3463
|
-
this.base_url = Routes.fields(Routes.guilds.get(guild.id), "logs");
|
|
3464
|
-
this.cache = new Collection();
|
|
3465
|
-
}
|
|
3466
|
-
async fetch() {
|
|
3467
|
-
const route = this.base_url;
|
|
3468
|
-
const response = await this.rest.request({
|
|
3469
|
-
method: "GET",
|
|
3470
|
-
url: route
|
|
3471
|
-
});
|
|
3472
|
-
return this.set(response);
|
|
3473
|
-
}
|
|
3474
|
-
async create(data) {
|
|
3475
|
-
const route = this.base_url;
|
|
3476
|
-
const payload = { ...data };
|
|
3477
|
-
const response = await this.rest.request({
|
|
3478
|
-
method: "POST",
|
|
3479
|
-
url: route,
|
|
3480
|
-
payload
|
|
3481
|
-
});
|
|
3482
|
-
const logEntry = this.set(response);
|
|
3483
|
-
this.cache.set(data._id, logEntry);
|
|
3484
|
-
this.rest.emit("logEntryCreate", logEntry, this.guild);
|
|
3485
|
-
return logEntry;
|
|
3486
|
-
}
|
|
3487
|
-
/* async createMany(data: Optional<APILogEntry>[]): Promise<APILogEntry[]> {
|
|
3488
|
-
const route = Routes.fields(this.base_url, "bulk");
|
|
3489
|
-
const payload = { ...data };
|
|
3490
|
-
const response = await this.rest.request<APILogEntry[], typeof payload>({
|
|
3491
|
-
method: "POST",
|
|
3492
|
-
url: route,
|
|
3493
|
-
payload,
|
|
3494
|
-
});
|
|
3495
|
-
|
|
3496
|
-
this.set(response);
|
|
3497
|
-
return response;
|
|
3498
|
-
} */
|
|
3499
|
-
set(data) {
|
|
3500
|
-
if (!data) return this.cache;
|
|
3501
|
-
if (Array.isArray(data)) {
|
|
3502
|
-
this.cache.clear();
|
|
3503
|
-
for (let entry of data) {
|
|
3504
|
-
if (!entry._id) continue;
|
|
3505
|
-
const logEntry = new LogEntry(entry, this);
|
|
3506
|
-
this.cache.set(entry._id, logEntry);
|
|
3507
|
-
}
|
|
3508
|
-
return this.cache;
|
|
3509
|
-
} else {
|
|
3510
|
-
const logEntry = new LogEntry(data, this);
|
|
3511
|
-
this.cache.set(data._id, logEntry);
|
|
3512
|
-
return logEntry;
|
|
3513
|
-
}
|
|
3514
|
-
}
|
|
3515
|
-
};
|
|
3516
|
-
|
|
3517
|
-
// src/managers/match/GuildMatchManager.ts
|
|
3518
|
-
var GuildMatchManager = class extends BaseManager {
|
|
3519
|
-
/**
|
|
3520
|
-
* Manage users with the given client
|
|
3521
|
-
* @param users An array of users
|
|
3522
|
-
* @param rest The rest client
|
|
3523
|
-
*/
|
|
3524
|
-
constructor(guild) {
|
|
3525
|
-
super(guild);
|
|
3526
|
-
this.guild = guild;
|
|
3527
|
-
this.rest = guild.rest;
|
|
3528
|
-
this.base_url = Routes.guilds.matches.getAll(guild.id);
|
|
3529
|
-
this.cache = new Collection("matches");
|
|
3530
|
-
}
|
|
3531
|
-
/**
|
|
3532
|
-
* Fetch a match
|
|
3533
|
-
* @param id Id of the match to fetch
|
|
3534
|
-
* @returns APIBetUser
|
|
3535
|
-
*/
|
|
3536
|
-
async fetch(options) {
|
|
3537
|
-
if (options && options.cache) return this.cache;
|
|
3538
|
-
if (options && options.matchId) {
|
|
3539
|
-
const route2 = Routes.guilds.matches.get(this.guild.id, options.matchId);
|
|
3540
|
-
const response2 = await this.rest.request({
|
|
3541
|
-
method: "get",
|
|
3542
|
-
url: route2
|
|
3543
|
-
});
|
|
3544
|
-
return this.set(response2);
|
|
3545
|
-
}
|
|
3546
|
-
const route = Routes.guilds.matches.getAll(this.guild.id);
|
|
3547
|
-
const response = await this.rest.request({
|
|
3548
|
-
method: "get",
|
|
3549
|
-
url: route
|
|
3550
|
-
});
|
|
3551
|
-
if (!response) return this.cache;
|
|
3552
|
-
const coll = new Collection("matches");
|
|
3553
|
-
for (let match of response ?? []) {
|
|
3554
|
-
const guildMatch = new GuildMatch(match, this);
|
|
3555
|
-
coll.set(match._id, guildMatch);
|
|
3556
|
-
this.rest.matches.set(match._id, guildMatch);
|
|
3557
|
-
}
|
|
3558
|
-
this.cache = coll;
|
|
3559
|
-
return coll;
|
|
3560
|
-
}
|
|
3561
|
-
async fetchAll() {
|
|
3562
|
-
const route = Routes.guilds.matches.getAll(this.guild.id);
|
|
3563
|
-
const response = await this.rest.request({
|
|
3564
|
-
method: "get",
|
|
3565
|
-
url: route
|
|
3566
|
-
});
|
|
3567
|
-
if (Array.isArray(response) && response.length === 0) {
|
|
3568
|
-
this.cache.clear();
|
|
3569
|
-
return this.cache;
|
|
3570
|
-
}
|
|
3571
|
-
this.set(response);
|
|
3572
|
-
return this.cache;
|
|
3573
|
-
}
|
|
3574
|
-
set(data) {
|
|
3575
|
-
if (!data) return this.cache;
|
|
3576
|
-
if (Array.isArray(data)) {
|
|
3577
|
-
for (let _match of data) {
|
|
3578
|
-
if (!_match._id) continue;
|
|
3579
|
-
const match = new GuildMatch(_match, this);
|
|
3580
|
-
this.cache.set(match._id, match);
|
|
3581
|
-
}
|
|
3582
|
-
return this.cache;
|
|
3583
|
-
} else {
|
|
3584
|
-
if (!data._id) return this.cache;
|
|
3585
|
-
if (data instanceof GuildMatch) {
|
|
3586
|
-
this.cache.set(data._id, data);
|
|
3587
|
-
return data;
|
|
3588
|
-
}
|
|
3589
|
-
const match = new GuildMatch(data, this);
|
|
3590
|
-
this.cache.set(match._id, match);
|
|
3591
|
-
return match;
|
|
3592
|
-
}
|
|
3593
|
-
}
|
|
3594
|
-
async create(payload) {
|
|
3595
|
-
Assertion.assertObject(payload);
|
|
3596
|
-
const route = Routes.guilds.matches.create(this.guild.id);
|
|
3597
|
-
const response = await this.rest.request({
|
|
3598
|
-
method: "POST",
|
|
3599
|
-
url: route,
|
|
3600
|
-
payload
|
|
3601
|
-
});
|
|
3602
|
-
return this.set(response);
|
|
3603
|
-
}
|
|
3604
|
-
async delete(id) {
|
|
3605
|
-
const route = Routes.fields(this.base_url, id);
|
|
3606
|
-
const response = await this.rest.request({ url: route, method: "DELETE" });
|
|
3607
|
-
return this.set(response);
|
|
3608
|
-
}
|
|
3609
|
-
};
|
|
3610
|
-
|
|
3611
|
-
// src/managers/message/MessagesManager.ts
|
|
3612
|
-
var MessagesManager = class {
|
|
3613
|
-
constructor(structure, base_url) {
|
|
3614
|
-
__publicField(this, "cache");
|
|
3615
|
-
__publicField(this, "base_url");
|
|
3616
|
-
__publicField(this, "rest");
|
|
3617
|
-
__publicField(this, "guild");
|
|
3618
|
-
this.rest = structure.rest;
|
|
3619
|
-
this.guild = structure.guild;
|
|
3620
|
-
this.cache = new Collection("messages");
|
|
3621
|
-
this.base_url = base_url;
|
|
3622
|
-
}
|
|
3623
|
-
async fetch() {
|
|
3624
|
-
const response = await this.rest.request({
|
|
3625
|
-
method: "GET",
|
|
3626
|
-
url: this.base_url,
|
|
3627
|
-
payload: {}
|
|
3628
|
-
});
|
|
3629
|
-
this.cache.set(response._id, response);
|
|
3630
|
-
return response;
|
|
3631
|
-
}
|
|
3632
|
-
async create(data) {
|
|
3633
|
-
const messages = [...this.cache.toArray()];
|
|
3634
|
-
if (Array.isArray(data)) messages.push(...data);
|
|
3635
|
-
else messages.push(data);
|
|
3636
|
-
const response = await this.rest.request({
|
|
3637
|
-
method: "PATCH",
|
|
3638
|
-
url: this.base_url,
|
|
3639
|
-
payload: { set: messages }
|
|
3640
|
-
});
|
|
3641
|
-
return this.set(response.messages);
|
|
3642
|
-
}
|
|
3643
|
-
set(data) {
|
|
3644
|
-
if (!data) return this.cache;
|
|
3645
|
-
if (Array.isArray(data)) {
|
|
3646
|
-
for (let message of data) {
|
|
3647
|
-
if (message && !message._id) continue;
|
|
3648
|
-
this.cache.set(message._id, message);
|
|
3649
|
-
}
|
|
3650
|
-
} else {
|
|
3651
|
-
if (data && !data._id) return this.cache;
|
|
3652
|
-
this.cache.set(data._id, data);
|
|
3653
|
-
}
|
|
3654
|
-
return this.cache;
|
|
3655
|
-
}
|
|
3656
|
-
};
|
|
3657
|
-
|
|
3658
|
-
// src/managers/minesgame/MinesGameManager.ts
|
|
3659
|
-
var MinesGameManager = class {
|
|
3660
|
-
constructor(rest) {
|
|
3661
|
-
__publicField(this, "cache");
|
|
3662
|
-
__publicField(this, "rest");
|
|
3663
|
-
this.cache = new Collection("minesgames");
|
|
3664
|
-
this.rest = rest;
|
|
3665
|
-
}
|
|
3666
|
-
async create(data) {
|
|
3667
|
-
const route = "/minesgames";
|
|
3668
|
-
const response = await this.rest.request({
|
|
3669
|
-
method: "POST",
|
|
3670
|
-
url: route,
|
|
3671
|
-
payload: data
|
|
3672
|
-
});
|
|
3673
|
-
return this.set(response);
|
|
3674
|
-
}
|
|
3675
|
-
async delete(gameId) {
|
|
3676
|
-
const route = `/minesgames/${gameId}`;
|
|
3677
|
-
const response = await this.rest.request({
|
|
3678
|
-
method: "DELETE",
|
|
3679
|
-
url: route
|
|
3680
|
-
});
|
|
3681
|
-
this.cache.delete(gameId);
|
|
3682
|
-
return response;
|
|
3683
|
-
}
|
|
3684
|
-
async fetch(options) {
|
|
3685
|
-
if (options && options.cache) return this.cache;
|
|
3686
|
-
if (options && options.gameId) {
|
|
3687
|
-
const route2 = `/minesgames/${options.gameId}`;
|
|
3688
|
-
const response2 = await this.rest.request({
|
|
3689
|
-
method: "GET",
|
|
3690
|
-
url: route2
|
|
3691
|
-
});
|
|
3692
|
-
const game = new MinesGame(response2, this);
|
|
3693
|
-
this.set(game);
|
|
3694
|
-
return game;
|
|
3695
|
-
}
|
|
3696
|
-
const route = "/minesgames";
|
|
3697
|
-
const response = await this.rest.request({
|
|
3698
|
-
method: "GET",
|
|
3699
|
-
url: route
|
|
3700
|
-
});
|
|
3701
|
-
return this.set(response);
|
|
3702
|
-
}
|
|
3703
|
-
set(data) {
|
|
3704
|
-
if (!data) return this.cache;
|
|
3705
|
-
if (Array.isArray(data)) {
|
|
3706
|
-
for (let _game of data) {
|
|
3707
|
-
const game = new MinesGame(_game, this);
|
|
3708
|
-
this.cache.set(game._id, game);
|
|
3709
|
-
}
|
|
3710
|
-
return this.cache;
|
|
3711
|
-
} else {
|
|
3712
|
-
const game = new MinesGame(data, this);
|
|
3713
|
-
this.cache.set(game._id, game);
|
|
3714
|
-
return game;
|
|
3715
|
-
}
|
|
3716
|
-
}
|
|
3717
|
-
};
|
|
3718
|
-
|
|
3719
|
-
// src/managers/permission/GuildPermissionManager.ts
|
|
3720
|
-
var GuildPermissionManager = class extends BaseManager {
|
|
3721
|
-
constructor(guild) {
|
|
3722
|
-
super(guild);
|
|
3723
|
-
this.guild = guild;
|
|
3724
|
-
this.rest = guild.rest;
|
|
3725
|
-
this.base_url = Routes.guilds.resource(guild.id, "permissions");
|
|
3726
|
-
}
|
|
3727
|
-
async addRole(type, ...ids) {
|
|
3728
|
-
const perm = this.guild.permissions.find((p) => p.type === type) || { ids: [], type };
|
|
3729
|
-
const _ids = [.../* @__PURE__ */ new Set([...perm.ids, ...ids])];
|
|
3730
|
-
const perms = [...this.guild.permissions];
|
|
3731
|
-
let permsIndex = this.guild.permissions.findIndex((p) => p.type === type);
|
|
3732
|
-
if (permsIndex === -1) perms.push({ type, ids: _ids });
|
|
3733
|
-
else perms[permsIndex] = { type, ids: _ids };
|
|
3734
|
-
const payload = { set: perms };
|
|
3735
|
-
const response = await this.rest.request({
|
|
3736
|
-
method: "PATCH",
|
|
3737
|
-
url: this.base_url,
|
|
3738
|
-
payload
|
|
3739
|
-
});
|
|
3740
|
-
this.guild.permissions = response.permissions;
|
|
3741
|
-
this.rest.guilds.cache.set(this.guild.id, this.guild);
|
|
3742
|
-
return response;
|
|
3743
|
-
}
|
|
3744
|
-
async removeRole(type, ...ids) {
|
|
3745
|
-
const perm = this.guild.permissions.find((p) => p.type === type) || { ids: [], type };
|
|
3746
|
-
const _ids = [.../* @__PURE__ */ new Set([...perm.ids.filter((i) => !ids.includes(i))])];
|
|
3747
|
-
const perms = [...this.guild.permissions];
|
|
3748
|
-
let permsIndex = this.guild.permissions.findIndex((p) => p.type === type);
|
|
3749
|
-
if (permsIndex === -1) {
|
|
3750
|
-
perms.push({ type, ids: _ids });
|
|
3751
|
-
} else {
|
|
3752
|
-
perms[permsIndex] = { type, ids: _ids };
|
|
3753
|
-
}
|
|
3754
|
-
const payload = { set: perms };
|
|
3755
|
-
const response = await this.rest.request({
|
|
3756
|
-
method: "PATCH",
|
|
3757
|
-
url: this.base_url,
|
|
3758
|
-
payload
|
|
3759
|
-
});
|
|
3760
|
-
this.guild.permissions = response.permissions;
|
|
3761
|
-
this.rest.guilds.cache.set(this.guild.id, this.guild);
|
|
3762
|
-
return response;
|
|
3763
|
-
}
|
|
3764
|
-
};
|
|
3765
|
-
|
|
3766
|
-
// src/managers/ticket/TicketManager.ts
|
|
3767
|
-
var GuildTicketManager = class {
|
|
3768
|
-
constructor(guild) {
|
|
3769
|
-
__publicField(this, "cache");
|
|
3770
|
-
__publicField(this, "guild");
|
|
3771
|
-
__publicField(this, "rest");
|
|
3772
|
-
this.guild = guild;
|
|
3773
|
-
this.rest = guild.rest;
|
|
3774
|
-
this.cache = new Collection("tickets");
|
|
3775
|
-
}
|
|
3776
|
-
async createTicketCategory(data) {
|
|
3777
|
-
const categories = this.guild.tickets_configuration.categories;
|
|
3778
|
-
let hasCategory = categories.find((c) => c.type === data?.type);
|
|
3779
|
-
if (hasCategory) {
|
|
3780
|
-
hasCategory = data;
|
|
3781
|
-
const index = categories.findIndex((c) => c.type === data?.type);
|
|
3782
|
-
categories[index] = hasCategory;
|
|
3783
|
-
} else {
|
|
3784
|
-
categories.push(data);
|
|
3785
|
-
}
|
|
3786
|
-
return this.guild.update({
|
|
3787
|
-
tickets_configuration: {
|
|
3788
|
-
categories,
|
|
3789
|
-
creationCategory: this.guild.tickets_configuration.creationCategory,
|
|
3790
|
-
deletionCategory: this.guild.tickets_configuration.deletionCategory,
|
|
3791
|
-
rating_channel_id: this.guild.tickets_configuration.rating_channel_id
|
|
3792
|
-
}
|
|
3793
|
-
});
|
|
3794
|
-
}
|
|
3795
|
-
async deleteTicketCategory(data) {
|
|
3796
|
-
let categories = this.guild.tickets_configuration.categories;
|
|
3797
|
-
let categoryIndex = categories.findIndex((c) => c.type === data?.type);
|
|
3798
|
-
if (categoryIndex === -1) return this.guild;
|
|
3799
|
-
categories = categories.filter((c) => c.type !== data.type);
|
|
3800
|
-
const payload = { tickets_configuration: { categories } };
|
|
3801
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
3802
|
-
const response = await this.rest.request({
|
|
3803
|
-
method: "PATCH",
|
|
3804
|
-
url: route,
|
|
3805
|
-
payload
|
|
3806
|
-
});
|
|
3807
|
-
return this.guild.update({
|
|
3808
|
-
tickets_configuration: {
|
|
3809
|
-
categories,
|
|
3810
|
-
creationCategory: this.guild.tickets_configuration.creationCategory,
|
|
3811
|
-
deletionCategory: this.guild.tickets_configuration.deletionCategory,
|
|
3812
|
-
rating_channel_id: this.guild.tickets_configuration.rating_channel_id
|
|
3813
|
-
}
|
|
3814
|
-
});
|
|
3815
|
-
}
|
|
3816
|
-
async fetch(options) {
|
|
3817
|
-
if (options && options.cache) return this.cache;
|
|
3818
|
-
if (options && options.ticketId) {
|
|
3819
|
-
const route2 = Routes.guilds.tickets.get(this.guild.id, options.ticketId);
|
|
3820
|
-
const response2 = await this.rest.request({
|
|
3821
|
-
method: "GET",
|
|
3822
|
-
url: route2
|
|
3823
|
-
});
|
|
3824
|
-
return this.set(response2);
|
|
3825
|
-
}
|
|
3826
|
-
const route = Routes.guilds.tickets.getAll(this.guild.id);
|
|
3827
|
-
const response = await this.rest.request({
|
|
3828
|
-
method: "GET",
|
|
3829
|
-
url: route
|
|
3830
|
-
});
|
|
3831
|
-
return this.set(response);
|
|
3832
|
-
}
|
|
3833
|
-
async create(data) {
|
|
3834
|
-
const route = Routes.guilds.tickets.create(this.guild.id);
|
|
3835
|
-
const response = await this.rest.request({
|
|
3836
|
-
method: "POST",
|
|
3837
|
-
url: route,
|
|
3838
|
-
payload: data
|
|
3839
|
-
});
|
|
3840
|
-
const ticket = this.set(response);
|
|
3841
|
-
this.rest.emit("ticketCreate", ticket);
|
|
3842
|
-
return ticket;
|
|
3843
|
-
}
|
|
3844
|
-
async delete(options) {
|
|
3845
|
-
if (options && options.ticketId) {
|
|
3846
|
-
const route2 = Routes.guilds.tickets.delete(this.guild.id, options.ticketId);
|
|
3847
|
-
await this.rest.request({
|
|
3848
|
-
method: "DELETE",
|
|
3849
|
-
url: route2
|
|
3850
|
-
});
|
|
3851
|
-
this.rest.emit("ticketDelete", this.cache.get(options.ticketId));
|
|
3852
|
-
this.cache.delete(options.ticketId);
|
|
3853
|
-
return true;
|
|
3854
|
-
}
|
|
3855
|
-
const route = Routes.guilds.tickets.deleteAll(this.guild.id);
|
|
3856
|
-
await this.rest.request({
|
|
3857
|
-
method: "DELETE",
|
|
3858
|
-
url: route
|
|
3859
|
-
});
|
|
3860
|
-
this.rest.emit("ticketsDelete", this.cache);
|
|
3861
|
-
this.cache.clear();
|
|
3862
|
-
return true;
|
|
3863
|
-
}
|
|
3864
|
-
set(data) {
|
|
3865
|
-
if (!data) return this.cache;
|
|
3866
|
-
if (Array.isArray(data)) {
|
|
3867
|
-
for (let _ticket of data) {
|
|
3868
|
-
if (!_ticket._id) return;
|
|
3869
|
-
const ticket = new GuildTicket(_ticket, this);
|
|
3870
|
-
this.cache.set(ticket._id, ticket);
|
|
3871
|
-
this.rest.tickets.set(ticket._id, ticket);
|
|
3872
|
-
}
|
|
3873
|
-
return this.cache;
|
|
3874
|
-
} else {
|
|
3875
|
-
if (!data._id) return;
|
|
3876
|
-
const ticket = new GuildTicket(data, this);
|
|
3877
|
-
this.cache.set(ticket._id, ticket);
|
|
3878
|
-
this.rest.tickets.set(ticket._id, ticket);
|
|
3879
|
-
return ticket;
|
|
3880
|
-
}
|
|
3881
|
-
}
|
|
3882
|
-
};
|
|
3883
|
-
|
|
3884
|
-
// src/managers/user/GuildUserManager.ts
|
|
3885
|
-
var GuildUserManager = class extends BaseManager {
|
|
3886
|
-
constructor(guild) {
|
|
3887
|
-
super(guild);
|
|
3888
|
-
this.guild = guild;
|
|
3889
|
-
this.rest = guild.rest;
|
|
3890
|
-
this.base_url = Routes.guilds.users.getAll(guild.id);
|
|
3891
|
-
this.cache = new Collection("users");
|
|
3892
|
-
}
|
|
3893
|
-
async fetch(options) {
|
|
3894
|
-
if (options && options.cache) return this.cache;
|
|
3895
|
-
if (options && options.userId) {
|
|
3896
|
-
const route2 = Routes.fields(this.base_url, options.userId);
|
|
3897
|
-
const response2 = await this.rest.request({
|
|
3898
|
-
method: "GET",
|
|
3899
|
-
url: route2
|
|
3900
|
-
});
|
|
3901
|
-
const user = new GuildUser(response2, this);
|
|
3902
|
-
this.set(user);
|
|
3903
|
-
return user;
|
|
3904
|
-
}
|
|
3905
|
-
const route = this.base_url;
|
|
3906
|
-
const response = await this.rest.request({
|
|
3907
|
-
method: "GET",
|
|
3908
|
-
url: route
|
|
3909
|
-
});
|
|
3910
|
-
this.cache.clear();
|
|
3911
|
-
for (let userData of response) {
|
|
3912
|
-
const user = new GuildUser(userData, this);
|
|
3913
|
-
this.set(user);
|
|
3914
|
-
}
|
|
3915
|
-
return this.cache;
|
|
3916
|
-
}
|
|
3917
|
-
async updateMany(...users) {
|
|
3918
|
-
const route = this.base_url;
|
|
3919
|
-
const response = await this.rest.request({
|
|
3920
|
-
method: "PATCH",
|
|
3921
|
-
url: route,
|
|
3922
|
-
payload: { users }
|
|
3923
|
-
});
|
|
3924
|
-
for (const userData of response) {
|
|
3925
|
-
const user = new GuildUser(userData, this);
|
|
3926
|
-
this.set(user);
|
|
3927
|
-
}
|
|
3928
|
-
return this.cache;
|
|
3929
|
-
}
|
|
3930
|
-
async deleteAll() {
|
|
3931
|
-
const route = this.base_url;
|
|
3932
|
-
await this.rest.request({
|
|
3933
|
-
method: "DELETE",
|
|
3934
|
-
url: route
|
|
3935
|
-
});
|
|
3936
|
-
this.cache.clear();
|
|
3937
|
-
}
|
|
3938
|
-
async resetAll() {
|
|
3939
|
-
const route = this.base_url;
|
|
3940
|
-
const response = await this.rest.request({
|
|
3941
|
-
method: "put",
|
|
3942
|
-
url: route
|
|
3943
|
-
});
|
|
3944
|
-
this.cache.clear();
|
|
3945
|
-
this.set(response);
|
|
3946
|
-
return this.cache;
|
|
3947
|
-
}
|
|
3948
|
-
set(data) {
|
|
3949
|
-
if (!data) return this.cache;
|
|
3950
|
-
if (Array.isArray(data)) {
|
|
3951
|
-
for (let _user of data) {
|
|
3952
|
-
if (!_user.id) return;
|
|
3953
|
-
const user = new GuildUser(_user, this);
|
|
3954
|
-
this.cache.set(user.id, user);
|
|
3955
|
-
this.rest.users.set(user.id, user);
|
|
3956
|
-
}
|
|
3957
|
-
return this.cache;
|
|
3958
|
-
} else {
|
|
3959
|
-
if (!data.id) return;
|
|
3960
|
-
const user = new GuildUser(data, this);
|
|
3961
|
-
this.cache.set(user.id, user);
|
|
3962
|
-
this.rest.users.set(user.id, user);
|
|
3963
|
-
return user;
|
|
3964
|
-
}
|
|
3965
|
-
}
|
|
3966
|
-
};
|
|
3967
|
-
|
|
3968
|
-
// src/managers/vipmember/VipMemberManager.ts
|
|
3969
|
-
var VipMemberManager = class extends BaseManager {
|
|
3970
|
-
/**
|
|
3971
|
-
* Manage vipmembers with the given client
|
|
3972
|
-
* @param vipmembers An array of vipmembers
|
|
3973
|
-
* @param rest The rest client
|
|
3974
|
-
*/
|
|
3975
|
-
constructor(guild) {
|
|
3976
|
-
super(guild);
|
|
3977
|
-
this.guild = guild;
|
|
3978
|
-
this.rest = guild.rest;
|
|
3979
|
-
this.base_url = Routes.guilds.resource(guild.id, "vipmembers");
|
|
3980
|
-
this.cache = new Collection("vipmembers");
|
|
3981
|
-
}
|
|
3982
|
-
async create(data) {
|
|
3983
|
-
const route = Routes.vipmembers.create(this.guild.id);
|
|
3984
|
-
const payload = { ...data };
|
|
3985
|
-
const response = await this.rest.request({
|
|
3986
|
-
method: "post",
|
|
3987
|
-
url: route,
|
|
3988
|
-
payload
|
|
3989
|
-
});
|
|
3990
|
-
const member = new VipMember(response, this);
|
|
3991
|
-
this.cache.set(member?.id, member);
|
|
3992
|
-
return member;
|
|
3993
|
-
}
|
|
3994
|
-
/**
|
|
3995
|
-
* Fetch a member
|
|
3996
|
-
* @param id Id of the member to fetch
|
|
3997
|
-
* @returns VipMember
|
|
3998
|
-
*/
|
|
3999
|
-
async fetch(options) {
|
|
4000
|
-
if (options && options.cache) return this.cache;
|
|
4001
|
-
if (options && options.memberId) {
|
|
4002
|
-
const route2 = Routes.vipmembers.get(this.guild.id, options.memberId);
|
|
4003
|
-
const payload = { guild_id: this.guild.id };
|
|
4004
|
-
const response2 = await this.rest.request({
|
|
4005
|
-
method: "get",
|
|
4006
|
-
url: route2,
|
|
4007
|
-
payload
|
|
4008
|
-
});
|
|
4009
|
-
if (!response2) return this.cache.get(options.memberId);
|
|
4010
|
-
const member = new VipMember(response2, this);
|
|
4011
|
-
this.cache.set(member?.id, member);
|
|
4012
|
-
return member;
|
|
4013
|
-
}
|
|
4014
|
-
const route = Routes.vipmembers.getAll(this.guild.id);
|
|
4015
|
-
const response = await this.rest.request({
|
|
4016
|
-
method: "get",
|
|
4017
|
-
url: route
|
|
4018
|
-
});
|
|
4019
|
-
if (Array.isArray(response) && response.length === 0) {
|
|
4020
|
-
this.cache.clear();
|
|
4021
|
-
return this.cache;
|
|
4022
|
-
}
|
|
4023
|
-
this.setAll(response);
|
|
4024
|
-
return this.cache;
|
|
4025
|
-
}
|
|
4026
|
-
async updateMember(id, data) {
|
|
4027
|
-
const route = Routes.vipmembers.update(this.guild.id, id);
|
|
4028
|
-
const payload = { ...data, guild_id: this.guild.id };
|
|
4029
|
-
const response = await this.rest.request({
|
|
4030
|
-
method: "patch",
|
|
4031
|
-
url: route,
|
|
4032
|
-
payload
|
|
4033
|
-
});
|
|
4034
|
-
const member = this.set(response);
|
|
4035
|
-
return member;
|
|
4036
|
-
}
|
|
4037
|
-
set(data) {
|
|
4038
|
-
if (!data?.id) return;
|
|
4039
|
-
const member = new VipMember(data, this);
|
|
4040
|
-
this.cache.set(member.id, member);
|
|
4041
|
-
return member;
|
|
4042
|
-
}
|
|
4043
|
-
setAll(data) {
|
|
4044
|
-
if (!data) return this.cache;
|
|
4045
|
-
for (let member of data) this.set(member);
|
|
4046
|
-
return this.cache;
|
|
4047
|
-
}
|
|
4048
|
-
async resetAll() {
|
|
4049
|
-
const route = Routes.vipmembers.getAll(this.guild.id);
|
|
4050
|
-
const response = await this.rest.request({
|
|
4051
|
-
method: "PUT",
|
|
4052
|
-
url: route
|
|
4053
|
-
});
|
|
4054
|
-
this.setAll(response);
|
|
4055
|
-
return this.cache;
|
|
4056
|
-
}
|
|
4057
|
-
async delete(id) {
|
|
4058
|
-
Assertion.assertString(id);
|
|
4059
|
-
Assertion.assertString(this.guild.id);
|
|
4060
|
-
const route = Routes.vipmembers.delete(id, this.guild.id);
|
|
4061
|
-
await this.rest.request({
|
|
4062
|
-
method: "DELETE",
|
|
4063
|
-
url: route
|
|
4064
|
-
});
|
|
4065
|
-
this.cache.delete(id);
|
|
4066
|
-
return this.cache;
|
|
4067
|
-
}
|
|
4068
|
-
async deleteAll() {
|
|
4069
|
-
Assertion.assertString(this.guild.id);
|
|
4070
|
-
const route = Routes.vipmembers.deleteAll(this.guild.id);
|
|
4071
|
-
const value = await this.rest.request({
|
|
4072
|
-
method: "DELETE",
|
|
4073
|
-
url: route
|
|
4074
|
-
});
|
|
4075
|
-
this.cache.clear();
|
|
4076
|
-
return value;
|
|
4077
|
-
}
|
|
4078
|
-
};
|
|
4079
|
-
|
|
4080
|
-
// src/types/api/APIGuild.ts
|
|
4081
|
-
var GuildStatusEnum = /* @__PURE__ */ ((GuildStatusEnum2) => {
|
|
4082
|
-
GuildStatusEnum2["Matches"] = "matches";
|
|
4083
|
-
GuildStatusEnum2["Bets"] = "bets";
|
|
4084
|
-
GuildStatusEnum2["DailyRank"] = "daily_rank";
|
|
4085
|
-
GuildStatusEnum2["CreateVoiceChannels"] = "create_voice_channels";
|
|
4086
|
-
GuildStatusEnum2["TwoMvps"] = "two_mvps";
|
|
4087
|
-
GuildStatusEnum2["RankingName"] = "ranking_name";
|
|
4088
|
-
GuildStatusEnum2["LogsQueues"] = "logs_queues";
|
|
4089
|
-
GuildStatusEnum2["LogsUsers"] = "logs_users";
|
|
4090
|
-
GuildStatusEnum2["LogsManaging"] = "logs_managing";
|
|
4091
|
-
GuildStatusEnum2["NameHidden"] = "name_hidden";
|
|
4092
|
-
return GuildStatusEnum2;
|
|
4093
|
-
})(GuildStatusEnum || {});
|
|
4094
|
-
var AutomaticMessagesTypes = /* @__PURE__ */ ((AutomaticMessagesTypes2) => {
|
|
4095
|
-
AutomaticMessagesTypes2["MatchStarted"] = "match_started";
|
|
4096
|
-
AutomaticMessagesTypes2["Miscellaneous"] = "miscellaneous";
|
|
4097
|
-
return AutomaticMessagesTypes2;
|
|
4098
|
-
})(AutomaticMessagesTypes || {});
|
|
4099
|
-
var GuildChannelsType = /* @__PURE__ */ ((GuildChannelsType2) => {
|
|
4100
|
-
GuildChannelsType2["DailyRank"] = "daily_rank";
|
|
4101
|
-
GuildChannelsType2["Commands"] = "command";
|
|
4102
|
-
GuildChannelsType2["Blacklist"] = "blacklist";
|
|
4103
|
-
GuildChannelsType2["Queues"] = "queue";
|
|
4104
|
-
GuildChannelsType2["VipMemebers"] = "vipmembers_category";
|
|
4105
|
-
GuildChannelsType2["QueueLogs"] = "queue_logs";
|
|
4106
|
-
GuildChannelsType2["UserLogs"] = "user_logs";
|
|
4107
|
-
GuildChannelsType2["TicketLogs"] = "ticket_logs";
|
|
4108
|
-
GuildChannelsType2["ManagingLogs"] = "managing_logs";
|
|
4109
|
-
GuildChannelsType2["NormalQueue"] = "normal_queue";
|
|
4110
|
-
GuildChannelsType2["ChallengeQueue"] = "challenge_queue";
|
|
4111
|
-
GuildChannelsType2["MatchTextChannelParent"] = "match_text_channel_parent";
|
|
4112
|
-
GuildChannelsType2["VoiceChannelMatchCreation"] = "voice_channel_match_creation";
|
|
4113
|
-
GuildChannelsType2["WaitingVC"] = "waiting_vc";
|
|
4114
|
-
GuildChannelsType2["BetMobileCategory"] = "bet_mobile_category";
|
|
4115
|
-
GuildChannelsType2["BetEmulatorCategory"] = "bet_emulator_category";
|
|
4116
|
-
GuildChannelsType2["BetMixCategory"] = "bet_mix_category";
|
|
4117
|
-
GuildChannelsType2["RouletteLogs"] = "roulette_logs";
|
|
4118
|
-
GuildChannelsType2["Rules"] = "rules";
|
|
4119
|
-
return GuildChannelsType2;
|
|
4120
|
-
})(GuildChannelsType || {});
|
|
4121
|
-
|
|
4122
|
-
// src/types/api/APIGuildBet.ts
|
|
4123
|
-
var BetChannelTypes = /* @__PURE__ */ ((BetChannelTypes2) => {
|
|
4124
|
-
BetChannelTypes2["CreationChannel"] = "creation_channel";
|
|
4125
|
-
return BetChannelTypes2;
|
|
4126
|
-
})(BetChannelTypes || {});
|
|
4127
|
-
|
|
4128
|
-
// src/types/api/APIGuildMatch.ts
|
|
4129
|
-
var GuildMatchChannelsType = /* @__PURE__ */ ((GuildMatchChannelsType2) => {
|
|
4130
|
-
GuildMatchChannelsType2["CreationChannel"] = "creation_channel";
|
|
4131
|
-
GuildMatchChannelsType2["TextChannel"] = "text_channel";
|
|
4132
|
-
return GuildMatchChannelsType2;
|
|
4133
|
-
})(GuildMatchChannelsType || {});
|
|
4134
|
-
var GuildMatchMessagesType = /* @__PURE__ */ ((GuildMatchMessagesType2) => {
|
|
4135
|
-
GuildMatchMessagesType2["CreationMessage"] = "creation_message";
|
|
4136
|
-
return GuildMatchMessagesType2;
|
|
4137
|
-
})(GuildMatchMessagesType || {});
|
|
4138
|
-
|
|
4139
|
-
// src/types/api/APIGuildPermissions.ts
|
|
4140
|
-
var GuildPermissionsTypes = /* @__PURE__ */ ((GuildPermissionsTypes2) => {
|
|
4141
|
-
GuildPermissionsTypes2["ManageBot"] = "manage_bot";
|
|
4142
|
-
GuildPermissionsTypes2["ManageQueues"] = "manage_queues";
|
|
4143
|
-
GuildPermissionsTypes2["ManageUsers"] = "manage_users";
|
|
4144
|
-
GuildPermissionsTypes2["ViewQueueChannels"] = "view_queue_channels";
|
|
4145
|
-
GuildPermissionsTypes2["MediatorRole"] = "mediator_role";
|
|
4146
|
-
GuildPermissionsTypes2["ManageRouletteRolls"] = "manage_roulette_rolls";
|
|
4147
|
-
return GuildPermissionsTypes2;
|
|
4148
|
-
})(GuildPermissionsTypes || {});
|
|
4149
|
-
|
|
4150
|
-
// src/types/api/APILogEntry.ts
|
|
4151
|
-
var LogEntryTypes = /* @__PURE__ */ ((LogEntryTypes2) => {
|
|
4152
|
-
LogEntryTypes2["QueueCreated"] = "queue_created";
|
|
4153
|
-
LogEntryTypes2["QueueShut"] = "queue_shut";
|
|
4154
|
-
LogEntryTypes2["MatchStarted"] = "match_started";
|
|
4155
|
-
LogEntryTypes2["MatchUpdated"] = "match_updated";
|
|
4156
|
-
LogEntryTypes2["MatchClosed"] = "match_closed";
|
|
4157
|
-
LogEntryTypes2["UserUpdated"] = "user_updated";
|
|
4158
|
-
LogEntryTypes2["UserManaged"] = "user_managed";
|
|
4159
|
-
LogEntryTypes2["BetManaged"] = "bet_managed";
|
|
4160
|
-
LogEntryTypes2["BetMediador"] = "bet_mediador";
|
|
4161
|
-
LogEntryTypes2["BetInitiated"] = "bet_initiated";
|
|
4162
|
-
LogEntryTypes2["BetClosed"] = "bet_closed";
|
|
4163
|
-
LogEntryTypes2["BetAwaitingConfirmation"] = "bet_awaiting_confirmation";
|
|
4164
|
-
LogEntryTypes2["BetCanceled"] = "bet_canceled";
|
|
4165
|
-
return LogEntryTypes2;
|
|
4166
|
-
})(LogEntryTypes || {});
|
|
4167
|
-
|
|
4168
|
-
// src/types/api/index.ts
|
|
4169
|
-
var MATCHTYPES = /* @__PURE__ */ ((MATCHTYPES2) => {
|
|
4170
|
-
MATCHTYPES2["OneVOne"] = "1v1";
|
|
4171
|
-
MATCHTYPES2["TwoVTwo"] = "2v2";
|
|
4172
|
-
MATCHTYPES2["ThreeVThree"] = "3v3";
|
|
4173
|
-
MATCHTYPES2["FourVFour"] = "4v4";
|
|
4174
|
-
MATCHTYPES2["FiveVFive"] = "5v5";
|
|
4175
|
-
MATCHTYPES2["SixVSix"] = "6v6";
|
|
4176
|
-
return MATCHTYPES2;
|
|
4177
|
-
})(MATCHTYPES || {});
|
|
4178
|
-
var MATCHSTATUS = /* @__PURE__ */ ((MATCHSTATUS2) => {
|
|
4179
|
-
MATCHSTATUS2["ON"] = "on";
|
|
4180
|
-
MATCHSTATUS2["OFF"] = "off";
|
|
4181
|
-
MATCHSTATUS2["CREATED"] = "created";
|
|
4182
|
-
MATCHSTATUS2["SHUTTED"] = "shutted";
|
|
4183
|
-
return MATCHSTATUS2;
|
|
4184
|
-
})(MATCHSTATUS || {});
|
|
4185
|
-
var BETSTATUS = /* @__PURE__ */ ((BETSTATUS2) => {
|
|
4186
|
-
BETSTATUS2["ON"] = "on";
|
|
4187
|
-
BETSTATUS2["OFF"] = "off";
|
|
4188
|
-
BETSTATUS2["CREATED"] = "created";
|
|
4189
|
-
BETSTATUS2["SHUTTED"] = "shutted";
|
|
4190
|
-
BETSTATUS2["WAITING"] = "waiting";
|
|
4191
|
-
return BETSTATUS2;
|
|
4192
|
-
})(BETSTATUS || {});
|
|
4193
|
-
var STATES = /* @__PURE__ */ ((STATES2) => {
|
|
4194
|
-
STATES2["ON"] = "on";
|
|
4195
|
-
STATES2["OFF"] = "off";
|
|
4196
|
-
STATES2["CREATED"] = "created";
|
|
4197
|
-
STATES2["SHUTTED"] = "shutted";
|
|
4198
|
-
STATES2["WAITING"] = "waiting";
|
|
4199
|
-
return STATES2;
|
|
4200
|
-
})(STATES || {});
|
|
18
|
+
__reExport(index_exports, require("./managers"), module.exports);
|
|
19
|
+
__reExport(index_exports, require("./structures"), module.exports);
|
|
20
|
+
__reExport(index_exports, require("./rest"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("./types"), module.exports);
|
|
4201
22
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4202
23
|
0 && (module.exports = {
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
BaseManager,
|
|
4208
|
-
BetChannelTypes,
|
|
4209
|
-
BufferManager,
|
|
4210
|
-
Collection,
|
|
4211
|
-
Guild,
|
|
4212
|
-
GuildBet,
|
|
4213
|
-
GuildBetManager,
|
|
4214
|
-
GuildBetUser,
|
|
4215
|
-
GuildBetUserManager,
|
|
4216
|
-
GuildChannelsType,
|
|
4217
|
-
GuildManager,
|
|
4218
|
-
GuildMatch,
|
|
4219
|
-
GuildMatchChannelsType,
|
|
4220
|
-
GuildMatchManager,
|
|
4221
|
-
GuildMatchMessagesType,
|
|
4222
|
-
GuildMediator,
|
|
4223
|
-
GuildMediatorManager,
|
|
4224
|
-
GuildPermissionManager,
|
|
4225
|
-
GuildPermissionsTypes,
|
|
4226
|
-
GuildStatusEnum,
|
|
4227
|
-
GuildTicket,
|
|
4228
|
-
GuildTicketManager,
|
|
4229
|
-
GuildUser,
|
|
4230
|
-
GuildUserManager,
|
|
4231
|
-
LogEntry,
|
|
4232
|
-
LogEntryTypes,
|
|
4233
|
-
LogManager,
|
|
4234
|
-
MATCHSTATUS,
|
|
4235
|
-
MATCHTYPES,
|
|
4236
|
-
MessagesManager,
|
|
4237
|
-
MinesGame,
|
|
4238
|
-
MinesGameManager,
|
|
4239
|
-
REST,
|
|
4240
|
-
Routes,
|
|
4241
|
-
STATES,
|
|
4242
|
-
VipMember,
|
|
4243
|
-
VipMemberManager
|
|
24
|
+
...require("./managers"),
|
|
25
|
+
...require("./structures"),
|
|
26
|
+
...require("./rest"),
|
|
27
|
+
...require("./types")
|
|
4244
28
|
});
|
|
29
|
+
//# sourceMappingURL=index.js.map
|