@duque.edits/sdk 1.1.2 → 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 +9 -18
- 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
|
@@ -1,3240 +1,43 @@
|
|
|
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
6
|
var __typeError = (msg) => {
|
|
9
7
|
throw TypeError(msg);
|
|
10
8
|
};
|
|
11
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
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
|
-
));
|
|
35
|
-
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/structures/guild/Guild.ts
|
|
401
|
-
var Guild_exports = {};
|
|
402
|
-
__export(Guild_exports, {
|
|
403
|
-
Guild: () => Guild
|
|
404
|
-
});
|
|
405
|
-
module.exports = __toCommonJS(Guild_exports);
|
|
406
|
-
|
|
407
|
-
// src/structures/Collection.ts
|
|
408
|
-
var Collection = class _Collection extends Map {
|
|
409
|
-
constructor(key, data) {
|
|
410
|
-
super();
|
|
411
|
-
__publicField(this, "key");
|
|
412
|
-
this.key = key;
|
|
413
|
-
if (data && Array.isArray(data) && key) {
|
|
414
|
-
if (data.length > 0) return;
|
|
415
|
-
for (let v of data) this.set(key, v);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
at(index) {
|
|
419
|
-
if (index < 0 || index >= this.size) {
|
|
420
|
-
return void 0;
|
|
421
|
-
}
|
|
422
|
-
let i = 0;
|
|
423
|
-
for (let [, value] of this) {
|
|
424
|
-
if (i === index) {
|
|
425
|
-
return value;
|
|
426
|
-
}
|
|
427
|
-
i++;
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
has(key) {
|
|
431
|
-
return this.get(key) !== void 0 ? true : false;
|
|
432
|
-
}
|
|
433
|
-
get first() {
|
|
434
|
-
return this.values().next().value;
|
|
435
|
-
}
|
|
436
|
-
get last() {
|
|
437
|
-
return [...this.values()].at(-1);
|
|
438
|
-
}
|
|
439
|
-
get length() {
|
|
440
|
-
return this.toArray().length;
|
|
441
|
-
}
|
|
442
|
-
find(predicate) {
|
|
443
|
-
for (const [key, value] of this) {
|
|
444
|
-
if (predicate(value, key, this)) return value;
|
|
445
|
-
}
|
|
446
|
-
return void 0;
|
|
447
|
-
}
|
|
448
|
-
filter(predicate) {
|
|
449
|
-
const results = new _Collection(this.key, []);
|
|
450
|
-
for (const [key, value] of this) {
|
|
451
|
-
if (predicate(value, key, this)) results.set(key, value);
|
|
452
|
-
}
|
|
453
|
-
return results;
|
|
454
|
-
}
|
|
455
|
-
some(predicate) {
|
|
456
|
-
const results = new _Collection(this.key, []);
|
|
457
|
-
for (const [key, value] of this) {
|
|
458
|
-
if (predicate(value, key, this)) results.set(key, value);
|
|
459
|
-
}
|
|
460
|
-
return results;
|
|
461
|
-
}
|
|
462
|
-
map(callback) {
|
|
463
|
-
return [...this].map(([key, val]) => callback(val, key, this));
|
|
464
|
-
}
|
|
465
|
-
toArray() {
|
|
466
|
-
return [...this.values()];
|
|
467
|
-
}
|
|
468
|
-
toJSON() {
|
|
469
|
-
let obj = {};
|
|
470
|
-
for (let [k, v] of this.entries()) {
|
|
471
|
-
obj[`${k}`] = v;
|
|
472
|
-
}
|
|
473
|
-
return obj;
|
|
474
|
-
}
|
|
475
|
-
sort(compareFunction) {
|
|
476
|
-
const sortedEntries = [...this.entries()].sort((ab, ba) => {
|
|
477
|
-
return compareFunction(ab[1], ba[1], this);
|
|
478
|
-
});
|
|
479
|
-
const coll = new _Collection();
|
|
480
|
-
for (let [k, v] of sortedEntries) coll.set(k, v);
|
|
481
|
-
return coll;
|
|
482
|
-
}
|
|
483
|
-
toString() {
|
|
484
|
-
return `${this.size}`;
|
|
485
|
-
}
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
// src/managers/base.ts
|
|
489
|
-
var BaseManager = class {
|
|
490
|
-
constructor(guild) {
|
|
491
|
-
/** This url of the manager */
|
|
492
|
-
__publicField(this, "base_url");
|
|
493
|
-
/** The rest client */
|
|
494
|
-
__publicField(this, "rest");
|
|
495
|
-
/** The guild of the manager */
|
|
496
|
-
__publicField(this, "guild");
|
|
497
|
-
/** Cache */
|
|
498
|
-
__publicField(this, "cache");
|
|
499
|
-
this.guild = guild;
|
|
500
|
-
this.rest = guild.rest;
|
|
501
|
-
this.cache = new Collection();
|
|
502
|
-
}
|
|
503
|
-
toJSON() {
|
|
504
|
-
return [...this.cache.values()].map((m) => m && "toJSON" in m && typeof m.toJSON === "function" ? m.toJSON() : m);
|
|
505
|
-
}
|
|
506
|
-
};
|
|
507
|
-
|
|
508
|
-
// src/managers/player/PlayerManager.ts
|
|
509
|
-
var PlayerManager = class extends Collection {
|
|
510
|
-
constructor(structure, base_url) {
|
|
511
|
-
super("players");
|
|
512
|
-
__publicField(this, "base_url");
|
|
513
|
-
__publicField(this, "rest");
|
|
514
|
-
__publicField(this, "guild");
|
|
515
|
-
this.base_url = base_url;
|
|
516
|
-
this.guild = structure.guild;
|
|
517
|
-
this.rest = structure.rest;
|
|
518
|
-
}
|
|
519
|
-
_set(data) {
|
|
520
|
-
this.clear();
|
|
521
|
-
if (Array.isArray(data)) {
|
|
522
|
-
for (let p of data) {
|
|
523
|
-
if (!p.id) continue;
|
|
524
|
-
this.set(p.id, {
|
|
525
|
-
id: p.id,
|
|
526
|
-
createdAt: p.createdAt ? new Date(p.createdAt) : /* @__PURE__ */ new Date(),
|
|
527
|
-
updateAt: p.updateAt ? new Date(p.updateAt) : /* @__PURE__ */ new Date()
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
} else {
|
|
531
|
-
if (!data.id) return;
|
|
532
|
-
this.set(data.id, {
|
|
533
|
-
id: data.id,
|
|
534
|
-
createdAt: data.createdAt ? new Date(data.createdAt) : /* @__PURE__ */ new Date(),
|
|
535
|
-
updateAt: data.updateAt ? new Date(data.updateAt) : /* @__PURE__ */ new Date()
|
|
536
|
-
});
|
|
537
|
-
}
|
|
538
|
-
return this;
|
|
539
|
-
}
|
|
540
|
-
/**
|
|
541
|
-
* Adds a player or an array of players to the structure.
|
|
542
|
-
* @param player A player or an array of players to be added
|
|
543
|
-
* @returns returns a collection of players
|
|
544
|
-
*/
|
|
545
|
-
async add(player) {
|
|
546
|
-
let players = [];
|
|
547
|
-
if (Array.isArray(player)) {
|
|
548
|
-
for (let p of player) this.has(p.id) ? null : players.push(p);
|
|
549
|
-
} else this.has(player.id) ? null : players.push(player);
|
|
550
|
-
const payload = { set: players };
|
|
551
|
-
const response = await this.rest.request({
|
|
552
|
-
method: "PATCH",
|
|
553
|
-
payload,
|
|
554
|
-
url: this.base_url
|
|
555
|
-
});
|
|
556
|
-
return this._set(response.players);
|
|
557
|
-
}
|
|
558
|
-
/**
|
|
559
|
-
* Remover a player or an array of players.
|
|
560
|
-
* @param player The player or an array of players to be removed
|
|
561
|
-
* @returns Player manager
|
|
562
|
-
*/
|
|
563
|
-
async remove(player) {
|
|
564
|
-
const ids = new Set(Array.isArray(player) ? player.map((p) => p.id) : [player.id]);
|
|
565
|
-
const players = this.toArray().filter((p) => !ids.has(p.id));
|
|
566
|
-
const payload = { set: players };
|
|
567
|
-
const response = await this.rest.request({
|
|
568
|
-
method: "PATCH",
|
|
569
|
-
payload,
|
|
570
|
-
url: this.base_url
|
|
571
|
-
});
|
|
572
|
-
return this._set(response.players);
|
|
573
|
-
}
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
// src/rest/Routes.ts
|
|
577
|
-
var Routes = {
|
|
578
|
-
base: "http://localhost:80/api/v1",
|
|
579
|
-
//base: "https://duqueapi.shardweb.app/api/v1",
|
|
580
|
-
field: (field) => `/${field}`,
|
|
581
|
-
fields: (...fields) => `${fields.join("/")}`,
|
|
582
|
-
guilds: {
|
|
583
|
-
create: () => `/guilds`,
|
|
584
|
-
get: (guildId) => `/guilds/${guildId}`,
|
|
585
|
-
getAll: () => `/guilds`,
|
|
586
|
-
delete: (guildId) => `/guilds/${guildId}`,
|
|
587
|
-
deleteAll: () => `/guilds`,
|
|
588
|
-
resource: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
|
|
589
|
-
resources: (guildId, ...resources) => `/guilds/${guildId}/manage/${resources.join("/")}`,
|
|
590
|
-
users: {
|
|
591
|
-
create: (guildId) => `/guilds/${guildId}/users`,
|
|
592
|
-
update: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
|
593
|
-
getAll: (guildId) => `/guilds/${guildId}/users`,
|
|
594
|
-
get: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
|
595
|
-
delete: (guildId, userId) => `/guilds/${guildId}/users/${userId}`,
|
|
596
|
-
deleteAll: (guildId) => `/guilds/${guildId}/users`,
|
|
597
|
-
resource: (guildId, userId, ...resource) => `/guilds/${guildId}/users/${userId}/${resource.join("/")}`
|
|
598
|
-
},
|
|
599
|
-
betusers: {
|
|
600
|
-
getAll: (guildId) => `/guilds/${guildId}/betusers`,
|
|
601
|
-
get: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
|
|
602
|
-
create: (guildId) => `/guilds/${guildId}/betusers`,
|
|
603
|
-
update: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
|
|
604
|
-
delete: (guildId, userId) => `/guilds/${guildId}/betusers/${userId}`,
|
|
605
|
-
deleteAll: (guildId) => `/guilds/${guildId}/betusers`,
|
|
606
|
-
resource: (guildId, userId, resourceName) => `/guilds/${guildId}/betusers/${userId}/${resourceName}`
|
|
607
|
-
},
|
|
608
|
-
matches: {
|
|
609
|
-
getAll: (guildId) => `/guilds/${guildId}/matches`,
|
|
610
|
-
get: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
|
|
611
|
-
create: (guildId) => `/guilds/${guildId}/matches`,
|
|
612
|
-
update: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
|
|
613
|
-
delete: (guildId, matchId) => `/guilds/${guildId}/matches/${matchId}`,
|
|
614
|
-
deleteAll: (guildId) => `/guilds/${guildId}/matches`,
|
|
615
|
-
resource: (guildId, matchId, ...resources) => `/guilds/${guildId}/matches/${matchId}/${resources.join("/")}`
|
|
616
|
-
},
|
|
617
|
-
bets: {
|
|
618
|
-
getAll: (guildId) => `/guilds/${guildId}/bets`,
|
|
619
|
-
get: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
|
|
620
|
-
create: (guildId) => `/guilds/${guildId}/bets`,
|
|
621
|
-
update: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
|
|
622
|
-
delete: (guildId, betId) => `/guilds/${guildId}/bets/${betId}`,
|
|
623
|
-
deleteAll: (guildId) => `/guilds/${guildId}/bets`,
|
|
624
|
-
resource: (guildId, betId, ...resources) => `/guilds/${guildId}/bets/${betId}/${resources.join("/")}`
|
|
625
|
-
},
|
|
626
|
-
tickets: {
|
|
627
|
-
getAll: (guildId) => `/guilds/${guildId}/tickets`,
|
|
628
|
-
get: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
|
|
629
|
-
create: (guildId) => `/guilds/${guildId}/tickets`,
|
|
630
|
-
update: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
|
|
631
|
-
delete: (guildId, ticketId) => `/guilds/${guildId}/tickets/${ticketId}`,
|
|
632
|
-
deleteAll: (guildId) => `/guilds/${guildId}/tickets`,
|
|
633
|
-
resource: (guildId, ticketId, ...resources) => `/guilds/${guildId}/tickets/${ticketId}/${resources.join("/")}`
|
|
634
|
-
},
|
|
635
|
-
mediators: {
|
|
636
|
-
getAll: (guildId) => `/guilds/${guildId}/mediators`,
|
|
637
|
-
get: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
|
|
638
|
-
create: (guildId) => `/guilds/${guildId}/mediators`,
|
|
639
|
-
update: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
|
|
640
|
-
delete: (guildId, mediatorId) => `/guilds/${guildId}/mediators/${mediatorId}`,
|
|
641
|
-
deleteAll: (guildId) => `/guilds/${guildId}/mediators`,
|
|
642
|
-
resource: (guildId, mediatorId, ...resources) => `/guilds/${guildId}/mediators/${mediatorId}/${resources.join("/")}`
|
|
643
|
-
},
|
|
644
|
-
shop: {
|
|
645
|
-
get: (guildId) => `/guilds/${guildId}/manage/shop`,
|
|
646
|
-
update: (guildId) => `/guilds/${guildId}/manage/shop`,
|
|
647
|
-
delete: (guildId) => `/guilds/${guildId}/manage/shop/ `,
|
|
648
|
-
resource: (guildId, ...resources) => `/guilds/${guildId}/manage/shop/${resources.join("/")}`,
|
|
649
|
-
products: {
|
|
650
|
-
getAll: (guildId) => `/guilds/${guildId}/manage/shop/products`,
|
|
651
|
-
get: (guildId, productId) => `/guilds/${guildId}/manage/shop/${productId}/products`,
|
|
652
|
-
create: (guildId) => `/guilds/${guildId}/manage/shop/products`,
|
|
653
|
-
update: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
|
|
654
|
-
delete: (guildId, productId) => `/guilds/${guildId}/manage/shop/products/${productId}`,
|
|
655
|
-
deleteAll: (guildId) => `/guilds/${guildId}/products/shop`,
|
|
656
|
-
resource: (guildId, productId, ...resources) => `/guilds/${guildId}/manage/shop/products/${productId}/${resources.join("/")}`
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
},
|
|
660
|
-
vipmembers: {
|
|
661
|
-
get: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
|
|
662
|
-
getAll: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
663
|
-
deleteAll: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
664
|
-
create: (guildId) => `/guilds/${guildId}/vipmembers`,
|
|
665
|
-
update: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`,
|
|
666
|
-
delete: (guildId, memberId) => `/guilds/${guildId}/vipmembers/${memberId}`
|
|
667
|
-
},
|
|
668
|
-
giveaways: {
|
|
669
|
-
get: (giveawayId) => `/giveaways/${giveawayId}`,
|
|
670
|
-
getAll: () => `/giveaways`,
|
|
671
|
-
deleteAll: () => `/giveaways`,
|
|
672
|
-
create: () => `/giveaways`,
|
|
673
|
-
update: (giveawayId) => `/giveaways/${giveawayId}`,
|
|
674
|
-
delete: (giveawayId) => `/giveaways/${giveawayId}`
|
|
675
|
-
}
|
|
676
|
-
};
|
|
677
|
-
|
|
678
|
-
// src/rest/REST.ts
|
|
679
|
-
var import_dotenv = __toESM(require_main());
|
|
680
|
-
|
|
681
|
-
// src/utils/Assertion.ts
|
|
682
|
-
var Assertion = class {
|
|
683
|
-
constructor() {
|
|
684
|
-
}
|
|
685
|
-
/**
|
|
686
|
-
* Tests if given key is a string
|
|
687
|
-
* @param key Key to test
|
|
688
|
-
*/
|
|
689
|
-
static assertString(key) {
|
|
690
|
-
if (typeof key !== "string") throw new Error(`${key} must be a string`);
|
|
691
|
-
if (!key || key === "") throw new Error(`${key} must be a string`);
|
|
692
|
-
return true;
|
|
693
|
-
}
|
|
694
|
-
/**
|
|
695
|
-
* Tests if given key is a number
|
|
696
|
-
* @param key Key to test
|
|
697
|
-
*/
|
|
698
|
-
static assertNumber(key) {
|
|
699
|
-
if (typeof key !== "number") throw new Error(`${key} must be a number`);
|
|
700
|
-
return true;
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* Tests if given key is a boolean
|
|
704
|
-
* @param key Key to test
|
|
705
|
-
*/
|
|
706
|
-
static assertBoolean(key) {
|
|
707
|
-
if (typeof key !== "boolean") throw new Error(`${key} must be a boolean`);
|
|
708
|
-
return true;
|
|
709
|
-
}
|
|
710
|
-
/**
|
|
711
|
-
* Tests if given key is an array
|
|
712
|
-
* @param key Key to test
|
|
713
|
-
*/
|
|
714
|
-
static assertArray(key) {
|
|
715
|
-
if (!Array.isArray(key)) throw new Error(`${key} must be an array`);
|
|
716
|
-
return true;
|
|
717
|
-
}
|
|
718
|
-
/**
|
|
719
|
-
* Tests if given key is an object
|
|
720
|
-
* @param key Key to test
|
|
721
|
-
*/
|
|
722
|
-
static assertObject(key) {
|
|
723
|
-
if (typeof key !== "object") throw new Error(`${key} must be an object`);
|
|
724
|
-
return true;
|
|
725
|
-
}
|
|
726
|
-
toString() {
|
|
727
|
-
return "string, number, boolean, array, object";
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
// src/rest/REST.ts
|
|
732
|
-
var import_undici = require("undici");
|
|
733
|
-
import_dotenv.default.config();
|
|
734
|
-
|
|
735
|
-
// src/structures/bet/GuildBet.ts
|
|
736
|
-
var _GuildBet_instances, updateInternals_fn;
|
|
737
|
-
var GuildBet = class {
|
|
738
|
-
constructor(data, manager) {
|
|
739
|
-
__privateAdd(this, _GuildBet_instances);
|
|
740
|
-
/** The bet's type */
|
|
741
|
-
__publicField(this, "type");
|
|
742
|
-
/** The bet's mode */
|
|
743
|
-
__publicField(this, "mode");
|
|
744
|
-
/** The bet's status */
|
|
745
|
-
__publicField(this, "status");
|
|
746
|
-
/** The bet's maximum size */
|
|
747
|
-
__publicField(this, "maximumSize");
|
|
748
|
-
/** The bet's price */
|
|
749
|
-
__publicField(this, "price");
|
|
750
|
-
/** The bet's players */
|
|
751
|
-
__publicField(this, "players");
|
|
752
|
-
__publicField(this, "teams");
|
|
753
|
-
/** The bet's channel */
|
|
754
|
-
__publicField(this, "channels");
|
|
755
|
-
/** The bet's messages */
|
|
756
|
-
__publicField(this, "messages");
|
|
757
|
-
/** The id of the winner */
|
|
758
|
-
__publicField(this, "winners");
|
|
759
|
-
/** The id of the loser */
|
|
760
|
-
__publicField(this, "losers");
|
|
761
|
-
/** The bet's creator id */
|
|
762
|
-
__publicField(this, "creatorId");
|
|
763
|
-
/** The bet's mediator */
|
|
764
|
-
__publicField(this, "mediatorId");
|
|
765
|
-
/** The bet's confirmers */
|
|
766
|
-
__publicField(this, "confirmed");
|
|
767
|
-
/** Creation Date */
|
|
768
|
-
__publicField(this, "createdAt");
|
|
769
|
-
/** Updated Date */
|
|
770
|
-
__publicField(this, "updatedAt");
|
|
771
|
-
/** Bet's id */
|
|
772
|
-
__publicField(this, "_id");
|
|
773
|
-
__publicField(this, "queues");
|
|
774
|
-
__publicField(this, "guild_id");
|
|
775
|
-
__publicField(this, "rest");
|
|
776
|
-
__publicField(this, "guild");
|
|
777
|
-
__publicField(this, "manager");
|
|
778
|
-
this.manager = manager;
|
|
779
|
-
this.guild = manager.guild;
|
|
780
|
-
this.rest = manager.rest;
|
|
781
|
-
this._id = data?._id;
|
|
782
|
-
this.guild_id = data?.guild_id;
|
|
783
|
-
this.type = data?.type;
|
|
784
|
-
this.mode = data?.mode;
|
|
785
|
-
this.status = data?.status;
|
|
786
|
-
this.maximumSize = data?.maximumSize;
|
|
787
|
-
this.price = data?.price;
|
|
788
|
-
this.teams = data?.teams;
|
|
789
|
-
this.channels = data?.channels;
|
|
790
|
-
this.players = new PlayerManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "players"));
|
|
791
|
-
this.messages = new MessagesManager(this, Routes.guilds.bets.resource(this.guild_id, this._id, "messages"));
|
|
792
|
-
this.winners = data?.winners;
|
|
793
|
-
this.losers = data?.losers;
|
|
794
|
-
this.creatorId = data?.creatorId;
|
|
795
|
-
this.mediatorId = data?.mediatorId;
|
|
796
|
-
this.confirmed = data?.confirmed;
|
|
797
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
798
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
799
|
-
this.queues = [];
|
|
800
|
-
for (let queue of data.queues ?? []) {
|
|
801
|
-
this.queues.push({
|
|
802
|
-
_id: queue?._id,
|
|
803
|
-
type: queue?.type,
|
|
804
|
-
players: queue?.players,
|
|
805
|
-
updatedAt: queue?.updatedAt ? new Date(queue?.updatedAt) : /* @__PURE__ */ new Date(),
|
|
806
|
-
createdAt: queue?.createdAt ? new Date(queue?.createdAt) : /* @__PURE__ */ new Date()
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
if (data?.messages?.length !== 0) this.messages.set(data.messages);
|
|
810
|
-
if (data?.players.length !== 0) this.players._set(data.players);
|
|
811
|
-
}
|
|
812
|
-
toString() {
|
|
813
|
-
return this._id;
|
|
814
|
-
}
|
|
815
|
-
async fetch() {
|
|
816
|
-
const route = Routes.guilds.bets.get(this.guild.id, this._id);
|
|
817
|
-
const response = await this.rest.request({ url: route, method: "GET" });
|
|
818
|
-
return __privateMethod(this, _GuildBet_instances, updateInternals_fn).call(this, response);
|
|
819
|
-
}
|
|
820
|
-
async addPlayer(player, queue_type) {
|
|
821
|
-
if (this.players.length === 2) return this;
|
|
822
|
-
if (this.players.has(player.id)) return this;
|
|
823
|
-
this.players.set(player.id, player);
|
|
824
|
-
if (queue_type) {
|
|
825
|
-
const queue = this.queues.find((q) => q.type === queue_type);
|
|
826
|
-
if (!queue) return this;
|
|
827
|
-
for (const q of this.queues) {
|
|
828
|
-
q.players = q.players.filter((p) => p.id !== player.id);
|
|
829
|
-
}
|
|
830
|
-
if (!queue.players.some((p) => p.id === player.id)) {
|
|
831
|
-
queue.players.push({ id: player.id });
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
return await this.update({
|
|
835
|
-
players: this.players.toArray(),
|
|
836
|
-
queues: this.queues
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
async removePlayer(player) {
|
|
840
|
-
if (!this.players.some((p) => p.id === player.id)) return this;
|
|
841
|
-
let players = this.players.toArray();
|
|
842
|
-
players = this.players.filter((p) => p.id !== player.id).toArray();
|
|
843
|
-
for (const q of this.queues) {
|
|
844
|
-
q.players = q.players.filter((p) => p.id !== player.id);
|
|
845
|
-
}
|
|
846
|
-
return await this.update({
|
|
847
|
-
players,
|
|
848
|
-
queues: this.queues
|
|
849
|
-
});
|
|
850
|
-
}
|
|
851
|
-
async update(data) {
|
|
852
|
-
const payload = data;
|
|
853
|
-
const route = Routes.guilds.bets.update(this.guild.id, this._id);
|
|
854
|
-
const response = await this.rest.request({ method: "patch", url: route, payload });
|
|
855
|
-
return __privateMethod(this, _GuildBet_instances, updateInternals_fn).call(this, response);
|
|
856
|
-
}
|
|
857
|
-
async delete() {
|
|
858
|
-
const route = Routes.guilds.bets.delete(this.manager.guild.id, this._id);
|
|
859
|
-
const response = await this.rest.request({
|
|
860
|
-
method: "DELETE",
|
|
861
|
-
url: route
|
|
862
|
-
});
|
|
863
|
-
this.rest.emit("betDelete", this);
|
|
864
|
-
this.manager.cache.delete(this._id);
|
|
865
|
-
return response;
|
|
866
|
-
}
|
|
867
|
-
toJSON() {
|
|
868
|
-
let json = {};
|
|
869
|
-
for (const [key, value] of Object.entries(this)) {
|
|
870
|
-
const exclude = ["rest", "guild", "manager"];
|
|
871
|
-
if (exclude.includes(key)) continue;
|
|
872
|
-
if (typeof value !== "function") {
|
|
873
|
-
json[key] = value;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
return {
|
|
877
|
-
...json,
|
|
878
|
-
messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : [],
|
|
879
|
-
players: this.players.toArray()
|
|
880
|
-
};
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
_GuildBet_instances = new WeakSet();
|
|
884
|
-
updateInternals_fn = function(data) {
|
|
885
|
-
for (let key in data) {
|
|
886
|
-
if (key === "_id" || key === "createdAt") continue;
|
|
887
|
-
if (key === "messages") {
|
|
888
|
-
this.messages.set(data[key]);
|
|
889
|
-
continue;
|
|
890
|
-
}
|
|
891
|
-
if (key === "players") {
|
|
892
|
-
this.players._set(data[key]);
|
|
893
|
-
continue;
|
|
894
|
-
}
|
|
895
|
-
if (key in this) {
|
|
896
|
-
this[key] = data[key];
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
if (data?.messages?.length !== 0) {
|
|
900
|
-
if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
|
|
901
|
-
else {
|
|
902
|
-
this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
|
|
903
|
-
this.messages.set(data.messages);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
907
|
-
this.createdAt = new Date(data.createdAt);
|
|
908
|
-
this.manager.set(this);
|
|
909
|
-
return this;
|
|
910
|
-
};
|
|
911
|
-
|
|
912
|
-
// src/structures/betuser/GuildBetUser.ts
|
|
913
|
-
var _GuildBetUser_instances, updateInternals_fn2;
|
|
914
|
-
var _GuildBetUser = class _GuildBetUser {
|
|
915
|
-
/**
|
|
916
|
-
* Bet user
|
|
917
|
-
* @param data The user's data
|
|
918
|
-
* @param manager The manager
|
|
919
|
-
* @param rest The rest client
|
|
920
|
-
*/
|
|
921
|
-
constructor(data, manager) {
|
|
922
|
-
__privateAdd(this, _GuildBetUser_instances);
|
|
923
|
-
/** User daily */
|
|
924
|
-
__publicField(this, "daily");
|
|
925
|
-
__publicField(this, "profile");
|
|
926
|
-
/** User's name */
|
|
927
|
-
__publicField(this, "id");
|
|
928
|
-
__publicField(this, "guild_id");
|
|
929
|
-
/** User's credit */
|
|
930
|
-
__publicField(this, "credit");
|
|
931
|
-
/** User's wins */
|
|
932
|
-
__publicField(this, "wins");
|
|
933
|
-
/** User's mvps */
|
|
934
|
-
__publicField(this, "mvps");
|
|
935
|
-
/** User's losses */
|
|
936
|
-
__publicField(this, "losses");
|
|
937
|
-
/** User's games */
|
|
938
|
-
__publicField(this, "games");
|
|
939
|
-
/** User's blacklist */
|
|
940
|
-
__publicField(this, "blacklist");
|
|
941
|
-
/** User's coins */
|
|
942
|
-
__publicField(this, "coins");
|
|
943
|
-
__publicField(this, "spins");
|
|
944
|
-
/** Creation Date */
|
|
945
|
-
__publicField(this, "createdAt");
|
|
946
|
-
/** Updated Date */
|
|
947
|
-
__publicField(this, "updatedAt");
|
|
948
|
-
__publicField(this, "consecutive_wins");
|
|
949
|
-
/** The given manager */
|
|
950
|
-
__publicField(this, "manager");
|
|
951
|
-
/** The rest client */
|
|
952
|
-
__publicField(this, "rest");
|
|
953
|
-
__publicField(this, "guild");
|
|
954
|
-
this.id = data?.id;
|
|
955
|
-
this.guild_id = data?.guild_id;
|
|
956
|
-
this.manager = manager;
|
|
957
|
-
this.rest = manager.rest;
|
|
958
|
-
this.guild = manager.guild;
|
|
959
|
-
this.wins = data?.wins;
|
|
960
|
-
this.coins = data?.coins;
|
|
961
|
-
this.losses = data?.losses;
|
|
962
|
-
this.credit = data?.credit;
|
|
963
|
-
this.spins = data?.spins;
|
|
964
|
-
this.daily = data?.daily;
|
|
965
|
-
this.games = data?.games;
|
|
966
|
-
this.blacklist = data?.blacklist;
|
|
967
|
-
this.consecutive_wins = data?.consecutive_wins;
|
|
968
|
-
this.profile = data?.profile;
|
|
969
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
970
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
971
|
-
}
|
|
972
|
-
/** String representation of this user */
|
|
973
|
-
toString() {
|
|
974
|
-
return `<@${this.id}>`;
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Fetches the user
|
|
978
|
-
* @returns New Instance of the user
|
|
979
|
-
*/
|
|
980
|
-
async fetch() {
|
|
981
|
-
const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
|
|
982
|
-
const response = await this.rest.request({
|
|
983
|
-
method: "get",
|
|
984
|
-
url: route
|
|
985
|
-
});
|
|
986
|
-
const user = new _GuildBetUser(response, this.manager);
|
|
987
|
-
this.manager.cache.set(user.id, user);
|
|
988
|
-
this.rest.betusers.set(user.id, user);
|
|
989
|
-
return user;
|
|
990
|
-
}
|
|
991
|
-
/**
|
|
992
|
-
* Set the user blacklist
|
|
993
|
-
* @param value Value to set to
|
|
994
|
-
* @returns GuildBetUser
|
|
995
|
-
*/
|
|
996
|
-
async setBlacklist(value) {
|
|
997
|
-
const route = Routes.guilds.betusers.resource(this.manager.guild.id, this.id, "blacklist");
|
|
998
|
-
const payload = { set: value };
|
|
999
|
-
await this.rest.request({
|
|
1000
|
-
method: "patch",
|
|
1001
|
-
url: route,
|
|
1002
|
-
payload
|
|
1003
|
-
});
|
|
1004
|
-
this.blacklist = value;
|
|
1005
|
-
this.manager.cache.set(this.id, this);
|
|
1006
|
-
this.rest.betusers.set(this.id, this);
|
|
1007
|
-
return this;
|
|
1008
|
-
}
|
|
1009
|
-
async reset() {
|
|
1010
|
-
const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
|
|
1011
|
-
const payload = { reset: true };
|
|
1012
|
-
const response = await this.rest.request({
|
|
1013
|
-
method: "DELETE",
|
|
1014
|
-
url: route,
|
|
1015
|
-
payload
|
|
1016
|
-
});
|
|
1017
|
-
return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn2).call(this, response);
|
|
1018
|
-
}
|
|
1019
|
-
async updateProfile(data) {
|
|
1020
|
-
const _data = {
|
|
1021
|
-
profile: {
|
|
1022
|
-
avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
|
|
1023
|
-
bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
|
|
1024
|
-
bio: data.bio || this.profile.bio || "Melhor da minha aldeia (use !bio para alterar)",
|
|
1025
|
-
name: data.name || this.profile.name || "",
|
|
1026
|
-
textColor: data.textColor || this.profile.textColor || "#ffffff",
|
|
1027
|
-
primaryColor: data.primaryColor || this.profile.primaryColor || "#272727",
|
|
1028
|
-
secondaryColor: data.secondaryColor || this.profile.secondaryColor || "#151515"
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
const route = Routes.guilds.betusers.update(this.manager.guild.id, this.id);
|
|
1032
|
-
const response = await this.rest.request({
|
|
1033
|
-
method: "patch",
|
|
1034
|
-
url: route,
|
|
1035
|
-
payload: _data
|
|
1036
|
-
});
|
|
1037
|
-
return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn2).call(this, response);
|
|
1038
|
-
}
|
|
1039
|
-
/**
|
|
1040
|
-
* Update certain property
|
|
1041
|
-
* @param data The new data to update with
|
|
1042
|
-
* @returns
|
|
1043
|
-
*/
|
|
1044
|
-
async update(data) {
|
|
1045
|
-
if (!data?.type) data.type = "add";
|
|
1046
|
-
const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
|
|
1047
|
-
let payload = {};
|
|
1048
|
-
const numericFields = ["wins", "credit", "losses", "mvps", "games", "coins", "spins", "consecutive_wins"];
|
|
1049
|
-
const arrayFields = ["items", "original_channels", "adverts", "accessories"];
|
|
1050
|
-
if (data?.type === "add" || data?.type === "remove") {
|
|
1051
|
-
for (const key in data) {
|
|
1052
|
-
if (key === "type") continue;
|
|
1053
|
-
const value = data[key];
|
|
1054
|
-
if (numericFields.includes(key)) {
|
|
1055
|
-
const current = this[key] || 0;
|
|
1056
|
-
const num = value || 0;
|
|
1057
|
-
payload[key] = Math.max(0, data?.type === "add" ? current + num : current - num);
|
|
1058
|
-
} else if (key === "blacklist") {
|
|
1059
|
-
payload["blacklist"] = value;
|
|
1060
|
-
} else if (key === "profile") {
|
|
1061
|
-
payload["profile"] = value;
|
|
1062
|
-
} else if (arrayFields.includes(key)) {
|
|
1063
|
-
const current = this[key];
|
|
1064
|
-
const incoming = value;
|
|
1065
|
-
payload[key] = data?.type === "add" ? [.../* @__PURE__ */ new Set([...current, ...incoming])] : current.filter((x) => !incoming.includes(x));
|
|
1066
|
-
}
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
const response = await this.rest.request({
|
|
1070
|
-
method: "patch",
|
|
1071
|
-
url: route,
|
|
1072
|
-
payload
|
|
1073
|
-
});
|
|
1074
|
-
return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn2).call(this, response);
|
|
1075
|
-
}
|
|
1076
|
-
async _update(data) {
|
|
1077
|
-
const route = Routes.guilds.betusers.get(this.manager.guild.id, this.id);
|
|
1078
|
-
let payload = {};
|
|
1079
|
-
const response = await this.rest.request({
|
|
1080
|
-
method: "put",
|
|
1081
|
-
url: route,
|
|
1082
|
-
payload
|
|
1083
|
-
});
|
|
1084
|
-
return __privateMethod(this, _GuildBetUser_instances, updateInternals_fn2).call(this, response);
|
|
1085
|
-
}
|
|
1086
|
-
async delete() {
|
|
1087
|
-
const route = Routes.guilds.betusers.delete(this.manager.guild.id, this.id);
|
|
1088
|
-
const response = await this.rest.request({
|
|
1089
|
-
method: "DELETE",
|
|
1090
|
-
url: route
|
|
1091
|
-
});
|
|
1092
|
-
this.rest.emit("betuserDelete", this);
|
|
1093
|
-
this.manager.cache.delete(this.id);
|
|
1094
|
-
return response;
|
|
1095
|
-
}
|
|
1096
|
-
toJSON() {
|
|
1097
|
-
let json = {};
|
|
1098
|
-
for (const [key, value] of Object.entries(this)) {
|
|
1099
|
-
const exclude = ["rest", "guilds", "guild", "manager"];
|
|
1100
|
-
if (exclude.includes(key)) continue;
|
|
1101
|
-
if (typeof value !== "function") {
|
|
1102
|
-
json[key] = value;
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
return json;
|
|
1106
|
-
}
|
|
1107
|
-
};
|
|
1108
|
-
_GuildBetUser_instances = new WeakSet();
|
|
1109
|
-
updateInternals_fn2 = function(data) {
|
|
1110
|
-
for (let key in data) {
|
|
1111
|
-
if (key === "id" || key === "createdAt") continue;
|
|
1112
|
-
if (key in this) {
|
|
1113
|
-
this[key] = data[key];
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
1117
|
-
this.createdAt = new Date(data.createdAt);
|
|
1118
|
-
this.manager.set(this);
|
|
1119
|
-
this.rest.emit("betuserUpdate", this);
|
|
1120
|
-
return this;
|
|
1121
|
-
};
|
|
1122
|
-
var GuildBetUser = _GuildBetUser;
|
|
1123
|
-
|
|
1124
|
-
// src/structures/logentry/LogEntry.ts
|
|
1125
|
-
var _LogEntry_instances, updateInternals_fn3;
|
|
1126
|
-
var LogEntry = class {
|
|
1127
|
-
constructor(data, manager) {
|
|
1128
|
-
__privateAdd(this, _LogEntry_instances);
|
|
1129
|
-
__publicField(this, "_id");
|
|
1130
|
-
__publicField(this, "guild_id");
|
|
1131
|
-
__publicField(this, "user_id");
|
|
1132
|
-
__publicField(this, "admin_id");
|
|
1133
|
-
__publicField(this, "object_id");
|
|
1134
|
-
__publicField(this, "type");
|
|
1135
|
-
__publicField(this, "description");
|
|
1136
|
-
__publicField(this, "change");
|
|
1137
|
-
__publicField(this, "before");
|
|
1138
|
-
__publicField(this, "after");
|
|
1139
|
-
__publicField(this, "logs_channel_id");
|
|
1140
|
-
__publicField(this, "createdAt");
|
|
1141
|
-
__publicField(this, "updatedAt");
|
|
1142
|
-
__publicField(this, "manager");
|
|
1143
|
-
/** The given guild */
|
|
1144
|
-
__publicField(this, "guild");
|
|
1145
|
-
/** The rest client */
|
|
1146
|
-
__publicField(this, "rest");
|
|
1147
|
-
this.manager = manager;
|
|
1148
|
-
this.guild = manager.guild;
|
|
1149
|
-
this._id = data?._id;
|
|
1150
|
-
this.guild_id = data?.guild_id;
|
|
1151
|
-
this.user_id = data?.user_id;
|
|
1152
|
-
this.admin_id = data?.admin_id;
|
|
1153
|
-
this.object_id = data?.object_id;
|
|
1154
|
-
this.type = data?.type;
|
|
1155
|
-
this.description = data?.description;
|
|
1156
|
-
this.change = data?.change;
|
|
1157
|
-
this.before = data?.before;
|
|
1158
|
-
this.after = data?.after;
|
|
1159
|
-
this.logs_channel_id = data?.logs_channel_id;
|
|
1160
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
1161
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1162
|
-
}
|
|
1163
|
-
async fetch() {
|
|
1164
|
-
const route = Routes.fields("guilds", this.guild.id, "logentries", this._id);
|
|
1165
|
-
const response = await this.rest.request({ url: route, method: "GET" });
|
|
1166
|
-
return __privateMethod(this, _LogEntry_instances, updateInternals_fn3).call(this, response);
|
|
1167
|
-
}
|
|
1168
|
-
toJSON() {
|
|
1169
|
-
const json = {};
|
|
1170
|
-
for (const [key, value] of Object.entries(this)) {
|
|
1171
|
-
if (typeof value !== "function") {
|
|
1172
|
-
json[key] = value;
|
|
1173
|
-
}
|
|
1174
|
-
}
|
|
1175
|
-
return json;
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
_LogEntry_instances = new WeakSet();
|
|
1179
|
-
updateInternals_fn3 = function(data) {
|
|
1180
|
-
for (let key in data) {
|
|
1181
|
-
if (key === "id" || key === "createdAt") continue;
|
|
1182
|
-
if (key in this) {
|
|
1183
|
-
this[key] = data[key];
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
1187
|
-
this.manager.set(this);
|
|
1188
|
-
return this;
|
|
1189
|
-
};
|
|
1190
|
-
|
|
1191
|
-
// src/structures/match/GuildMatch.ts
|
|
1192
|
-
var _GuildMatch_instances, updateInternals_fn4;
|
|
1193
|
-
var _GuildMatch = class _GuildMatch {
|
|
1194
|
-
/**
|
|
1195
|
-
* GuildMatch match
|
|
1196
|
-
* @param data The match's data
|
|
1197
|
-
* @param guild The guild
|
|
1198
|
-
* @param rest The rest client
|
|
1199
|
-
*/
|
|
1200
|
-
constructor(data, manager) {
|
|
1201
|
-
__privateAdd(this, _GuildMatch_instances);
|
|
1202
|
-
__publicField(this, "_id");
|
|
1203
|
-
__publicField(this, "selections");
|
|
1204
|
-
/** Match's type */
|
|
1205
|
-
__publicField(this, "type");
|
|
1206
|
-
__publicField(this, "channels");
|
|
1207
|
-
__publicField(this, "guild_id");
|
|
1208
|
-
/** Match's status */
|
|
1209
|
-
__publicField(this, "status");
|
|
1210
|
-
/** Match's challenge */
|
|
1211
|
-
__publicField(this, "challenge");
|
|
1212
|
-
/** Match's players */
|
|
1213
|
-
__publicField(this, "players");
|
|
1214
|
-
__publicField(this, "teams");
|
|
1215
|
-
/** Match's winners */
|
|
1216
|
-
__publicField(this, "winners");
|
|
1217
|
-
/** Match's losers */
|
|
1218
|
-
__publicField(this, "losers");
|
|
1219
|
-
/** Match's maximum size */
|
|
1220
|
-
__publicField(this, "maximumSize");
|
|
1221
|
-
/** Match's kicked out */
|
|
1222
|
-
__publicField(this, "kickedOut");
|
|
1223
|
-
/** Match's confirmed */
|
|
1224
|
-
__publicField(this, "confirmed");
|
|
1225
|
-
/** Match's leaders */
|
|
1226
|
-
__publicField(this, "leaders");
|
|
1227
|
-
/** Match's creator id */
|
|
1228
|
-
__publicField(this, "creatorId");
|
|
1229
|
-
/** Match's room creator id */
|
|
1230
|
-
__publicField(this, "roomCreatorId");
|
|
1231
|
-
/** Creation Date */
|
|
1232
|
-
__publicField(this, "createdAt");
|
|
1233
|
-
/** Updated Date */
|
|
1234
|
-
__publicField(this, "updatedAt");
|
|
1235
|
-
__publicField(this, "messages");
|
|
1236
|
-
/** Match's id */
|
|
1237
|
-
__publicField(this, "mvps");
|
|
1238
|
-
__publicField(this, "manager");
|
|
1239
|
-
__publicField(this, "bet");
|
|
1240
|
-
__publicField(this, "admin_id");
|
|
1241
|
-
/** The given guild */
|
|
1242
|
-
__publicField(this, "guild");
|
|
1243
|
-
/** The rest client */
|
|
1244
|
-
__publicField(this, "rest");
|
|
1245
|
-
__publicField(this, "key");
|
|
1246
|
-
this._id = data?._id;
|
|
1247
|
-
this.guild_id = data?.guild_id;
|
|
1248
|
-
this.manager = manager;
|
|
1249
|
-
this.guild = manager.guild;
|
|
1250
|
-
this.rest = manager.rest;
|
|
1251
|
-
this.admin_id = data?.admin_id;
|
|
1252
|
-
this.challenge = data?.challenge;
|
|
1253
|
-
this.players = data?.players;
|
|
1254
|
-
this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
|
|
1255
|
-
this.channels = data?.channels;
|
|
1256
|
-
this.type = data?.type;
|
|
1257
|
-
this.status = data?.status;
|
|
1258
|
-
this.bet = this.guild.bets.cache.get(data?.bet?._id);
|
|
1259
|
-
this.mvps = data?.mvps;
|
|
1260
|
-
this.winners = data?.winners;
|
|
1261
|
-
this.losers = data?.losers;
|
|
1262
|
-
this.maximumSize = data?.maximumSize;
|
|
1263
|
-
this.kickedOut = data?.kickedOut;
|
|
1264
|
-
this.confirmed = data?.confirmed;
|
|
1265
|
-
this.teams = data?.teams;
|
|
1266
|
-
this.leaders = data?.leaders;
|
|
1267
|
-
this.creatorId = data?.creatorId;
|
|
1268
|
-
this.roomCreatorId = data?.roomCreatorId;
|
|
1269
|
-
this.selections = data?.selections;
|
|
1270
|
-
this.key = "matches";
|
|
1271
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
1272
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1273
|
-
if (data?.messages?.length !== 0) this.messages.set(data.messages);
|
|
1274
|
-
}
|
|
1275
|
-
/**
|
|
1276
|
-
* Fetches the match
|
|
1277
|
-
* @returns New Instance of the match
|
|
1278
|
-
*/
|
|
1279
|
-
async fetch() {
|
|
1280
|
-
const route = Routes.guilds.matches.get(this.guild.id, this._id);
|
|
1281
|
-
const response = await this.rest.request({
|
|
1282
|
-
method: "get",
|
|
1283
|
-
url: route
|
|
1284
|
-
});
|
|
1285
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1286
|
-
}
|
|
1287
|
-
async addConfirmed(type, id) {
|
|
1288
|
-
const confirmed = this.confirmed.find((c) => c.type === type);
|
|
1289
|
-
const idsToAdd = Array.isArray(id) ? id : [id];
|
|
1290
|
-
if (!confirmed) {
|
|
1291
|
-
this.confirmed.push({ type, ids: [...idsToAdd], count: idsToAdd.length });
|
|
1292
|
-
} else {
|
|
1293
|
-
const chIndex = this.confirmed.findIndex((ch) => ch.type === type);
|
|
1294
|
-
const mergedIds = [.../* @__PURE__ */ new Set([...confirmed.ids || [], ...idsToAdd])];
|
|
1295
|
-
this.confirmed[chIndex] = { ...confirmed, ids: mergedIds, count: mergedIds.length };
|
|
1296
|
-
}
|
|
1297
|
-
return this.update({ confirmed: this.confirmed });
|
|
1298
|
-
}
|
|
1299
|
-
async setConfirmed(set) {
|
|
1300
|
-
Assertion.assertObject(set);
|
|
1301
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "confirmed");
|
|
1302
|
-
const response = await this.rest.request({
|
|
1303
|
-
method: "PATCH",
|
|
1304
|
-
url: route,
|
|
1305
|
-
payload: set
|
|
1306
|
-
});
|
|
1307
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1308
|
-
}
|
|
1309
|
-
async setStatus(status) {
|
|
1310
|
-
Assertion.assertString(status);
|
|
1311
|
-
const payload = { set: status.toLowerCase() };
|
|
1312
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "status");
|
|
1313
|
-
const response = await this.rest.request({
|
|
1314
|
-
method: "PATCH",
|
|
1315
|
-
url: route,
|
|
1316
|
-
payload
|
|
1317
|
-
});
|
|
1318
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1319
|
-
}
|
|
1320
|
-
async setWinners(players) {
|
|
1321
|
-
if (!Array.isArray(players)) players = [players];
|
|
1322
|
-
const payload = { set: players };
|
|
1323
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "winners");
|
|
1324
|
-
const response = await this.rest.request({
|
|
1325
|
-
method: "PATCH",
|
|
1326
|
-
url: route,
|
|
1327
|
-
payload
|
|
1328
|
-
});
|
|
1329
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1330
|
-
}
|
|
1331
|
-
async setLoser(players) {
|
|
1332
|
-
if (!Array.isArray(players)) players = [players];
|
|
1333
|
-
const payload = { set: players };
|
|
1334
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "losers");
|
|
1335
|
-
const response = await this.rest.request({
|
|
1336
|
-
method: "PATCH",
|
|
1337
|
-
url: route,
|
|
1338
|
-
payload
|
|
1339
|
-
});
|
|
1340
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1341
|
-
}
|
|
1342
|
-
async setMvps(...usersId) {
|
|
1343
|
-
const payload = { set: usersId };
|
|
1344
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "mvps");
|
|
1345
|
-
const response = await this.rest.request({
|
|
1346
|
-
method: "PATCH",
|
|
1347
|
-
url: route,
|
|
1348
|
-
payload
|
|
1349
|
-
});
|
|
1350
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1351
|
-
}
|
|
1352
|
-
async setRoomCreatorId(userId) {
|
|
1353
|
-
Assertion.assertString(userId);
|
|
1354
|
-
const payload = { set: userId };
|
|
1355
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "roomCreatorId");
|
|
1356
|
-
const response = await this.rest.request({
|
|
1357
|
-
method: "PATCH",
|
|
1358
|
-
url: route,
|
|
1359
|
-
payload
|
|
1360
|
-
});
|
|
1361
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1362
|
-
}
|
|
1363
|
-
async setRoomAdminId(userId) {
|
|
1364
|
-
Assertion.assertString(userId);
|
|
1365
|
-
const payload = { set: userId };
|
|
1366
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id, "admin_id");
|
|
1367
|
-
const response = await this.rest.request({
|
|
1368
|
-
method: "PATCH",
|
|
1369
|
-
url: route,
|
|
1370
|
-
payload
|
|
1371
|
-
});
|
|
1372
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1373
|
-
}
|
|
1374
|
-
async kick(player) {
|
|
1375
|
-
this.players = this.players.filter((p) => p.id !== player.id);
|
|
1376
|
-
this.leaders = this.leaders.filter((p) => p.id !== player.id);
|
|
1377
|
-
const teamIndex = this.teams.findIndex((t) => t.some((p) => p.id === player.id));
|
|
1378
|
-
if (teamIndex !== -1) {
|
|
1379
|
-
let team = this.teams.find((t) => t.some((p) => p.id === player.id));
|
|
1380
|
-
team = team.filter((p) => p.id === player.id);
|
|
1381
|
-
this.teams[teamIndex] = team;
|
|
1382
|
-
}
|
|
1383
|
-
return await this.update(this.toJSON());
|
|
1384
|
-
}
|
|
1385
|
-
async update(data) {
|
|
1386
|
-
const route = Routes.guilds.matches.get(this.guild.id, this._id);
|
|
1387
|
-
if (data?.bet && data?.bet instanceof GuildBet) {
|
|
1388
|
-
data.bet = data.bet.toJSON();
|
|
1389
|
-
}
|
|
1390
|
-
const response = await this.rest.request({
|
|
1391
|
-
method: "patch",
|
|
1392
|
-
url: route,
|
|
1393
|
-
payload: data
|
|
1394
|
-
});
|
|
1395
|
-
this.rest.emit("matchUpdate", this, new _GuildMatch(response, this.manager));
|
|
1396
|
-
return await __privateMethod(this, _GuildMatch_instances, updateInternals_fn4).call(this, response);
|
|
1397
|
-
}
|
|
1398
|
-
async delete() {
|
|
1399
|
-
const route = Routes.guilds.matches.resource(this.guild.id, this._id);
|
|
1400
|
-
const response = await this.rest.request({
|
|
1401
|
-
method: "DELETE",
|
|
1402
|
-
url: route
|
|
1403
|
-
});
|
|
1404
|
-
this.manager.cache.delete(this?._id);
|
|
1405
|
-
this.rest.matches.delete(this?._id);
|
|
1406
|
-
return response;
|
|
1407
|
-
}
|
|
1408
|
-
toJSON() {
|
|
1409
|
-
let json = {};
|
|
1410
|
-
for (const [key, value] of Object.entries(this)) {
|
|
1411
|
-
const exclude = ["rest", "guilds", "guild", "manager"];
|
|
1412
|
-
if (exclude.includes(key)) continue;
|
|
1413
|
-
if (typeof value !== "function") {
|
|
1414
|
-
json[key] = value;
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
return {
|
|
1418
|
-
...json,
|
|
1419
|
-
messages: this?.messages instanceof MessagesManager ? this.messages?.cache?.toArray() : []
|
|
1420
|
-
};
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
|
-
_GuildMatch_instances = new WeakSet();
|
|
1424
|
-
updateInternals_fn4 = async function(data) {
|
|
1425
|
-
if (!data) return;
|
|
1426
|
-
for (let key in data) {
|
|
1427
|
-
if (key === "id" || key === "createdAt" || key === "messages") continue;
|
|
1428
|
-
if (key in this) {
|
|
1429
|
-
this[key] = data[key];
|
|
1430
|
-
}
|
|
1431
|
-
if (key === "bet") {
|
|
1432
|
-
this.bet = this.guild.bets.set(data.bet);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
if (data?.messages?.length !== 0) {
|
|
1436
|
-
if (this?.messages instanceof MessagesManager) this.messages.set(data.messages);
|
|
1437
|
-
else {
|
|
1438
|
-
this.messages = new MessagesManager(this, Routes.guilds.matches.resource(this.guild_id, this._id, "messages"));
|
|
1439
|
-
this.messages.set(data.messages);
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
if (!(this.bet instanceof GuildBet) && data?.bet) {
|
|
1443
|
-
this.bet = this.guild.bets.cache.get(data._id) ?? await this.guild.bets.fetch({ betId: data?.bet?._id });
|
|
1444
|
-
}
|
|
1445
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
1446
|
-
this.manager.set(this);
|
|
1447
|
-
return this;
|
|
1448
|
-
};
|
|
1449
|
-
var GuildMatch = _GuildMatch;
|
|
1450
|
-
|
|
1451
|
-
// src/structures/mediator/GuildMediator.ts
|
|
1452
|
-
var _GuildMediator_instances, updateInternals_fn5;
|
|
1453
|
-
var _GuildMediator = class _GuildMediator {
|
|
1454
|
-
/**
|
|
1455
|
-
* Bet user
|
|
1456
|
-
* @param data The user's data
|
|
1457
|
-
* @param manager The manager
|
|
1458
|
-
* @param rest The rest client
|
|
1459
|
-
*/
|
|
1460
|
-
constructor(data, manager) {
|
|
1461
|
-
__privateAdd(this, _GuildMediator_instances);
|
|
1462
|
-
/** User's name */
|
|
1463
|
-
__publicField(this, "id");
|
|
1464
|
-
__publicField(this, "guild_id");
|
|
1465
|
-
/** User's games */
|
|
1466
|
-
__publicField(this, "games");
|
|
1467
|
-
__publicField(this, "paypal");
|
|
1468
|
-
__publicField(this, "revolut");
|
|
1469
|
-
__publicField(this, "mbway");
|
|
1470
|
-
__publicField(this, "external_links");
|
|
1471
|
-
/** Creation Date */
|
|
1472
|
-
__publicField(this, "createdAt");
|
|
1473
|
-
/** Updated Date */
|
|
1474
|
-
__publicField(this, "updatedAt");
|
|
1475
|
-
/** The given manager */
|
|
1476
|
-
__publicField(this, "manager");
|
|
1477
|
-
/** The rest client */
|
|
1478
|
-
__publicField(this, "rest");
|
|
1479
|
-
__publicField(this, "guild");
|
|
1480
|
-
this.id = data?.id;
|
|
1481
|
-
this.guild_id = data?.guild_id;
|
|
1482
|
-
this.manager = manager;
|
|
1483
|
-
this.rest = manager.rest;
|
|
1484
|
-
this.guild = manager.guild;
|
|
1485
|
-
this.games = data?.games;
|
|
1486
|
-
this.paypal = data?.paypal;
|
|
1487
|
-
this.revolut = data?.revolut;
|
|
1488
|
-
this.mbway = data?.mbway;
|
|
1489
|
-
this.external_links = data?.external_links;
|
|
1490
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
1491
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1492
|
-
}
|
|
1493
|
-
/** String representation of this user */
|
|
1494
|
-
toString() {
|
|
1495
|
-
return `<@${this.id}>`;
|
|
1496
|
-
}
|
|
1497
|
-
/**
|
|
1498
|
-
* Fetches the user
|
|
1499
|
-
* @returns New Instance of the user
|
|
1500
|
-
*/
|
|
1501
|
-
async fetch() {
|
|
1502
|
-
const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
|
|
1503
|
-
const response = await this.rest.request({
|
|
1504
|
-
method: "get",
|
|
1505
|
-
url: route
|
|
1506
|
-
});
|
|
1507
|
-
const user = new _GuildMediator(response, this.manager);
|
|
1508
|
-
this.manager.cache.set(user.id, user);
|
|
1509
|
-
this.rest.mediators.set(user.id, user);
|
|
1510
|
-
return user;
|
|
1511
|
-
}
|
|
1512
|
-
async reset() {
|
|
1513
|
-
const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
|
|
1514
|
-
const payload = { reset: true };
|
|
1515
|
-
const response = await this.rest.request({
|
|
1516
|
-
method: "DELETE",
|
|
1517
|
-
url: route,
|
|
1518
|
-
payload
|
|
1519
|
-
});
|
|
1520
|
-
return __privateMethod(this, _GuildMediator_instances, updateInternals_fn5).call(this, response);
|
|
1521
|
-
}
|
|
1522
|
-
/**
|
|
1523
|
-
* Update certain property
|
|
1524
|
-
* @param data The new data to update with
|
|
1525
|
-
* @returns
|
|
1526
|
-
*/
|
|
1527
|
-
async update(data) {
|
|
1528
|
-
const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
|
|
1529
|
-
let payload = data;
|
|
1530
|
-
const response = await this.rest.request({
|
|
1531
|
-
method: "patch",
|
|
1532
|
-
url: route,
|
|
1533
|
-
payload
|
|
1534
|
-
});
|
|
1535
|
-
return __privateMethod(this, _GuildMediator_instances, updateInternals_fn5).call(this, response);
|
|
1536
|
-
}
|
|
1537
|
-
async setPaymentlink(type, link) {
|
|
1538
|
-
const route = Routes.guilds.mediators.get(this.manager.guild.id, this.id);
|
|
1539
|
-
let payload = { [type]: link };
|
|
1540
|
-
const response = await this.rest.request({
|
|
1541
|
-
method: "patch",
|
|
1542
|
-
url: route,
|
|
1543
|
-
payload
|
|
1544
|
-
});
|
|
1545
|
-
return __privateMethod(this, _GuildMediator_instances, updateInternals_fn5).call(this, response);
|
|
1546
|
-
}
|
|
1547
|
-
async delete() {
|
|
1548
|
-
const route = Routes.guilds.mediators.delete(this.manager.guild.id, this.id);
|
|
1549
|
-
const response = await this.rest.request({
|
|
1550
|
-
method: "DELETE",
|
|
1551
|
-
url: route
|
|
1552
|
-
});
|
|
1553
|
-
this.manager.cache.delete(this.id);
|
|
1554
|
-
return response;
|
|
1555
|
-
}
|
|
1556
|
-
toJSON() {
|
|
1557
|
-
let json = {};
|
|
1558
|
-
for (const [key, value] of Object.entries(this)) {
|
|
1559
|
-
const exclude = ["rest", "guilds", "guild", "manager"];
|
|
1560
|
-
if (exclude.includes(key)) continue;
|
|
1561
|
-
if (typeof value !== "function") {
|
|
1562
|
-
json[key] = value;
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
return json;
|
|
1566
|
-
}
|
|
1567
|
-
};
|
|
1568
|
-
_GuildMediator_instances = new WeakSet();
|
|
1569
|
-
updateInternals_fn5 = function(data) {
|
|
1570
|
-
for (let key in data) {
|
|
1571
|
-
if (key === "id" || key === "createdAt") continue;
|
|
1572
|
-
if (key in this) {
|
|
1573
|
-
this[key] = data[key];
|
|
1574
|
-
}
|
|
1575
|
-
}
|
|
1576
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
1577
|
-
this.createdAt = new Date(data.createdAt);
|
|
1578
|
-
this.manager.set(this);
|
|
1579
|
-
return this;
|
|
1580
|
-
};
|
|
1581
|
-
var GuildMediator = _GuildMediator;
|
|
1582
|
-
|
|
1583
|
-
// src/structures/user/GuildUser.ts
|
|
1584
|
-
var _GuildUser_instances, updateInternals_fn6;
|
|
1585
|
-
var _GuildUser = class _GuildUser {
|
|
1586
|
-
/**
|
|
1587
|
-
* Bet user
|
|
1588
|
-
* @param data The user's data
|
|
1589
|
-
* @param manager The manager
|
|
1590
|
-
* @param rest The rest client
|
|
1591
|
-
*/
|
|
1592
|
-
constructor(data, manager) {
|
|
1593
|
-
__privateAdd(this, _GuildUser_instances);
|
|
1594
|
-
/** User's id */
|
|
1595
|
-
__publicField(this, "id");
|
|
1596
|
-
__publicField(this, "guild_id");
|
|
1597
|
-
/** User's daily */
|
|
1598
|
-
__publicField(this, "daily");
|
|
1599
|
-
/** User's points */
|
|
1600
|
-
__publicField(this, "points");
|
|
1601
|
-
/** User's wins */
|
|
1602
|
-
__publicField(this, "wins");
|
|
1603
|
-
/** User's mvps */
|
|
1604
|
-
__publicField(this, "mvps");
|
|
1605
|
-
/** User's losses */
|
|
1606
|
-
__publicField(this, "losses");
|
|
1607
|
-
/** User's games */
|
|
1608
|
-
__publicField(this, "games");
|
|
1609
|
-
/** If user is blacklisted */
|
|
1610
|
-
__publicField(this, "blacklist");
|
|
1611
|
-
/** User's accessories such as double point */
|
|
1612
|
-
__publicField(this, "accessories");
|
|
1613
|
-
/** User's original channels */
|
|
1614
|
-
__publicField(this, "original_channels");
|
|
1615
|
-
__publicField(this, "profile");
|
|
1616
|
-
__publicField(this, "creations");
|
|
1617
|
-
/** User's items */
|
|
1618
|
-
__publicField(this, "adverts");
|
|
1619
|
-
__publicField(this, "spins");
|
|
1620
|
-
/** Creation Date */
|
|
1621
|
-
__publicField(this, "createdAt");
|
|
1622
|
-
/** Updated Date */
|
|
1623
|
-
__publicField(this, "updatedAt");
|
|
1624
|
-
/** The given manager */
|
|
1625
|
-
__publicField(this, "manager");
|
|
1626
|
-
/** The rest client */
|
|
1627
|
-
__publicField(this, "rest");
|
|
1628
|
-
this.id = data?.id;
|
|
1629
|
-
this.guild_id = data?.guild_id;
|
|
1630
|
-
this.manager = manager;
|
|
1631
|
-
this.rest = manager.rest;
|
|
1632
|
-
this.wins = data?.wins;
|
|
1633
|
-
this.losses = data?.losses;
|
|
1634
|
-
this.mvps = data?.mvps;
|
|
1635
|
-
this.points = data?.points;
|
|
1636
|
-
this.creations = data?.creations;
|
|
1637
|
-
this.spins = data.spins;
|
|
1638
|
-
this.daily = data?.daily;
|
|
1639
|
-
this.games = data?.games;
|
|
1640
|
-
this.blacklist = data?.blacklist;
|
|
1641
|
-
this.accessories = data?.accessories;
|
|
1642
|
-
this.original_channels = data?.original_channels;
|
|
1643
|
-
this.profile = data?.profile;
|
|
1644
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
1645
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1646
|
-
this.adverts = [];
|
|
1647
|
-
for (let _adv of data?.adverts || []) {
|
|
1648
|
-
this.adverts.push({
|
|
1649
|
-
_id: _adv._id,
|
|
1650
|
-
admin_id: _adv.admin_id,
|
|
1651
|
-
role_id: _adv.role_id,
|
|
1652
|
-
reason: _adv.reason,
|
|
1653
|
-
points_removed: _adv.points_removed,
|
|
1654
|
-
proof: _adv.proof,
|
|
1655
|
-
proof_ext: _adv.proof_ext,
|
|
1656
|
-
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
|
|
1657
|
-
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
}
|
|
1661
|
-
/** String representation of this user */
|
|
1662
|
-
toString() {
|
|
1663
|
-
return `<@${this.id}>`;
|
|
1664
|
-
}
|
|
1665
|
-
/**
|
|
1666
|
-
* Fetches the user
|
|
1667
|
-
* @returns New Instance of the user
|
|
1668
|
-
*/
|
|
1669
|
-
async fetch() {
|
|
1670
|
-
const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
1671
|
-
const response = await this.rest.request({
|
|
1672
|
-
method: "get",
|
|
1673
|
-
url: route
|
|
1674
|
-
});
|
|
1675
|
-
const user = new _GuildUser(response, this.manager);
|
|
1676
|
-
this.manager.cache.set(user.id, user);
|
|
1677
|
-
this.rest.users.set(user.id, user);
|
|
1678
|
-
return user;
|
|
1679
|
-
}
|
|
1680
|
-
/**
|
|
1681
|
-
* Set the user blacklist
|
|
1682
|
-
* @param value Value to set to
|
|
1683
|
-
* @returns GuildUser
|
|
1684
|
-
*/
|
|
1685
|
-
async setBlacklist(value) {
|
|
1686
|
-
const route = Routes.guilds.users.resource(this.manager.guild.id, this.id, "blacklist");
|
|
1687
|
-
const payload = { set: value };
|
|
1688
|
-
await this.rest.request({
|
|
1689
|
-
method: "patch",
|
|
1690
|
-
url: route,
|
|
1691
|
-
payload
|
|
1692
|
-
});
|
|
1693
|
-
this.blacklist = value;
|
|
1694
|
-
this.manager.cache.set(this.id, this);
|
|
1695
|
-
this.rest.users.set(this.id, this);
|
|
1696
|
-
return this;
|
|
1697
|
-
}
|
|
1698
|
-
async reset() {
|
|
1699
|
-
const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
1700
|
-
const payload = { reset: true };
|
|
1701
|
-
const response = await this.rest.request({
|
|
1702
|
-
method: "DELETE",
|
|
1703
|
-
url: route,
|
|
1704
|
-
payload
|
|
1705
|
-
});
|
|
1706
|
-
__privateMethod(this, _GuildUser_instances, updateInternals_fn6).call(this, response);
|
|
1707
|
-
return this;
|
|
1708
|
-
}
|
|
1709
|
-
async updateProfile(data) {
|
|
1710
|
-
const _data = {
|
|
1711
|
-
profile: {
|
|
1712
|
-
avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
|
|
1713
|
-
bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
|
|
1714
|
-
bio: data.bio || this.profile.bio || "Melhor da minha aldeia (use !bio para alterar)",
|
|
1715
|
-
name: data.name || this.profile.name || "",
|
|
1716
|
-
textColor: data.textColor || this.profile.textColor || "#ffffff",
|
|
1717
|
-
primaryColor: data.primaryColor || this.profile.primaryColor || "#272727",
|
|
1718
|
-
secondaryColor: data.secondaryColor || this.profile.secondaryColor || "#151515"
|
|
1719
|
-
}
|
|
1720
|
-
};
|
|
1721
|
-
const route = Routes.guilds.users.update(this.manager.guild.id, this.id);
|
|
1722
|
-
const response = await this.rest.request({
|
|
1723
|
-
method: "patch",
|
|
1724
|
-
url: route,
|
|
1725
|
-
payload: _data
|
|
1726
|
-
});
|
|
1727
|
-
__privateMethod(this, _GuildUser_instances, updateInternals_fn6).call(this, response);
|
|
1728
|
-
return this;
|
|
1729
|
-
}
|
|
1730
|
-
async addAdvert(data) {
|
|
1731
|
-
const route = Routes.guilds.users.resource(this.manager.guild.id, this.id, "adverts");
|
|
1732
|
-
const payload = data;
|
|
1733
|
-
const response = await this.rest.request({ method: "POST", url: route, payload });
|
|
1734
|
-
return __privateMethod(this, _GuildUser_instances, updateInternals_fn6).call(this, response);
|
|
1735
|
-
}
|
|
1736
|
-
async removeAdvert(advertId) {
|
|
1737
|
-
let advs = this.adverts;
|
|
1738
|
-
if (advertId) advs = advs.filter((a) => a._id !== advertId);
|
|
1739
|
-
else advs.pop();
|
|
1740
|
-
const payload = { adverts: advs };
|
|
1741
|
-
const route = Routes.guilds.users.update(this.manager.guild.id, this.id);
|
|
1742
|
-
const response = await this.rest.request({ method: "PATCH", url: route, payload });
|
|
1743
|
-
return __privateMethod(this, _GuildUser_instances, updateInternals_fn6).call(this, response);
|
|
1744
|
-
}
|
|
1745
|
-
/**
|
|
1746
|
-
* Update certain property
|
|
1747
|
-
* @param data The new data to update with
|
|
1748
|
-
* @returns
|
|
1749
|
-
*/
|
|
1750
|
-
async update(data) {
|
|
1751
|
-
if (!data?.type) data.type = "add";
|
|
1752
|
-
const route = Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
1753
|
-
let payload = {};
|
|
1754
|
-
const numericFields = ["wins", "points", "losses", "mvps", "games", "creations", "spins"];
|
|
1755
|
-
const arrayFields = ["items", "original_channels", "adverts", "accessories"];
|
|
1756
|
-
if (data?.type === "add" || data?.type === "remove") {
|
|
1757
|
-
for (const key in data) {
|
|
1758
|
-
if (key === "type") continue;
|
|
1759
|
-
const value = data[key];
|
|
1760
|
-
if (numericFields.includes(key)) {
|
|
1761
|
-
const current = this[key] || 0;
|
|
1762
|
-
const num = value || 0;
|
|
1763
|
-
payload[key] = Math.max(0, data?.type === "add" ? current + num : current - num);
|
|
1764
|
-
} else if (key === "blacklist") {
|
|
1765
|
-
payload["blacklist"] = value;
|
|
1766
|
-
} else if (key === "profile") {
|
|
1767
|
-
payload["profile"] = value;
|
|
1768
|
-
} else if (arrayFields.includes(key)) {
|
|
1769
|
-
if (key === "original_channels") {
|
|
1770
|
-
const current2 = this.original_channels;
|
|
1771
|
-
const fromData = data["original_channels"];
|
|
1772
|
-
let channels = [];
|
|
1773
|
-
if (data?.type === "add") {
|
|
1774
|
-
const existingIds = new Set(current2.map((ch) => ch.matchId));
|
|
1775
|
-
channels = [...current2, ...fromData.filter((ch) => !existingIds.has(ch.matchId))];
|
|
1776
|
-
} else if (data?.type === "remove") {
|
|
1777
|
-
const idsToRemove = new Set(fromData.map((ch) => ch.matchId));
|
|
1778
|
-
channels = current2.filter((ch) => !idsToRemove.has(ch.matchId));
|
|
1779
|
-
}
|
|
1780
|
-
payload["original_channels"] = channels;
|
|
1781
|
-
continue;
|
|
1782
|
-
}
|
|
1783
|
-
const current = this[key];
|
|
1784
|
-
const incoming = value;
|
|
1785
|
-
payload[key] = data?.type === "add" ? [.../* @__PURE__ */ new Set([...current, ...incoming])] : current.filter((x) => !incoming.includes(x));
|
|
1786
|
-
}
|
|
1787
|
-
}
|
|
1788
|
-
}
|
|
1789
|
-
const response = await this.rest.request({
|
|
1790
|
-
method: "patch",
|
|
1791
|
-
url: route,
|
|
1792
|
-
payload
|
|
1793
|
-
});
|
|
1794
|
-
__privateMethod(this, _GuildUser_instances, updateInternals_fn6).call(this, response);
|
|
1795
|
-
return this;
|
|
1796
|
-
}
|
|
1797
|
-
async delete() {
|
|
1798
|
-
const route = Routes.guilds.users.delete(this.manager.guild.id, this.id);
|
|
1799
|
-
const response = await this.rest.request({
|
|
1800
|
-
method: "DELETE",
|
|
1801
|
-
url: route
|
|
1802
|
-
});
|
|
1803
|
-
this.rest.emit("userDelete", this);
|
|
1804
|
-
this.manager.cache.delete(this.id);
|
|
1805
|
-
return response;
|
|
1806
|
-
}
|
|
1807
|
-
toJSON() {
|
|
1808
|
-
let json = {};
|
|
1809
|
-
for (const [key, value] of Object.entries(this)) {
|
|
1810
|
-
const exclude = ["rest", "guilds", "guild", "manager"];
|
|
1811
|
-
if (exclude.includes(key)) continue;
|
|
1812
|
-
if (typeof value !== "function") {
|
|
1813
|
-
json[key] = value;
|
|
1814
|
-
}
|
|
1815
|
-
}
|
|
1816
|
-
return json;
|
|
1817
|
-
}
|
|
1818
|
-
};
|
|
1819
|
-
_GuildUser_instances = new WeakSet();
|
|
1820
|
-
updateInternals_fn6 = function(data) {
|
|
1821
|
-
for (let key in data) {
|
|
1822
|
-
if (key === "id" || key === "createdAt") continue;
|
|
1823
|
-
if (key in this) {
|
|
1824
|
-
this[key] = data[key];
|
|
1825
|
-
}
|
|
1826
|
-
if (key === "adverts") {
|
|
1827
|
-
this.adverts = [];
|
|
1828
|
-
for (let _adv of data.adverts) {
|
|
1829
|
-
this.adverts.push({
|
|
1830
|
-
_id: _adv._id,
|
|
1831
|
-
admin_id: _adv.admin_id,
|
|
1832
|
-
role_id: _adv.role_id,
|
|
1833
|
-
reason: _adv.reason,
|
|
1834
|
-
points_removed: _adv.points_removed,
|
|
1835
|
-
proof: _adv.proof,
|
|
1836
|
-
proof_ext: _adv.proof_ext,
|
|
1837
|
-
createdAt: _adv.createdAt ? new Date(_adv.createdAt) : /* @__PURE__ */ new Date(),
|
|
1838
|
-
updatedAt: _adv.updatedAt ? new Date(_adv.updatedAt) : /* @__PURE__ */ new Date()
|
|
1839
|
-
});
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
1844
|
-
this.createdAt = new Date(data.createdAt);
|
|
1845
|
-
this.manager.set(this);
|
|
1846
|
-
this.rest.emit("userUpdate", this);
|
|
1847
|
-
return this;
|
|
1848
|
-
};
|
|
1849
|
-
var GuildUser = _GuildUser;
|
|
1850
|
-
|
|
1851
|
-
// src/structures/vipmember/VipMember.ts
|
|
1852
|
-
var _VipMember_instances, updateData_fn;
|
|
1853
|
-
var _VipMember = class _VipMember {
|
|
1854
|
-
/**
|
|
1855
|
-
* Bet member
|
|
1856
|
-
* @param data The member's data
|
|
1857
|
-
* @param manager The manager
|
|
1858
|
-
* @param rest The rest client
|
|
1859
|
-
*/
|
|
1860
|
-
constructor(data, manager) {
|
|
1861
|
-
__privateAdd(this, _VipMember_instances);
|
|
1862
|
-
/** member's id */
|
|
1863
|
-
__publicField(this, "id");
|
|
1864
|
-
/** member name */
|
|
1865
|
-
__publicField(this, "name");
|
|
1866
|
-
/** Members's roleId */
|
|
1867
|
-
__publicField(this, "roleId");
|
|
1868
|
-
/** Members's voiceChannelId */
|
|
1869
|
-
__publicField(this, "voiceChannelId");
|
|
1870
|
-
/** Vip's type */
|
|
1871
|
-
__publicField(this, "type");
|
|
1872
|
-
/** Member's Guild Id */
|
|
1873
|
-
__publicField(this, "guild_id");
|
|
1874
|
-
__publicField(this, "duration");
|
|
1875
|
-
__publicField(this, "status");
|
|
1876
|
-
/** member's daily */
|
|
1877
|
-
__publicField(this, "createdAt");
|
|
1878
|
-
/** Updated Date */
|
|
1879
|
-
__publicField(this, "updatedAt");
|
|
1880
|
-
/** The given manager */
|
|
1881
|
-
__publicField(this, "manager");
|
|
1882
|
-
/** The rest client */
|
|
1883
|
-
__publicField(this, "rest");
|
|
1884
|
-
__publicField(this, "guild");
|
|
1885
|
-
this.name = data?.name;
|
|
1886
|
-
this.id = data?.id;
|
|
1887
|
-
this.manager = manager;
|
|
1888
|
-
this.rest = manager.rest;
|
|
1889
|
-
this.guild = manager.guild;
|
|
1890
|
-
this.duration = data?.duration ? new Date(data?.duration) : /* @__PURE__ */ new Date();
|
|
1891
|
-
this.status = data?.status;
|
|
1892
|
-
this.type = data?.type;
|
|
1893
|
-
this.roleId = data?.roleId;
|
|
1894
|
-
this.voiceChannelId = data?.voiceChannelId;
|
|
1895
|
-
this.guild_id = data?.guild_id;
|
|
1896
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
1897
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1898
|
-
}
|
|
1899
|
-
/** String representation of this member */
|
|
1900
|
-
toString() {
|
|
1901
|
-
return `<@${this.id}>`;
|
|
1902
|
-
}
|
|
1903
|
-
/**
|
|
1904
|
-
* Fetches the member
|
|
1905
|
-
* @returns New Instance of the member
|
|
1906
|
-
*/
|
|
1907
|
-
async fetch() {
|
|
1908
|
-
const route = Routes.vipmembers.get(this.guild_id, this.id);
|
|
1909
|
-
const response = await this.rest.request({
|
|
1910
|
-
method: "get",
|
|
1911
|
-
url: route
|
|
1912
|
-
});
|
|
1913
|
-
const member = new _VipMember(response, this.manager);
|
|
1914
|
-
this.manager.cache.set(member.id, member);
|
|
1915
|
-
return member;
|
|
1916
|
-
}
|
|
1917
|
-
async reset() {
|
|
1918
|
-
const route = Routes.vipmembers.get(this.guild_id, this.id);
|
|
1919
|
-
const payload = { reset: true };
|
|
1920
|
-
const response = await this.rest.request({
|
|
1921
|
-
method: "DELETE",
|
|
1922
|
-
url: route,
|
|
1923
|
-
payload
|
|
1924
|
-
});
|
|
1925
|
-
__privateMethod(this, _VipMember_instances, updateData_fn).call(this, response);
|
|
1926
|
-
this.type = response.type;
|
|
1927
|
-
this.manager.set(response);
|
|
1928
|
-
return this;
|
|
1929
|
-
}
|
|
1930
|
-
/**
|
|
1931
|
-
* Update certain property
|
|
1932
|
-
* @param data The new data to update with
|
|
1933
|
-
* @returns
|
|
1934
|
-
*/
|
|
1935
|
-
async update(data) {
|
|
1936
|
-
const route = Routes.vipmembers.get(this.guild.id, this.id);
|
|
1937
|
-
const payload = data;
|
|
1938
|
-
const response = await this.rest.request({
|
|
1939
|
-
method: "patch",
|
|
1940
|
-
url: route,
|
|
1941
|
-
payload
|
|
1942
|
-
});
|
|
1943
|
-
for (const k in response) {
|
|
1944
|
-
if (k === "id") continue;
|
|
1945
|
-
if (Object.hasOwn(this, k)) {
|
|
1946
|
-
this[k] = response[k];
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : /* @__PURE__ */ new Date();
|
|
1950
|
-
this.duration = response?.duration ? new Date(response?.duration) : /* @__PURE__ */ new Date();
|
|
1951
|
-
this.createdAt = response?.createdAt ? new Date(response?.createdAt) : /* @__PURE__ */ new Date();
|
|
1952
|
-
this.type = response.type;
|
|
1953
|
-
this.manager.cache.set(this.id, this);
|
|
1954
|
-
return this;
|
|
1955
|
-
}
|
|
1956
|
-
async delete() {
|
|
1957
|
-
const route = Routes.vipmembers.delete(this.guild_id, this.id);
|
|
1958
|
-
const response = await this.rest.request({
|
|
1959
|
-
method: "DELETE",
|
|
1960
|
-
url: route
|
|
1961
|
-
});
|
|
1962
|
-
this.manager.cache.delete(this.id);
|
|
1963
|
-
return response;
|
|
1964
|
-
}
|
|
1965
|
-
toJSON() {
|
|
1966
|
-
let json;
|
|
1967
|
-
for (const [key, value] of Object.entries(this)) {
|
|
1968
|
-
if (typeof value !== "function") {
|
|
1969
|
-
json[key] = value;
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
return json;
|
|
1973
|
-
}
|
|
1974
|
-
};
|
|
1975
|
-
_VipMember_instances = new WeakSet();
|
|
1976
|
-
updateData_fn = function(data) {
|
|
1977
|
-
for (const k in data) {
|
|
1978
|
-
if (k === "id") continue;
|
|
1979
|
-
if (Object.hasOwn(this, k)) {
|
|
1980
|
-
this[k] = data[k];
|
|
1981
|
-
this.data[k] = data[k];
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
};
|
|
1985
|
-
var VipMember = _VipMember;
|
|
1986
|
-
|
|
1987
|
-
// src/structures/ticket/Ticket.ts
|
|
1988
|
-
var _GuildTicket_instances, updateInternals_fn7;
|
|
1989
|
-
var GuildTicket = class {
|
|
1990
|
-
constructor(data, manager) {
|
|
1991
|
-
__privateAdd(this, _GuildTicket_instances);
|
|
1992
|
-
__publicField(this, "_id");
|
|
1993
|
-
__publicField(this, "guild_id");
|
|
1994
|
-
__publicField(this, "type");
|
|
1995
|
-
__publicField(this, "status");
|
|
1996
|
-
__publicField(this, "admin_id");
|
|
1997
|
-
__publicField(this, "channel_id");
|
|
1998
|
-
__publicField(this, "closed_by_id");
|
|
1999
|
-
__publicField(this, "creator_id");
|
|
2000
|
-
__publicField(this, "customer_rating");
|
|
2001
|
-
__publicField(this, "messages");
|
|
2002
|
-
__publicField(this, "createdAt");
|
|
2003
|
-
__publicField(this, "updatedAt");
|
|
2004
|
-
__publicField(this, "rest");
|
|
2005
|
-
__publicField(this, "guild");
|
|
2006
|
-
__publicField(this, "manager");
|
|
2007
|
-
this.manager = manager;
|
|
2008
|
-
this.guild = manager.guild;
|
|
2009
|
-
this.rest = manager.rest;
|
|
2010
|
-
this._id = data?._id;
|
|
2011
|
-
this.type = data?.type;
|
|
2012
|
-
this.admin_id = data?.admin_id;
|
|
2013
|
-
this.guild_id = data?.guild_id;
|
|
2014
|
-
this.channel_id = data?.channel_id;
|
|
2015
|
-
this.creator_id = data?.creator_id;
|
|
2016
|
-
this.status = data?.status;
|
|
2017
|
-
this.customer_rating = data?.customer_rating;
|
|
2018
|
-
this.messages = data?.messages;
|
|
2019
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
2020
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
2021
|
-
}
|
|
2022
|
-
async fetch() {
|
|
2023
|
-
const route = Routes.guilds.tickets.get(this.guild.id, this._id);
|
|
2024
|
-
const response = await this.rest.request({
|
|
2025
|
-
method: "GET",
|
|
2026
|
-
url: route
|
|
2027
|
-
});
|
|
2028
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn7).call(this, response);
|
|
2029
|
-
}
|
|
2030
|
-
async setCustomerRating(rating) {
|
|
2031
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "customer_rating");
|
|
2032
|
-
const payload = { set: rating };
|
|
2033
|
-
const response = await this.rest.request({
|
|
2034
|
-
method: "PATCH",
|
|
2035
|
-
url: route,
|
|
2036
|
-
payload
|
|
2037
|
-
});
|
|
2038
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn7).call(this, response);
|
|
2039
|
-
}
|
|
2040
|
-
async setAdminId(id) {
|
|
2041
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "admin_id");
|
|
2042
|
-
const payload = { set: id };
|
|
2043
|
-
const response = await this.rest.request({
|
|
2044
|
-
method: "PATCH",
|
|
2045
|
-
url: route,
|
|
2046
|
-
payload
|
|
2047
|
-
});
|
|
2048
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn7).call(this, response);
|
|
2049
|
-
}
|
|
2050
|
-
async setChannelId(id) {
|
|
2051
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "channel_id");
|
|
2052
|
-
const payload = { set: id };
|
|
2053
|
-
const response = await this.rest.request({
|
|
2054
|
-
method: "PATCH",
|
|
2055
|
-
url: route,
|
|
2056
|
-
payload
|
|
2057
|
-
});
|
|
2058
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn7).call(this, response);
|
|
2059
|
-
}
|
|
2060
|
-
async setClosedById(id) {
|
|
2061
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "closed_by_id");
|
|
2062
|
-
const payload = { set: id };
|
|
2063
|
-
const response = await this.rest.request({
|
|
2064
|
-
method: "PATCH",
|
|
2065
|
-
url: route,
|
|
2066
|
-
payload
|
|
2067
|
-
});
|
|
2068
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn7).call(this, response);
|
|
2069
|
-
}
|
|
2070
|
-
async setStatus(status) {
|
|
2071
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "status");
|
|
2072
|
-
const payload = { set: status };
|
|
2073
|
-
const response = await this.rest.request({
|
|
2074
|
-
method: "PATCH",
|
|
2075
|
-
url: route,
|
|
2076
|
-
payload
|
|
2077
|
-
});
|
|
2078
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn7).call(this, response);
|
|
2079
|
-
}
|
|
2080
|
-
async addMessage(message) {
|
|
2081
|
-
const route = Routes.guilds.tickets.resource(this.guild.id, this._id, "messages");
|
|
2082
|
-
const payload = { set: [...this.messages, message] };
|
|
2083
|
-
const response = await this.rest.request({
|
|
2084
|
-
method: "PATCH",
|
|
2085
|
-
url: route,
|
|
2086
|
-
payload
|
|
2087
|
-
});
|
|
2088
|
-
return __privateMethod(this, _GuildTicket_instances, updateInternals_fn7).call(this, response);
|
|
2089
|
-
}
|
|
2090
|
-
};
|
|
2091
|
-
_GuildTicket_instances = new WeakSet();
|
|
2092
|
-
updateInternals_fn7 = function(data) {
|
|
2093
|
-
for (let key in data) {
|
|
2094
|
-
if (key === "id" || key === "createdAt") continue;
|
|
2095
|
-
if (key in this) {
|
|
2096
|
-
this[key] = data[key];
|
|
2097
|
-
}
|
|
2098
|
-
}
|
|
2099
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
2100
|
-
this.createdAt = new Date(data.createdAt);
|
|
2101
|
-
this.manager.set(this);
|
|
2102
|
-
return this;
|
|
2103
|
-
};
|
|
2104
|
-
|
|
2105
|
-
// src/structures/automaticmessage/AutomaticMessage.ts
|
|
2106
|
-
var _AutomaticMessage_instances, updateInternals_fn8;
|
|
2107
|
-
var AutomaticMessage = class {
|
|
2108
|
-
constructor(data, manager) {
|
|
2109
|
-
__privateAdd(this, _AutomaticMessage_instances);
|
|
2110
|
-
__publicField(this, "id");
|
|
2111
|
-
__publicField(this, "type");
|
|
2112
|
-
__publicField(this, "admin_id");
|
|
2113
|
-
__publicField(this, "channel_ids");
|
|
2114
|
-
__publicField(this, "content");
|
|
2115
|
-
__publicField(this, "embeds");
|
|
2116
|
-
__publicField(this, "components");
|
|
2117
|
-
__publicField(this, "attachments");
|
|
2118
|
-
__publicField(this, "flags");
|
|
2119
|
-
__publicField(this, "interval_ms");
|
|
2120
|
-
__publicField(this, "createdAt");
|
|
2121
|
-
__publicField(this, "updatedAt");
|
|
2122
|
-
__publicField(this, "guild");
|
|
2123
|
-
__publicField(this, "manager");
|
|
2124
|
-
__publicField(this, "rest");
|
|
2125
|
-
this.manager = manager;
|
|
2126
|
-
this.guild = manager.guild;
|
|
2127
|
-
this.rest = manager.rest;
|
|
2128
|
-
this.id = data?.id;
|
|
2129
|
-
this.type = data?.type;
|
|
2130
|
-
this.admin_id = data?.admin_id;
|
|
2131
|
-
this.channel_ids = data?.channel_ids;
|
|
2132
|
-
this.content = data?.content;
|
|
2133
|
-
this.embeds = data?.embeds;
|
|
2134
|
-
this.components = data?.components;
|
|
2135
|
-
this.attachments = data?.attachments;
|
|
2136
|
-
this.flags = data?.flags;
|
|
2137
|
-
this.interval_ms = data?.interval_ms;
|
|
2138
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
2139
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
2140
|
-
}
|
|
2141
|
-
async fetch() {
|
|
2142
|
-
return this.manager.fetch(this.id);
|
|
2143
|
-
}
|
|
2144
|
-
async addChannelId(...id) {
|
|
2145
|
-
const ids = [.../* @__PURE__ */ new Set([...this.channel_ids, ...id])];
|
|
2146
|
-
return this.update({ channel_ids: ids });
|
|
2147
|
-
}
|
|
2148
|
-
async removeChannelId(...id) {
|
|
2149
|
-
const remove = new Set(id);
|
|
2150
|
-
const ids = this.channel_ids.filter((i) => !remove.has(i));
|
|
2151
|
-
return this.update({ channel_ids: ids });
|
|
2152
|
-
}
|
|
2153
|
-
async update(data) {
|
|
2154
|
-
this.manager.cache.set(this.id, { ...this, ...data, id: this.id });
|
|
2155
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
2156
|
-
const response = await this.rest.request({
|
|
2157
|
-
method: "patch",
|
|
2158
|
-
url: route,
|
|
2159
|
-
payload: { automatic_messages: this.manager.toJSON() }
|
|
2160
|
-
});
|
|
2161
|
-
return __privateMethod(this, _AutomaticMessage_instances, updateInternals_fn8).call(this, response);
|
|
2162
|
-
}
|
|
2163
|
-
async delete() {
|
|
2164
|
-
this.manager.cache.delete(this.id);
|
|
2165
|
-
this.guild.automatic_messages = this.manager.cache.toArray();
|
|
2166
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
2167
|
-
const response = await this.rest.request({
|
|
2168
|
-
method: "patch",
|
|
2169
|
-
url: route,
|
|
2170
|
-
payload: { automatic_messages: this.manager.toJSON() }
|
|
2171
|
-
});
|
|
2172
|
-
return this.manager.set(response.automatic_messages);
|
|
2173
|
-
}
|
|
2174
|
-
toJSON() {
|
|
2175
|
-
return {
|
|
2176
|
-
id: this.id,
|
|
2177
|
-
type: this.type,
|
|
2178
|
-
admin_id: this.admin_id,
|
|
2179
|
-
attachments: this.attachments,
|
|
2180
|
-
channel_ids: this.channel_ids,
|
|
2181
|
-
content: this.content,
|
|
2182
|
-
embeds: this.embeds,
|
|
2183
|
-
flags: this.flags,
|
|
2184
|
-
interval_ms: this.interval_ms,
|
|
2185
|
-
components: this.components,
|
|
2186
|
-
createdAt: this.createdAt,
|
|
2187
|
-
updatedAt: this.updatedAt
|
|
2188
|
-
};
|
|
2189
|
-
}
|
|
2190
|
-
};
|
|
2191
|
-
_AutomaticMessage_instances = new WeakSet();
|
|
2192
|
-
updateInternals_fn8 = function(data) {
|
|
2193
|
-
const _this = data?.automatic_messages?.find((m) => m.id === this.id);
|
|
2194
|
-
for (let key in _this) {
|
|
2195
|
-
if (key === "id" || key === "createdAt") continue;
|
|
2196
|
-
if (key in this) {
|
|
2197
|
-
this[key] = _this[key];
|
|
2198
|
-
}
|
|
2199
|
-
}
|
|
2200
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
2201
|
-
this.createdAt = new Date(data.createdAt);
|
|
2202
|
-
this.manager._add(data.automatic_messages);
|
|
2203
|
-
return this;
|
|
2204
|
-
};
|
|
2205
|
-
|
|
2206
|
-
// src/utils/randomKeyGenerator.ts
|
|
2207
|
-
var import_crypto = require("crypto");
|
|
2208
|
-
function randomKeyGenerator(max, enconding) {
|
|
2209
|
-
return (0, import_crypto.randomBytes)(24).toString(enconding ?? "base64").slice(0, max || 24).toUpperCase();
|
|
2210
|
-
}
|
|
2211
|
-
|
|
2212
|
-
// src/managers/automaticmessage/AutomaticMessageManager.ts
|
|
2213
|
-
var AutomaticMessageManager = class extends BaseManager {
|
|
2214
|
-
constructor(guild) {
|
|
2215
|
-
super(guild);
|
|
2216
|
-
this.guild = guild;
|
|
2217
|
-
this.rest = guild.rest;
|
|
2218
|
-
this.base_url = Routes.guilds.resource(guild.id);
|
|
2219
|
-
this.cache = new Collection();
|
|
2220
|
-
if (guild.automatic_messages && guild.automatic_messages.length !== 0) this.set(guild.automatic_messages);
|
|
2221
|
-
else this.guild.automatic_messages = [];
|
|
2222
|
-
}
|
|
2223
|
-
async fetch(messageId) {
|
|
2224
|
-
const route = this.base_url;
|
|
2225
|
-
const response = await this.rest.request({
|
|
2226
|
-
method: "get",
|
|
2227
|
-
url: route
|
|
2228
|
-
});
|
|
2229
|
-
this._add(response.automatic_messages);
|
|
2230
|
-
return this.cache;
|
|
2231
|
-
}
|
|
2232
|
-
async create(data) {
|
|
2233
|
-
if (!data.type) throw new Error(`Missing message's type.`);
|
|
2234
|
-
const id = randomKeyGenerator(9).replace(/-/g, "0").replace(/_/g, "Y");
|
|
2235
|
-
const m = { ...data, id };
|
|
2236
|
-
this.guild.automatic_messages.push(m);
|
|
2237
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
2238
|
-
const response = await this.rest.request({
|
|
2239
|
-
method: "patch",
|
|
2240
|
-
url: route,
|
|
2241
|
-
payload: { automatic_messages: this.guild.automatic_messages }
|
|
2242
|
-
});
|
|
2243
|
-
return this._add(response.automatic_messages).find((m2) => m2.id === id);
|
|
2244
|
-
}
|
|
2245
|
-
_add(data) {
|
|
2246
|
-
if (Array.isArray(data)) {
|
|
2247
|
-
for (let _m of data) {
|
|
2248
|
-
if (!_m.id) continue;
|
|
2249
|
-
if (_m instanceof AutomaticMessage) this.cache.set(_m.id, _m);
|
|
2250
|
-
else this.cache.set(_m.id, new AutomaticMessage(_m, this));
|
|
2251
|
-
}
|
|
2252
|
-
} else {
|
|
2253
|
-
if (!data.id) return this.cache;
|
|
2254
|
-
if (data instanceof AutomaticMessage) this.cache.set(data.id, data);
|
|
2255
|
-
else this.cache.set(data.id, new AutomaticMessage(data, this));
|
|
2256
|
-
}
|
|
2257
|
-
this.guild.automatic_messages = this.cache.toArray();
|
|
2258
|
-
return this.cache;
|
|
2259
|
-
}
|
|
2260
|
-
set(data) {
|
|
2261
|
-
this.cache.clear();
|
|
2262
|
-
if (Array.isArray(data)) {
|
|
2263
|
-
for (let _m of data) {
|
|
2264
|
-
if (!_m.id) continue;
|
|
2265
|
-
if (_m instanceof AutomaticMessage) this.cache.set(_m.id, _m);
|
|
2266
|
-
else this.cache.set(_m.id, new AutomaticMessage(_m, this));
|
|
2267
|
-
}
|
|
2268
|
-
} else {
|
|
2269
|
-
if (!data.id) return this.cache;
|
|
2270
|
-
if (data instanceof AutomaticMessage) this.cache.set(data.id, data);
|
|
2271
|
-
else this.cache.set(data.id, new AutomaticMessage(data, this));
|
|
2272
|
-
}
|
|
2273
|
-
return this.cache;
|
|
2274
|
-
}
|
|
2275
|
-
async delete(messageId) {
|
|
2276
|
-
if (messageId) return await this.cache.get(messageId).delete();
|
|
2277
|
-
this.cache.clear();
|
|
2278
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
2279
|
-
const response = await this.rest.request({
|
|
2280
|
-
method: "patch",
|
|
2281
|
-
url: route,
|
|
2282
|
-
payload: { automatic_messages: [] }
|
|
2283
|
-
});
|
|
2284
|
-
return response;
|
|
2285
|
-
}
|
|
2286
|
-
toJSON() {
|
|
2287
|
-
[...this.cache.values()].map((m) => console.log(m instanceof AutomaticMessage));
|
|
2288
|
-
return this.cache.toArray();
|
|
2289
|
-
}
|
|
2290
|
-
};
|
|
2291
|
-
|
|
2292
|
-
// src/managers/bet/GuildBetManager.ts
|
|
2293
|
-
var GuildBetManager2 = class extends BaseManager {
|
|
2294
|
-
constructor(guild) {
|
|
2295
|
-
super(guild);
|
|
2296
|
-
this.guild = guild;
|
|
2297
|
-
this.rest = guild.rest;
|
|
2298
|
-
this.base_url = Routes.guilds.bets.getAll(guild.id);
|
|
2299
|
-
this.cache = new Collection("bets");
|
|
2300
|
-
}
|
|
2301
|
-
toString() {
|
|
2302
|
-
return this.cache.size;
|
|
2303
|
-
}
|
|
2304
|
-
async fetch(options) {
|
|
2305
|
-
const route = this.base_url;
|
|
2306
|
-
if (options && options.cache) return this.cache;
|
|
2307
|
-
if (options && options.betId) {
|
|
2308
|
-
const response2 = await this.rest.request({ url: `${route}/${options.betId}`, method: "GET" });
|
|
2309
|
-
return this.set(response2);
|
|
2310
|
-
}
|
|
2311
|
-
const response = await this.rest.request({ url: route, method: "GET" });
|
|
2312
|
-
return this.set(response);
|
|
2313
|
-
}
|
|
2314
|
-
async create(data) {
|
|
2315
|
-
const route = Routes.guilds.bets.create(this.guild.id);
|
|
2316
|
-
const response = await this.rest.request({ url: route, method: "POST", payload: data });
|
|
2317
|
-
return this.set(response);
|
|
2318
|
-
}
|
|
2319
|
-
async delete(betId) {
|
|
2320
|
-
const route = Routes.fields(this.base_url, betId);
|
|
2321
|
-
const response = await this.rest.request({ url: route, method: "DELETE" });
|
|
2322
|
-
return this.set(response);
|
|
2323
|
-
}
|
|
2324
|
-
set(data) {
|
|
2325
|
-
if (!data) return;
|
|
2326
|
-
if (Array.isArray(data)) {
|
|
2327
|
-
for (let _bet of data) {
|
|
2328
|
-
if (!_bet._id) continue;
|
|
2329
|
-
const bet = new GuildBet(_bet, this);
|
|
2330
|
-
this.cache.set(bet._id, bet);
|
|
2331
|
-
this.rest.bets.set(bet._id, bet);
|
|
2332
|
-
}
|
|
2333
|
-
} else {
|
|
2334
|
-
if (!data._id) return;
|
|
2335
|
-
if (data instanceof GuildBet) {
|
|
2336
|
-
this.cache.set(data._id, data);
|
|
2337
|
-
return data;
|
|
2338
|
-
}
|
|
2339
|
-
const bet = new GuildBet(data, this);
|
|
2340
|
-
this.cache.set(bet._id, bet);
|
|
2341
|
-
this.rest.bets.set(bet._id, bet);
|
|
2342
|
-
return bet;
|
|
2343
|
-
}
|
|
2344
|
-
}
|
|
2345
|
-
};
|
|
2346
|
-
|
|
2347
|
-
// src/managers/betuser/GuildBetUserManager.ts
|
|
2348
|
-
var GuildBetUserManager = class extends BaseManager {
|
|
2349
|
-
constructor(guild) {
|
|
2350
|
-
super(guild);
|
|
2351
|
-
this.guild = guild;
|
|
2352
|
-
this.rest = guild.rest;
|
|
2353
|
-
this.base_url = Routes.guilds.betusers.getAll(guild.id);
|
|
2354
|
-
this.cache = new Collection("betusers");
|
|
2355
|
-
}
|
|
2356
|
-
async fetch(options) {
|
|
2357
|
-
if (options && options.cache) return this.cache;
|
|
2358
|
-
if (options && options.userId) {
|
|
2359
|
-
const route2 = Routes.fields(this.base_url, options.userId);
|
|
2360
|
-
const response2 = await this.rest.request({
|
|
2361
|
-
method: "GET",
|
|
2362
|
-
url: route2
|
|
2363
|
-
});
|
|
2364
|
-
const user = new GuildBetUser(response2, this);
|
|
2365
|
-
this.set(user);
|
|
2366
|
-
return user;
|
|
2367
|
-
}
|
|
2368
|
-
const route = this.base_url;
|
|
2369
|
-
const response = await this.rest.request({
|
|
2370
|
-
method: "GET",
|
|
2371
|
-
url: route
|
|
2372
|
-
});
|
|
2373
|
-
this.set(response);
|
|
2374
|
-
return this.cache;
|
|
2375
|
-
}
|
|
2376
|
-
async updateMany(...betusers) {
|
|
2377
|
-
const route = this.base_url;
|
|
2378
|
-
const response = await this.rest.request({
|
|
2379
|
-
method: "PATCH",
|
|
2380
|
-
url: route,
|
|
2381
|
-
payload: { betusers }
|
|
2382
|
-
});
|
|
2383
|
-
return this.set(response);
|
|
2384
|
-
}
|
|
2385
|
-
async deleteAll() {
|
|
2386
|
-
const route = this.base_url;
|
|
2387
|
-
await this.rest.request({
|
|
2388
|
-
method: "DELETE",
|
|
2389
|
-
url: route
|
|
2390
|
-
});
|
|
2391
|
-
this.cache.clear();
|
|
2392
|
-
}
|
|
2393
|
-
async resetAll() {
|
|
2394
|
-
const route = this.base_url;
|
|
2395
|
-
const response = await this.rest.request({
|
|
2396
|
-
method: "put",
|
|
2397
|
-
url: route
|
|
2398
|
-
});
|
|
2399
|
-
this.cache.clear();
|
|
2400
|
-
return this.set(response);
|
|
2401
|
-
}
|
|
2402
|
-
set(data) {
|
|
2403
|
-
if (!data) return this.cache;
|
|
2404
|
-
if (Array.isArray(data)) {
|
|
2405
|
-
for (let _user of data) {
|
|
2406
|
-
if (!_user.id) return;
|
|
2407
|
-
const user = new GuildBetUser(_user, this);
|
|
2408
|
-
this.cache.set(user.id, user);
|
|
2409
|
-
this.rest.betusers.set(user.id, user);
|
|
2410
|
-
}
|
|
2411
|
-
return this.cache;
|
|
2412
|
-
} else {
|
|
2413
|
-
if (!data.id) return;
|
|
2414
|
-
const user = new GuildBetUser(data, this);
|
|
2415
|
-
this.cache.set(user.id, user);
|
|
2416
|
-
this.rest.betusers.set(user.id, user);
|
|
2417
|
-
return user;
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
};
|
|
2421
|
-
|
|
2422
|
-
// src/managers/buffer/BufferManager.ts
|
|
2423
|
-
var BufferManager = class {
|
|
2424
|
-
constructor(guild) {
|
|
2425
|
-
__publicField(this, "matches");
|
|
2426
|
-
__publicField(this, "tickets");
|
|
2427
|
-
__publicField(this, "guild");
|
|
2428
|
-
this.matches = new Collection("buffer:matches");
|
|
2429
|
-
this.tickets = new Collection("buffer:tickets");
|
|
2430
|
-
this.guild = guild;
|
|
2431
|
-
}
|
|
2432
|
-
async flush(key) {
|
|
2433
|
-
const { rest } = this.guild;
|
|
2434
|
-
const cache = this[key];
|
|
2435
|
-
const { size, clear } = cache;
|
|
2436
|
-
if (size >= 2) {
|
|
2437
|
-
const response = await rest.request({
|
|
2438
|
-
method: "POST",
|
|
2439
|
-
url: Routes.guilds.resources(this.guild.id, key, "bulk"),
|
|
2440
|
-
payload: { [key]: this[key].toArray() }
|
|
2441
|
-
});
|
|
2442
|
-
this.guild[key].set(response);
|
|
2443
|
-
clear();
|
|
2444
|
-
return response;
|
|
2445
|
-
}
|
|
2446
|
-
return;
|
|
2447
|
-
}
|
|
2448
|
-
createMatch(id, data) {
|
|
2449
|
-
this.matches.set(id, data);
|
|
2450
|
-
}
|
|
2451
|
-
createTicket(id, data) {
|
|
2452
|
-
this.tickets.set(id, data);
|
|
2453
|
-
}
|
|
2454
|
-
};
|
|
2455
|
-
|
|
2456
|
-
// src/managers/logs/LogManager.ts
|
|
2457
|
-
var LogManager = class extends BaseManager {
|
|
2458
|
-
constructor(guild) {
|
|
2459
|
-
super(guild);
|
|
2460
|
-
this.guild = guild;
|
|
2461
|
-
this.rest = guild.rest;
|
|
2462
|
-
this.base_url = Routes.fields(Routes.guilds.get(guild.id), "logs");
|
|
2463
|
-
this.cache = new Collection();
|
|
2464
|
-
}
|
|
2465
|
-
async fetch() {
|
|
2466
|
-
const route = this.base_url;
|
|
2467
|
-
const response = await this.rest.request({
|
|
2468
|
-
method: "GET",
|
|
2469
|
-
url: route
|
|
2470
|
-
});
|
|
2471
|
-
return this.set(response);
|
|
2472
|
-
}
|
|
2473
|
-
async create(data) {
|
|
2474
|
-
const route = this.base_url;
|
|
2475
|
-
const payload = { ...data };
|
|
2476
|
-
const response = await this.rest.request({
|
|
2477
|
-
method: "POST",
|
|
2478
|
-
url: route,
|
|
2479
|
-
payload
|
|
2480
|
-
});
|
|
2481
|
-
const logEntry = this.set(response);
|
|
2482
|
-
this.cache.set(data._id, logEntry);
|
|
2483
|
-
this.rest.emit("logEntryCreate", logEntry, this.guild);
|
|
2484
|
-
return logEntry;
|
|
2485
|
-
}
|
|
2486
|
-
/* async createMany(data: Optional<APILogEntry>[]): Promise<APILogEntry[]> {
|
|
2487
|
-
const route = Routes.fields(this.base_url, "bulk");
|
|
2488
|
-
const payload = { ...data };
|
|
2489
|
-
const response = await this.rest.request<APILogEntry[], typeof payload>({
|
|
2490
|
-
method: "POST",
|
|
2491
|
-
url: route,
|
|
2492
|
-
payload,
|
|
2493
|
-
});
|
|
2494
|
-
|
|
2495
|
-
this.set(response);
|
|
2496
|
-
return response;
|
|
2497
|
-
} */
|
|
2498
|
-
set(data) {
|
|
2499
|
-
if (!data) return this.cache;
|
|
2500
|
-
if (Array.isArray(data)) {
|
|
2501
|
-
this.cache.clear();
|
|
2502
|
-
for (let entry of data) {
|
|
2503
|
-
if (!entry._id) continue;
|
|
2504
|
-
const logEntry = new LogEntry(entry, this);
|
|
2505
|
-
this.cache.set(entry._id, logEntry);
|
|
2506
|
-
}
|
|
2507
|
-
return this.cache;
|
|
2508
|
-
} else {
|
|
2509
|
-
const logEntry = new LogEntry(data, this);
|
|
2510
|
-
this.cache.set(data._id, logEntry);
|
|
2511
|
-
return logEntry;
|
|
2512
|
-
}
|
|
2513
|
-
}
|
|
2514
|
-
};
|
|
2515
|
-
|
|
2516
|
-
// src/managers/match/GuildMatchManager.ts
|
|
2517
|
-
var GuildMatchManager2 = class extends BaseManager {
|
|
2518
|
-
/**
|
|
2519
|
-
* Manage users with the given client
|
|
2520
|
-
* @param users An array of users
|
|
2521
|
-
* @param rest The rest client
|
|
2522
|
-
*/
|
|
2523
|
-
constructor(guild) {
|
|
2524
|
-
super(guild);
|
|
2525
|
-
this.guild = guild;
|
|
2526
|
-
this.rest = guild.rest;
|
|
2527
|
-
this.base_url = Routes.guilds.matches.getAll(guild.id);
|
|
2528
|
-
this.cache = new Collection("matches");
|
|
2529
|
-
}
|
|
2530
|
-
/**
|
|
2531
|
-
* Fetch a match
|
|
2532
|
-
* @param id Id of the match to fetch
|
|
2533
|
-
* @returns APIBetUser
|
|
2534
|
-
*/
|
|
2535
|
-
async fetch(options) {
|
|
2536
|
-
if (options && options.cache) return this.cache;
|
|
2537
|
-
if (options && options.matchId) {
|
|
2538
|
-
const route2 = Routes.guilds.matches.get(this.guild.id, options.matchId);
|
|
2539
|
-
const response2 = await this.rest.request({
|
|
2540
|
-
method: "get",
|
|
2541
|
-
url: route2
|
|
2542
|
-
});
|
|
2543
|
-
return this.set(response2);
|
|
2544
|
-
}
|
|
2545
|
-
const route = Routes.guilds.matches.getAll(this.guild.id);
|
|
2546
|
-
const response = await this.rest.request({
|
|
2547
|
-
method: "get",
|
|
2548
|
-
url: route
|
|
2549
|
-
});
|
|
2550
|
-
if (!response) return this.cache;
|
|
2551
|
-
const coll = new Collection("matches");
|
|
2552
|
-
for (let match of response ?? []) {
|
|
2553
|
-
const guildMatch = new GuildMatch(match, this);
|
|
2554
|
-
coll.set(match._id, guildMatch);
|
|
2555
|
-
this.rest.matches.set(match._id, guildMatch);
|
|
2556
|
-
}
|
|
2557
|
-
this.cache = coll;
|
|
2558
|
-
return coll;
|
|
2559
|
-
}
|
|
2560
|
-
async fetchAll() {
|
|
2561
|
-
const route = Routes.guilds.matches.getAll(this.guild.id);
|
|
2562
|
-
const response = await this.rest.request({
|
|
2563
|
-
method: "get",
|
|
2564
|
-
url: route
|
|
2565
|
-
});
|
|
2566
|
-
if (Array.isArray(response) && response.length === 0) {
|
|
2567
|
-
this.cache.clear();
|
|
2568
|
-
return this.cache;
|
|
2569
|
-
}
|
|
2570
|
-
this.set(response);
|
|
2571
|
-
return this.cache;
|
|
2572
|
-
}
|
|
2573
|
-
set(data) {
|
|
2574
|
-
if (!data) return this.cache;
|
|
2575
|
-
if (Array.isArray(data)) {
|
|
2576
|
-
for (let _match of data) {
|
|
2577
|
-
if (!_match._id) continue;
|
|
2578
|
-
const match = new GuildMatch(_match, this);
|
|
2579
|
-
this.cache.set(match._id, match);
|
|
2580
|
-
}
|
|
2581
|
-
return this.cache;
|
|
2582
|
-
} else {
|
|
2583
|
-
if (!data._id) return this.cache;
|
|
2584
|
-
if (data instanceof GuildMatch) {
|
|
2585
|
-
this.cache.set(data._id, data);
|
|
2586
|
-
return data;
|
|
2587
|
-
}
|
|
2588
|
-
const match = new GuildMatch(data, this);
|
|
2589
|
-
this.cache.set(match._id, match);
|
|
2590
|
-
return match;
|
|
2591
|
-
}
|
|
2592
|
-
}
|
|
2593
|
-
async create(payload) {
|
|
2594
|
-
Assertion.assertObject(payload);
|
|
2595
|
-
const route = Routes.guilds.matches.create(this.guild.id);
|
|
2596
|
-
const response = await this.rest.request({
|
|
2597
|
-
method: "POST",
|
|
2598
|
-
url: route,
|
|
2599
|
-
payload
|
|
2600
|
-
});
|
|
2601
|
-
return this.set(response);
|
|
2602
|
-
}
|
|
2603
|
-
async delete(id) {
|
|
2604
|
-
const route = Routes.fields(this.base_url, id);
|
|
2605
|
-
const response = await this.rest.request({ url: route, method: "DELETE" });
|
|
2606
|
-
return this.set(response);
|
|
2607
|
-
}
|
|
2608
|
-
};
|
|
2609
|
-
|
|
2610
|
-
// src/managers/mediator/GuildMediatorManager.ts
|
|
2611
|
-
var GuildMediatorManager = class extends BaseManager {
|
|
2612
|
-
constructor(guild) {
|
|
2613
|
-
super(guild);
|
|
2614
|
-
this.guild = guild;
|
|
2615
|
-
this.rest = guild.rest;
|
|
2616
|
-
this.base_url = Routes.guilds.mediators.getAll(guild.id);
|
|
2617
|
-
this.cache = new Collection("mediators");
|
|
2618
|
-
}
|
|
2619
|
-
async fetch(options) {
|
|
2620
|
-
if (options && options.cache) return this.cache;
|
|
2621
|
-
if (options && options.mediatorId) {
|
|
2622
|
-
const route2 = Routes.fields(this.base_url, options.mediatorId);
|
|
2623
|
-
const response2 = await this.rest.request({
|
|
2624
|
-
method: "GET",
|
|
2625
|
-
url: route2
|
|
2626
|
-
});
|
|
2627
|
-
return this.set(response2);
|
|
2628
|
-
}
|
|
2629
|
-
const route = this.base_url;
|
|
2630
|
-
const response = await this.rest.request({
|
|
2631
|
-
method: "GET",
|
|
2632
|
-
url: route
|
|
2633
|
-
});
|
|
2634
|
-
this.set(response);
|
|
2635
|
-
return this.cache;
|
|
2636
|
-
}
|
|
2637
|
-
async updateMany(...mediators) {
|
|
2638
|
-
const route = this.base_url;
|
|
2639
|
-
const response = await this.rest.request({
|
|
2640
|
-
method: "PATCH",
|
|
2641
|
-
url: route,
|
|
2642
|
-
payload: { mediators }
|
|
2643
|
-
});
|
|
2644
|
-
return this.set(response);
|
|
2645
|
-
}
|
|
2646
|
-
async create(payload) {
|
|
2647
|
-
const route = Routes.guilds.mediators.create(this.guild.id);
|
|
2648
|
-
const response = await this.rest.request({
|
|
2649
|
-
method: "POST",
|
|
2650
|
-
url: route,
|
|
2651
|
-
payload
|
|
2652
|
-
});
|
|
2653
|
-
return this.set(response);
|
|
2654
|
-
}
|
|
2655
|
-
async deleteAll() {
|
|
2656
|
-
const route = this.base_url;
|
|
2657
|
-
await this.rest.request({
|
|
2658
|
-
method: "DELETE",
|
|
2659
|
-
url: route
|
|
2660
|
-
});
|
|
2661
|
-
this.cache.clear();
|
|
2662
|
-
}
|
|
2663
|
-
async resetAll() {
|
|
2664
|
-
const route = this.base_url;
|
|
2665
|
-
const response = await this.rest.request({
|
|
2666
|
-
method: "put",
|
|
2667
|
-
url: route
|
|
2668
|
-
});
|
|
2669
|
-
this.cache.clear();
|
|
2670
|
-
this.set(response);
|
|
2671
|
-
return this.cache;
|
|
2672
|
-
}
|
|
2673
|
-
set(data) {
|
|
2674
|
-
if (!data) return this.cache;
|
|
2675
|
-
if (Array.isArray(data)) {
|
|
2676
|
-
for (let _mediator of data) {
|
|
2677
|
-
if (!_mediator.id) return;
|
|
2678
|
-
const mediator = new GuildMediator(_mediator, this);
|
|
2679
|
-
this.cache.set(mediator.id, mediator);
|
|
2680
|
-
this.rest.mediators.set(mediator.id, mediator);
|
|
2681
|
-
}
|
|
2682
|
-
return this.cache;
|
|
2683
|
-
} else {
|
|
2684
|
-
if (!data.id) return;
|
|
2685
|
-
const mediator = new GuildMediator(data, this);
|
|
2686
|
-
this.cache.set(mediator.id, mediator);
|
|
2687
|
-
this.rest.mediators.set(mediator.id, mediator);
|
|
2688
|
-
return mediator;
|
|
2689
|
-
}
|
|
2690
|
-
}
|
|
2691
|
-
};
|
|
2692
|
-
|
|
2693
|
-
// src/managers/message/MessagesManager.ts
|
|
2694
|
-
var MessagesManager = class {
|
|
2695
|
-
constructor(structure, base_url) {
|
|
2696
|
-
__publicField(this, "cache");
|
|
2697
|
-
__publicField(this, "base_url");
|
|
2698
|
-
__publicField(this, "rest");
|
|
2699
|
-
__publicField(this, "guild");
|
|
2700
|
-
this.rest = structure.rest;
|
|
2701
|
-
this.guild = structure.guild;
|
|
2702
|
-
this.cache = new Collection("messages");
|
|
2703
|
-
this.base_url = base_url;
|
|
2704
|
-
}
|
|
2705
|
-
async fetch() {
|
|
2706
|
-
const response = await this.rest.request({
|
|
2707
|
-
method: "GET",
|
|
2708
|
-
url: this.base_url,
|
|
2709
|
-
payload: {}
|
|
2710
|
-
});
|
|
2711
|
-
this.cache.set(response._id, response);
|
|
2712
|
-
return response;
|
|
2713
|
-
}
|
|
2714
|
-
async create(data) {
|
|
2715
|
-
const messages = [...this.cache.toArray()];
|
|
2716
|
-
if (Array.isArray(data)) messages.push(...data);
|
|
2717
|
-
else messages.push(data);
|
|
2718
|
-
const response = await this.rest.request({
|
|
2719
|
-
method: "PATCH",
|
|
2720
|
-
url: this.base_url,
|
|
2721
|
-
payload: { set: messages }
|
|
2722
|
-
});
|
|
2723
|
-
return this.set(response.messages);
|
|
2724
|
-
}
|
|
2725
|
-
set(data) {
|
|
2726
|
-
if (!data) return this.cache;
|
|
2727
|
-
if (Array.isArray(data)) {
|
|
2728
|
-
for (let message of data) {
|
|
2729
|
-
if (message && !message._id) continue;
|
|
2730
|
-
this.cache.set(message._id, message);
|
|
2731
|
-
}
|
|
2732
|
-
} else {
|
|
2733
|
-
if (data && !data._id) return this.cache;
|
|
2734
|
-
this.cache.set(data._id, data);
|
|
2735
|
-
}
|
|
2736
|
-
return this.cache;
|
|
2737
|
-
}
|
|
2738
|
-
};
|
|
2739
|
-
|
|
2740
|
-
// src/managers/permission/GuildPermissionManager.ts
|
|
2741
|
-
var GuildPermissionManager = class extends BaseManager {
|
|
2742
|
-
constructor(guild) {
|
|
2743
|
-
super(guild);
|
|
2744
|
-
this.guild = guild;
|
|
2745
|
-
this.rest = guild.rest;
|
|
2746
|
-
this.base_url = Routes.guilds.resource(guild.id, "permissions");
|
|
2747
|
-
}
|
|
2748
|
-
async addRole(type, ...ids) {
|
|
2749
|
-
const perm = this.guild.permissions.find((p) => p.type === type) || { ids: [], type };
|
|
2750
|
-
const _ids = [.../* @__PURE__ */ new Set([...perm.ids, ...ids])];
|
|
2751
|
-
const perms = [...this.guild.permissions];
|
|
2752
|
-
let permsIndex = this.guild.permissions.findIndex((p) => p.type === type);
|
|
2753
|
-
if (permsIndex === -1) perms.push({ type, ids: _ids });
|
|
2754
|
-
else perms[permsIndex] = { type, ids: _ids };
|
|
2755
|
-
const payload = { set: perms };
|
|
2756
|
-
const response = await this.rest.request({
|
|
2757
|
-
method: "PATCH",
|
|
2758
|
-
url: this.base_url,
|
|
2759
|
-
payload
|
|
2760
|
-
});
|
|
2761
|
-
this.guild.permissions = response.permissions;
|
|
2762
|
-
this.rest.guilds.cache.set(this.guild.id, this.guild);
|
|
2763
|
-
return response;
|
|
2764
|
-
}
|
|
2765
|
-
async removeRole(type, ...ids) {
|
|
2766
|
-
const perm = this.guild.permissions.find((p) => p.type === type) || { ids: [], type };
|
|
2767
|
-
const _ids = [.../* @__PURE__ */ new Set([...perm.ids.filter((i) => !ids.includes(i))])];
|
|
2768
|
-
const perms = [...this.guild.permissions];
|
|
2769
|
-
let permsIndex = this.guild.permissions.findIndex((p) => p.type === type);
|
|
2770
|
-
if (permsIndex === -1) {
|
|
2771
|
-
perms.push({ type, ids: _ids });
|
|
2772
|
-
} else {
|
|
2773
|
-
perms[permsIndex] = { type, ids: _ids };
|
|
2774
|
-
}
|
|
2775
|
-
const payload = { set: perms };
|
|
2776
|
-
const response = await this.rest.request({
|
|
2777
|
-
method: "PATCH",
|
|
2778
|
-
url: this.base_url,
|
|
2779
|
-
payload
|
|
2780
|
-
});
|
|
2781
|
-
this.guild.permissions = response.permissions;
|
|
2782
|
-
this.rest.guilds.cache.set(this.guild.id, this.guild);
|
|
2783
|
-
return response;
|
|
2784
|
-
}
|
|
2785
|
-
};
|
|
2786
|
-
|
|
2787
|
-
// src/managers/ticket/TicketManager.ts
|
|
2788
|
-
var GuildTicketManager = class {
|
|
2789
|
-
constructor(guild) {
|
|
2790
|
-
__publicField(this, "cache");
|
|
2791
|
-
__publicField(this, "guild");
|
|
2792
|
-
__publicField(this, "rest");
|
|
2793
|
-
this.guild = guild;
|
|
2794
|
-
this.rest = guild.rest;
|
|
2795
|
-
this.cache = new Collection("tickets");
|
|
2796
|
-
}
|
|
2797
|
-
async createTicketCategory(data) {
|
|
2798
|
-
const categories = this.guild.tickets_configuration.categories;
|
|
2799
|
-
let hasCategory = categories.find((c) => c.type === data?.type);
|
|
2800
|
-
if (hasCategory) {
|
|
2801
|
-
hasCategory = data;
|
|
2802
|
-
const index = categories.findIndex((c) => c.type === data?.type);
|
|
2803
|
-
categories[index] = hasCategory;
|
|
2804
|
-
} else {
|
|
2805
|
-
categories.push(data);
|
|
2806
|
-
}
|
|
2807
|
-
return this.guild.update({
|
|
2808
|
-
tickets_configuration: {
|
|
2809
|
-
categories,
|
|
2810
|
-
creationCategory: this.guild.tickets_configuration.creationCategory,
|
|
2811
|
-
deletionCategory: this.guild.tickets_configuration.deletionCategory,
|
|
2812
|
-
rating_channel_id: this.guild.tickets_configuration.rating_channel_id
|
|
2813
|
-
}
|
|
2814
|
-
});
|
|
2815
|
-
}
|
|
2816
|
-
async deleteTicketCategory(data) {
|
|
2817
|
-
let categories = this.guild.tickets_configuration.categories;
|
|
2818
|
-
let categoryIndex = categories.findIndex((c) => c.type === data?.type);
|
|
2819
|
-
if (categoryIndex === -1) return this.guild;
|
|
2820
|
-
categories = categories.filter((c) => c.type !== data.type);
|
|
2821
|
-
const payload = { tickets_configuration: { categories } };
|
|
2822
|
-
const route = Routes.guilds.get(this.guild.id);
|
|
2823
|
-
const response = await this.rest.request({
|
|
2824
|
-
method: "PATCH",
|
|
2825
|
-
url: route,
|
|
2826
|
-
payload
|
|
2827
|
-
});
|
|
2828
|
-
return this.guild.update({
|
|
2829
|
-
tickets_configuration: {
|
|
2830
|
-
categories,
|
|
2831
|
-
creationCategory: this.guild.tickets_configuration.creationCategory,
|
|
2832
|
-
deletionCategory: this.guild.tickets_configuration.deletionCategory,
|
|
2833
|
-
rating_channel_id: this.guild.tickets_configuration.rating_channel_id
|
|
2834
|
-
}
|
|
2835
|
-
});
|
|
2836
|
-
}
|
|
2837
|
-
async fetch(options) {
|
|
2838
|
-
if (options && options.cache) return this.cache;
|
|
2839
|
-
if (options && options.ticketId) {
|
|
2840
|
-
const route2 = Routes.guilds.tickets.get(this.guild.id, options.ticketId);
|
|
2841
|
-
const response2 = await this.rest.request({
|
|
2842
|
-
method: "GET",
|
|
2843
|
-
url: route2
|
|
2844
|
-
});
|
|
2845
|
-
return this.set(response2);
|
|
2846
|
-
}
|
|
2847
|
-
const route = Routes.guilds.tickets.getAll(this.guild.id);
|
|
2848
|
-
const response = await this.rest.request({
|
|
2849
|
-
method: "GET",
|
|
2850
|
-
url: route
|
|
2851
|
-
});
|
|
2852
|
-
return this.set(response);
|
|
2853
|
-
}
|
|
2854
|
-
async create(data) {
|
|
2855
|
-
const route = Routes.guilds.tickets.create(this.guild.id);
|
|
2856
|
-
const response = await this.rest.request({
|
|
2857
|
-
method: "POST",
|
|
2858
|
-
url: route,
|
|
2859
|
-
payload: data
|
|
2860
|
-
});
|
|
2861
|
-
const ticket = this.set(response);
|
|
2862
|
-
this.rest.emit("ticketCreate", ticket);
|
|
2863
|
-
return ticket;
|
|
2864
|
-
}
|
|
2865
|
-
async delete(options) {
|
|
2866
|
-
if (options && options.ticketId) {
|
|
2867
|
-
const route2 = Routes.guilds.tickets.delete(this.guild.id, options.ticketId);
|
|
2868
|
-
await this.rest.request({
|
|
2869
|
-
method: "DELETE",
|
|
2870
|
-
url: route2
|
|
2871
|
-
});
|
|
2872
|
-
this.rest.emit("ticketDelete", this.cache.get(options.ticketId));
|
|
2873
|
-
this.cache.delete(options.ticketId);
|
|
2874
|
-
return true;
|
|
2875
|
-
}
|
|
2876
|
-
const route = Routes.guilds.tickets.deleteAll(this.guild.id);
|
|
2877
|
-
await this.rest.request({
|
|
2878
|
-
method: "DELETE",
|
|
2879
|
-
url: route
|
|
2880
|
-
});
|
|
2881
|
-
this.rest.emit("ticketsDelete", this.cache);
|
|
2882
|
-
this.cache.clear();
|
|
2883
|
-
return true;
|
|
2884
|
-
}
|
|
2885
|
-
set(data) {
|
|
2886
|
-
if (!data) return this.cache;
|
|
2887
|
-
if (Array.isArray(data)) {
|
|
2888
|
-
for (let _ticket of data) {
|
|
2889
|
-
if (!_ticket._id) return;
|
|
2890
|
-
const ticket = new GuildTicket(_ticket, this);
|
|
2891
|
-
this.cache.set(ticket._id, ticket);
|
|
2892
|
-
this.rest.tickets.set(ticket._id, ticket);
|
|
2893
|
-
}
|
|
2894
|
-
return this.cache;
|
|
2895
|
-
} else {
|
|
2896
|
-
if (!data._id) return;
|
|
2897
|
-
const ticket = new GuildTicket(data, this);
|
|
2898
|
-
this.cache.set(ticket._id, ticket);
|
|
2899
|
-
this.rest.tickets.set(ticket._id, ticket);
|
|
2900
|
-
return ticket;
|
|
2901
|
-
}
|
|
2902
|
-
}
|
|
2903
|
-
};
|
|
2904
|
-
|
|
2905
|
-
// src/managers/user/GuildUserManager.ts
|
|
2906
|
-
var GuildUserManager = class extends BaseManager {
|
|
2907
|
-
constructor(guild) {
|
|
2908
|
-
super(guild);
|
|
2909
|
-
this.guild = guild;
|
|
2910
|
-
this.rest = guild.rest;
|
|
2911
|
-
this.base_url = Routes.guilds.users.getAll(guild.id);
|
|
2912
|
-
this.cache = new Collection("users");
|
|
2913
|
-
}
|
|
2914
|
-
async fetch(options) {
|
|
2915
|
-
if (options && options.cache) return this.cache;
|
|
2916
|
-
if (options && options.userId) {
|
|
2917
|
-
const route2 = Routes.fields(this.base_url, options.userId);
|
|
2918
|
-
const response2 = await this.rest.request({
|
|
2919
|
-
method: "GET",
|
|
2920
|
-
url: route2
|
|
2921
|
-
});
|
|
2922
|
-
const user = new GuildUser(response2, this);
|
|
2923
|
-
this.set(user);
|
|
2924
|
-
return user;
|
|
2925
|
-
}
|
|
2926
|
-
const route = this.base_url;
|
|
2927
|
-
const response = await this.rest.request({
|
|
2928
|
-
method: "GET",
|
|
2929
|
-
url: route
|
|
2930
|
-
});
|
|
2931
|
-
this.cache.clear();
|
|
2932
|
-
for (let userData of response) {
|
|
2933
|
-
const user = new GuildUser(userData, this);
|
|
2934
|
-
this.set(user);
|
|
2935
|
-
}
|
|
2936
|
-
return this.cache;
|
|
2937
|
-
}
|
|
2938
|
-
async updateMany(...users) {
|
|
2939
|
-
const route = this.base_url;
|
|
2940
|
-
const response = await this.rest.request({
|
|
2941
|
-
method: "PATCH",
|
|
2942
|
-
url: route,
|
|
2943
|
-
payload: { users }
|
|
2944
|
-
});
|
|
2945
|
-
for (const userData of response) {
|
|
2946
|
-
const user = new GuildUser(userData, this);
|
|
2947
|
-
this.set(user);
|
|
2948
|
-
}
|
|
2949
|
-
return this.cache;
|
|
2950
|
-
}
|
|
2951
|
-
async deleteAll() {
|
|
2952
|
-
const route = this.base_url;
|
|
2953
|
-
await this.rest.request({
|
|
2954
|
-
method: "DELETE",
|
|
2955
|
-
url: route
|
|
2956
|
-
});
|
|
2957
|
-
this.cache.clear();
|
|
2958
|
-
}
|
|
2959
|
-
async resetAll() {
|
|
2960
|
-
const route = this.base_url;
|
|
2961
|
-
const response = await this.rest.request({
|
|
2962
|
-
method: "put",
|
|
2963
|
-
url: route
|
|
2964
|
-
});
|
|
2965
|
-
this.cache.clear();
|
|
2966
|
-
this.set(response);
|
|
2967
|
-
return this.cache;
|
|
2968
|
-
}
|
|
2969
|
-
set(data) {
|
|
2970
|
-
if (!data) return this.cache;
|
|
2971
|
-
if (Array.isArray(data)) {
|
|
2972
|
-
for (let _user of data) {
|
|
2973
|
-
if (!_user.id) return;
|
|
2974
|
-
const user = new GuildUser(_user, this);
|
|
2975
|
-
this.cache.set(user.id, user);
|
|
2976
|
-
this.rest.users.set(user.id, user);
|
|
2977
|
-
}
|
|
2978
|
-
return this.cache;
|
|
2979
|
-
} else {
|
|
2980
|
-
if (!data.id) return;
|
|
2981
|
-
const user = new GuildUser(data, this);
|
|
2982
|
-
this.cache.set(user.id, user);
|
|
2983
|
-
this.rest.users.set(user.id, user);
|
|
2984
|
-
return user;
|
|
2985
|
-
}
|
|
2986
|
-
}
|
|
2987
|
-
};
|
|
2988
|
-
|
|
2989
|
-
// src/managers/vipmember/VipMemberManager.ts
|
|
2990
|
-
var VipMemberManager = class extends BaseManager {
|
|
2991
|
-
/**
|
|
2992
|
-
* Manage vipmembers with the given client
|
|
2993
|
-
* @param vipmembers An array of vipmembers
|
|
2994
|
-
* @param rest The rest client
|
|
2995
|
-
*/
|
|
2996
|
-
constructor(guild) {
|
|
2997
|
-
super(guild);
|
|
2998
|
-
this.guild = guild;
|
|
2999
|
-
this.rest = guild.rest;
|
|
3000
|
-
this.base_url = Routes.guilds.resource(guild.id, "vipmembers");
|
|
3001
|
-
this.cache = new Collection("vipmembers");
|
|
3002
|
-
}
|
|
3003
|
-
async create(data) {
|
|
3004
|
-
const route = Routes.vipmembers.create(this.guild.id);
|
|
3005
|
-
const payload = { ...data };
|
|
3006
|
-
const response = await this.rest.request({
|
|
3007
|
-
method: "post",
|
|
3008
|
-
url: route,
|
|
3009
|
-
payload
|
|
3010
|
-
});
|
|
3011
|
-
const member = new VipMember(response, this);
|
|
3012
|
-
this.cache.set(member?.id, member);
|
|
3013
|
-
return member;
|
|
3014
|
-
}
|
|
3015
|
-
/**
|
|
3016
|
-
* Fetch a member
|
|
3017
|
-
* @param id Id of the member to fetch
|
|
3018
|
-
* @returns VipMember
|
|
3019
|
-
*/
|
|
3020
|
-
async fetch(options) {
|
|
3021
|
-
if (options && options.cache) return this.cache;
|
|
3022
|
-
if (options && options.memberId) {
|
|
3023
|
-
const route2 = Routes.vipmembers.get(this.guild.id, options.memberId);
|
|
3024
|
-
const payload = { guild_id: this.guild.id };
|
|
3025
|
-
const response2 = await this.rest.request({
|
|
3026
|
-
method: "get",
|
|
3027
|
-
url: route2,
|
|
3028
|
-
payload
|
|
3029
|
-
});
|
|
3030
|
-
if (!response2) return this.cache.get(options.memberId);
|
|
3031
|
-
const member = new VipMember(response2, this);
|
|
3032
|
-
this.cache.set(member?.id, member);
|
|
3033
|
-
return member;
|
|
3034
|
-
}
|
|
3035
|
-
const route = Routes.vipmembers.getAll(this.guild.id);
|
|
3036
|
-
const response = await this.rest.request({
|
|
3037
|
-
method: "get",
|
|
3038
|
-
url: route
|
|
3039
|
-
});
|
|
3040
|
-
if (Array.isArray(response) && response.length === 0) {
|
|
3041
|
-
this.cache.clear();
|
|
3042
|
-
return this.cache;
|
|
3043
|
-
}
|
|
3044
|
-
this.setAll(response);
|
|
3045
|
-
return this.cache;
|
|
3046
|
-
}
|
|
3047
|
-
async updateMember(id, data) {
|
|
3048
|
-
const route = Routes.vipmembers.update(this.guild.id, id);
|
|
3049
|
-
const payload = { ...data, guild_id: this.guild.id };
|
|
3050
|
-
const response = await this.rest.request({
|
|
3051
|
-
method: "patch",
|
|
3052
|
-
url: route,
|
|
3053
|
-
payload
|
|
3054
|
-
});
|
|
3055
|
-
const member = this.set(response);
|
|
3056
|
-
return member;
|
|
3057
|
-
}
|
|
3058
|
-
set(data) {
|
|
3059
|
-
if (!data?.id) return;
|
|
3060
|
-
const member = new VipMember(data, this);
|
|
3061
|
-
this.cache.set(member.id, member);
|
|
3062
|
-
return member;
|
|
3063
|
-
}
|
|
3064
|
-
setAll(data) {
|
|
3065
|
-
if (!data) return this.cache;
|
|
3066
|
-
for (let member of data) this.set(member);
|
|
3067
|
-
return this.cache;
|
|
3068
|
-
}
|
|
3069
|
-
async resetAll() {
|
|
3070
|
-
const route = Routes.vipmembers.getAll(this.guild.id);
|
|
3071
|
-
const response = await this.rest.request({
|
|
3072
|
-
method: "PUT",
|
|
3073
|
-
url: route
|
|
3074
|
-
});
|
|
3075
|
-
this.setAll(response);
|
|
3076
|
-
return this.cache;
|
|
3077
|
-
}
|
|
3078
|
-
async delete(id) {
|
|
3079
|
-
Assertion.assertString(id);
|
|
3080
|
-
Assertion.assertString(this.guild.id);
|
|
3081
|
-
const route = Routes.vipmembers.delete(id, this.guild.id);
|
|
3082
|
-
await this.rest.request({
|
|
3083
|
-
method: "DELETE",
|
|
3084
|
-
url: route
|
|
3085
|
-
});
|
|
3086
|
-
this.cache.delete(id);
|
|
3087
|
-
return this.cache;
|
|
3088
|
-
}
|
|
3089
|
-
async deleteAll() {
|
|
3090
|
-
Assertion.assertString(this.guild.id);
|
|
3091
|
-
const route = Routes.vipmembers.deleteAll(this.guild.id);
|
|
3092
|
-
const value = await this.rest.request({
|
|
3093
|
-
method: "DELETE",
|
|
3094
|
-
url: route
|
|
3095
|
-
});
|
|
3096
|
-
this.cache.clear();
|
|
3097
|
-
return value;
|
|
3098
|
-
}
|
|
3099
|
-
};
|
|
3100
|
-
|
|
3101
|
-
// src/structures/tournament/Tournament.ts
|
|
3102
|
-
var _Tournament_instances, updateInternals_fn9;
|
|
3103
|
-
var Tournament = class {
|
|
3104
|
-
constructor(data, manager) {
|
|
3105
|
-
__privateAdd(this, _Tournament_instances);
|
|
3106
|
-
__publicField(this, "_id");
|
|
3107
|
-
__publicField(this, "guild_id");
|
|
3108
|
-
__publicField(this, "type");
|
|
3109
|
-
__publicField(this, "max_teams");
|
|
3110
|
-
__publicField(this, "teams");
|
|
3111
|
-
__publicField(this, "message");
|
|
3112
|
-
__publicField(this, "message_id");
|
|
3113
|
-
__publicField(this, "status");
|
|
3114
|
-
__publicField(this, "createdAt");
|
|
3115
|
-
__publicField(this, "updatedAt");
|
|
3116
|
-
__publicField(this, "guild");
|
|
3117
|
-
__publicField(this, "rest");
|
|
3118
|
-
__publicField(this, "manager");
|
|
3119
|
-
__publicField(this, "data");
|
|
3120
|
-
this.manager = manager;
|
|
3121
|
-
this.guild = manager.guild;
|
|
3122
|
-
this.rest = manager.rest;
|
|
3123
|
-
this.guild_id = data?.guild_id;
|
|
3124
|
-
this.type = data?.type;
|
|
3125
|
-
this.teams = data?.teams;
|
|
3126
|
-
this.message = data?.message;
|
|
3127
|
-
this.message_id = data?.message_id;
|
|
3128
|
-
this.status = data?.status;
|
|
3129
|
-
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
3130
|
-
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
3131
|
-
this.data = data;
|
|
3132
|
-
}
|
|
3133
|
-
async fetch() {
|
|
3134
|
-
const route = Routes.fields("guilds", this.guild.id, "tournaments", this._id);
|
|
3135
|
-
const response = await this.rest.request({
|
|
3136
|
-
method: "get",
|
|
3137
|
-
url: route
|
|
3138
|
-
});
|
|
3139
|
-
return __privateMethod(this, _Tournament_instances, updateInternals_fn9).call(this, response);
|
|
3140
|
-
}
|
|
3141
|
-
async update(data) {
|
|
3142
|
-
const route = Routes.fields("guilds", this.guild.id, "tournaments", this._id);
|
|
3143
|
-
const response = await this.rest.request({
|
|
3144
|
-
method: "patch",
|
|
3145
|
-
url: route,
|
|
3146
|
-
payload: data
|
|
3147
|
-
});
|
|
3148
|
-
return __privateMethod(this, _Tournament_instances, updateInternals_fn9).call(this, response);
|
|
3149
|
-
}
|
|
3150
|
-
toJSON() {
|
|
3151
|
-
return {
|
|
3152
|
-
guild_id: this.guild_id,
|
|
3153
|
-
type: this.type,
|
|
3154
|
-
max_teams: this.max_teams,
|
|
3155
|
-
teams: this.teams,
|
|
3156
|
-
message: this.message,
|
|
3157
|
-
message_id: this.message_id,
|
|
3158
|
-
status: this.status,
|
|
3159
|
-
createdAt: this.createdAt ? new Date(this?.createdAt) : /* @__PURE__ */ new Date(),
|
|
3160
|
-
updatedAt: this.updatedAt ? new Date(this?.updatedAt) : /* @__PURE__ */ new Date()
|
|
3161
|
-
};
|
|
3162
|
-
}
|
|
3163
|
-
};
|
|
3164
|
-
_Tournament_instances = new WeakSet();
|
|
3165
|
-
updateInternals_fn9 = function(data) {
|
|
3166
|
-
for (let key in data) {
|
|
3167
|
-
if (key === "id" || key === "createdAt") continue;
|
|
3168
|
-
if (key in this) {
|
|
3169
|
-
this[key] = data[key];
|
|
3170
|
-
}
|
|
3171
|
-
}
|
|
3172
|
-
this.updatedAt = /* @__PURE__ */ new Date();
|
|
3173
|
-
this.createdAt = new Date(data.createdAt);
|
|
3174
|
-
this.manager._add(this);
|
|
3175
|
-
return this;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all)
|
|
12
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
3176
13
|
};
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
this.guild = guild;
|
|
3183
|
-
this.rest = guild.rest;
|
|
3184
|
-
this.base_url = Routes.guilds.resource(guild.id, "tournaments");
|
|
3185
|
-
this.cache = new Collection();
|
|
3186
|
-
}
|
|
3187
|
-
async fetch(options) {
|
|
3188
|
-
if (options && options.cache) return this.cache;
|
|
3189
|
-
if (options && options.tournamentId) {
|
|
3190
|
-
const response2 = await this.rest.request({
|
|
3191
|
-
method: "GET",
|
|
3192
|
-
url: Routes.fields(this.base_url, options.tournamentId)
|
|
3193
|
-
});
|
|
3194
|
-
const tournament = new Tournament(response2, this);
|
|
3195
|
-
this._add(tournament);
|
|
3196
|
-
return tournament;
|
|
3197
|
-
}
|
|
3198
|
-
const response = await this.rest.request({
|
|
3199
|
-
method: "GET",
|
|
3200
|
-
url: this.base_url
|
|
3201
|
-
});
|
|
3202
|
-
return this.set(response);
|
|
3203
|
-
}
|
|
3204
|
-
set(data) {
|
|
3205
|
-
this.cache.clear();
|
|
3206
|
-
if (Array.isArray(data)) {
|
|
3207
|
-
for (let _m of data) {
|
|
3208
|
-
if (!_m._id) continue;
|
|
3209
|
-
if (_m instanceof Tournament) this.cache.set(_m._id, _m);
|
|
3210
|
-
else this.cache.set(_m._id, new Tournament(_m, this));
|
|
3211
|
-
}
|
|
3212
|
-
} else {
|
|
3213
|
-
if (!data._id) return this.cache;
|
|
3214
|
-
if (data instanceof Tournament) this.cache.set(data._id, data);
|
|
3215
|
-
else this.cache.set(data._id, new Tournament(data, this));
|
|
3216
|
-
}
|
|
3217
|
-
return this.cache;
|
|
3218
|
-
}
|
|
3219
|
-
_add(data) {
|
|
3220
|
-
if (Array.isArray(data)) {
|
|
3221
|
-
for (let _m of data) {
|
|
3222
|
-
if (!_m._id) continue;
|
|
3223
|
-
if (_m instanceof Tournament) this.cache.set(_m._id, _m);
|
|
3224
|
-
else this.cache.set(_m._id, new Tournament(_m, this));
|
|
3225
|
-
}
|
|
3226
|
-
} else {
|
|
3227
|
-
if (!data._id) return this.cache;
|
|
3228
|
-
if (data instanceof Tournament) this.cache.set(data._id, data);
|
|
3229
|
-
else this.cache.set(data._id, new Tournament(data, this));
|
|
3230
|
-
}
|
|
3231
|
-
return this.cache;
|
|
14
|
+
var __copyProps = (to, from, except, desc) => {
|
|
15
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
16
|
+
for (let key of __getOwnPropNames(from))
|
|
17
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
18
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
3232
19
|
}
|
|
20
|
+
return to;
|
|
3233
21
|
};
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
var
|
|
3237
|
-
var
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
24
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
25
|
+
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);
|
|
26
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
27
|
+
var Guild_exports = {};
|
|
28
|
+
__export(Guild_exports, {
|
|
29
|
+
Guild: () => Guild
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(Guild_exports);
|
|
32
|
+
var import_managers = require("../../managers");
|
|
33
|
+
var import_GuildBetUserManager = require("../../managers/betuser/GuildBetUserManager");
|
|
34
|
+
var import_GuildMediatorManager = require("../../managers/mediator/GuildMediatorManager");
|
|
35
|
+
var import_TicketPanelManager = require("../../managers/ticketpanel/TicketPanelManager");
|
|
36
|
+
var import_TournamentManager = require("../../managers/tournament/TournamentManager");
|
|
37
|
+
var import_Routes = require("../../rest/Routes");
|
|
38
|
+
var import_Assertion = require("../../utils/Assertion");
|
|
39
|
+
var _Guild_instances, update_fn;
|
|
40
|
+
class Guild {
|
|
3238
41
|
/**
|
|
3239
42
|
* The guild structure
|
|
3240
43
|
* @param data The guild's data
|
|
@@ -3259,6 +62,8 @@ var Guild = class {
|
|
|
3259
62
|
__publicField(this, "tickets_configuration");
|
|
3260
63
|
/** Guild Daily Categories */
|
|
3261
64
|
__publicField(this, "daily_categories");
|
|
65
|
+
__publicField(this, "match_count");
|
|
66
|
+
__publicField(this, "bet_count");
|
|
3262
67
|
/** Guild Scores */
|
|
3263
68
|
__publicField(this, "scores");
|
|
3264
69
|
/** Guild Status */
|
|
@@ -3281,14 +86,15 @@ var Guild = class {
|
|
|
3281
86
|
__publicField(this, "vipMembers");
|
|
3282
87
|
__publicField(this, "users");
|
|
3283
88
|
__publicField(this, "logEntries");
|
|
3284
|
-
__publicField(this, "
|
|
89
|
+
__publicField(this, "shops");
|
|
3285
90
|
__publicField(this, "betusers");
|
|
3286
91
|
__publicField(this, "bets");
|
|
3287
92
|
__publicField(this, "mediators");
|
|
3288
|
-
__publicField(this, "
|
|
3289
|
-
__publicField(this, "automaticMessagesManager");
|
|
93
|
+
__publicField(this, "automaticMessages");
|
|
3290
94
|
__publicField(this, "tournaments");
|
|
95
|
+
__publicField(this, "webhook_urls");
|
|
3291
96
|
__publicField(this, "adverts");
|
|
97
|
+
__publicField(this, "ticket_panels");
|
|
3292
98
|
__publicField(this, "codes");
|
|
3293
99
|
__publicField(this, "coin_symbol");
|
|
3294
100
|
this.data = data;
|
|
@@ -3305,25 +111,46 @@ var Guild = class {
|
|
|
3305
111
|
this.prefixes = data?.prefixes;
|
|
3306
112
|
this.status = data?.status;
|
|
3307
113
|
this.tickets_configuration = data?.tickets_configuration;
|
|
3308
|
-
this.automatic_messages = data?.automatic_messages;
|
|
3309
114
|
this.channels = data?.channels;
|
|
3310
|
-
this.shop = data?.shop;
|
|
3311
115
|
this.coin_symbol = data?.coin_symbol;
|
|
3312
116
|
this.roulette_settings = data?.roulette_settings;
|
|
117
|
+
this.webhook_urls = data?.webhook_urls || {
|
|
118
|
+
queues: {
|
|
119
|
+
closed: "",
|
|
120
|
+
managed: "",
|
|
121
|
+
shutted: "",
|
|
122
|
+
started: ""
|
|
123
|
+
},
|
|
124
|
+
users: {
|
|
125
|
+
punished: "",
|
|
126
|
+
updated: ""
|
|
127
|
+
},
|
|
128
|
+
shop: {
|
|
129
|
+
redeemed: ""
|
|
130
|
+
},
|
|
131
|
+
tickets: {
|
|
132
|
+
closed: "",
|
|
133
|
+
opened: ""
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
this.match_count = data?.match_count;
|
|
137
|
+
this.bet_count = data?.bet_count;
|
|
3313
138
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
3314
139
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
3315
|
-
this.permissionsManager = new GuildPermissionManager(this);
|
|
3316
|
-
this.buffer = new BufferManager(this);
|
|
3317
|
-
this.
|
|
3318
|
-
this.
|
|
3319
|
-
this.
|
|
3320
|
-
this.
|
|
3321
|
-
this.
|
|
3322
|
-
this.
|
|
3323
|
-
this.
|
|
3324
|
-
this.
|
|
3325
|
-
this.
|
|
3326
|
-
this.
|
|
140
|
+
this.permissionsManager = new import_managers.GuildPermissionManager(this);
|
|
141
|
+
this.buffer = new import_managers.BufferManager(this);
|
|
142
|
+
this.shops = new import_managers.ShopManager(this);
|
|
143
|
+
this.users = new import_managers.GuildUserManager(this);
|
|
144
|
+
this.matches = new import_managers.GuildMatchManager(this);
|
|
145
|
+
this.tickets = new import_managers.GuildTicketManager(this);
|
|
146
|
+
this.vipMembers = new import_managers.VipMemberManager(this);
|
|
147
|
+
this.logEntries = new import_managers.LogManager(this);
|
|
148
|
+
this.betusers = new import_GuildBetUserManager.GuildBetUserManager(this);
|
|
149
|
+
this.bets = new import_managers.GuildBetManager(this);
|
|
150
|
+
this.mediators = new import_GuildMediatorManager.GuildMediatorManager(this);
|
|
151
|
+
this.automaticMessages = new import_managers.AutomaticMessageManager(this);
|
|
152
|
+
this.tournaments = new import_TournamentManager.TournamentManager(this);
|
|
153
|
+
this.ticket_panels = new import_TicketPanelManager.TicketPanelManager(this);
|
|
3327
154
|
this.adverts = [];
|
|
3328
155
|
for (let _adv of data?.adverts || []) {
|
|
3329
156
|
this.adverts.push({
|
|
@@ -3349,18 +176,35 @@ var Guild = class {
|
|
|
3349
176
|
});
|
|
3350
177
|
}
|
|
3351
178
|
}
|
|
179
|
+
async _start() {
|
|
180
|
+
await Promise.all([
|
|
181
|
+
this.users.fetch(),
|
|
182
|
+
this.matches.fetch(),
|
|
183
|
+
this.tickets.fetch(),
|
|
184
|
+
this.vipMembers.fetch(),
|
|
185
|
+
this.logEntries.fetch(),
|
|
186
|
+
this.betusers.fetch(),
|
|
187
|
+
this.bets.fetch(),
|
|
188
|
+
this.mediators.fetch(),
|
|
189
|
+
this.tournaments.fetch(),
|
|
190
|
+
this.shops.fetch(),
|
|
191
|
+
this.automaticMessages.fetch(),
|
|
192
|
+
this.ticket_panels.fetch(null)
|
|
193
|
+
]);
|
|
194
|
+
return this;
|
|
195
|
+
}
|
|
3352
196
|
async getChannel(type) {
|
|
3353
197
|
const channel = this.channels.find((c) => c.type === type);
|
|
3354
198
|
if (channel) return channel;
|
|
3355
199
|
else {
|
|
3356
200
|
const channels = [...this.channels, { type, ids: [] }];
|
|
3357
|
-
const
|
|
201
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3358
202
|
const response = await this.rest.request({
|
|
3359
203
|
method: "PATCH",
|
|
3360
|
-
url
|
|
204
|
+
url,
|
|
3361
205
|
payload: { channels }
|
|
3362
206
|
});
|
|
3363
|
-
__privateMethod(this, _Guild_instances,
|
|
207
|
+
__privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3364
208
|
return response.channels.find((t) => t.type === type);
|
|
3365
209
|
}
|
|
3366
210
|
}
|
|
@@ -3369,41 +213,54 @@ var Guild = class {
|
|
|
3369
213
|
if (permission) return permission;
|
|
3370
214
|
else {
|
|
3371
215
|
const permissions = [...this.permissions, { type, ids: [] }];
|
|
3372
|
-
const
|
|
216
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3373
217
|
const response = await this.rest.request({
|
|
3374
218
|
method: "PATCH",
|
|
3375
|
-
url
|
|
219
|
+
url,
|
|
3376
220
|
payload: { permissions }
|
|
3377
221
|
});
|
|
3378
|
-
__privateMethod(this, _Guild_instances,
|
|
222
|
+
__privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3379
223
|
return response.permissions.find((t) => t.type === type);
|
|
3380
224
|
}
|
|
3381
225
|
}
|
|
3382
226
|
async createAdvert(data) {
|
|
3383
227
|
this.adverts.push(data);
|
|
3384
|
-
const
|
|
228
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
229
|
+
const payload = { adverts: this.adverts, max_advert_per_user: this.adverts.length };
|
|
230
|
+
const response = await this.rest.request({ method: "PATCH", url, payload });
|
|
231
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
232
|
+
}
|
|
233
|
+
async updateAdvert(data) {
|
|
234
|
+
const advIndex = this.adverts.findIndex((a) => a._id === data._id);
|
|
235
|
+
if (advIndex === -1) return this;
|
|
236
|
+
this.adverts[advIndex] = { ...this.adverts[advIndex], ...data };
|
|
237
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3385
238
|
const payload = { adverts: this.adverts };
|
|
3386
|
-
const response = await this.rest.request({ method: "PATCH", url
|
|
3387
|
-
return __privateMethod(this, _Guild_instances,
|
|
239
|
+
const response = await this.rest.request({ method: "PATCH", url, payload });
|
|
240
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3388
241
|
}
|
|
3389
242
|
async removeAdvert(advertId) {
|
|
3390
|
-
const
|
|
3391
|
-
|
|
3392
|
-
const
|
|
3393
|
-
|
|
243
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
244
|
+
this.adverts = this.adverts.filter((a) => a._id !== advertId);
|
|
245
|
+
const payload = {
|
|
246
|
+
adverts: this.adverts,
|
|
247
|
+
max_advert_per_user: this.adverts.length
|
|
248
|
+
};
|
|
249
|
+
const response = await this.rest.request({ method: "PATCH", url, payload });
|
|
250
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3394
251
|
}
|
|
3395
252
|
async createCode(data) {
|
|
3396
253
|
this.codes.push(data);
|
|
3397
|
-
const
|
|
254
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3398
255
|
const payload = { codes: this.codes };
|
|
3399
|
-
const response = await this.rest.request({ method: "PATCH", url
|
|
3400
|
-
return __privateMethod(this, _Guild_instances,
|
|
256
|
+
const response = await this.rest.request({ method: "PATCH", url, payload });
|
|
257
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3401
258
|
}
|
|
3402
259
|
async removeCode(codeId) {
|
|
3403
|
-
const
|
|
3404
|
-
const payload = { codes: this.codes.filter((a) => a.
|
|
3405
|
-
const response = await this.rest.request({ method: "PATCH", url
|
|
3406
|
-
return __privateMethod(this, _Guild_instances,
|
|
260
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
261
|
+
const payload = { codes: this.codes.filter((a) => a.code.toLowerCase() !== codeId.toLowerCase()) };
|
|
262
|
+
const response = await this.rest.request({ method: "PATCH", url, payload });
|
|
263
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3407
264
|
}
|
|
3408
265
|
async addIdToChannel(type, id) {
|
|
3409
266
|
const channel = this.channels.find((c) => c.type === type);
|
|
@@ -3415,14 +272,14 @@ var Guild = class {
|
|
|
3415
272
|
const mergedIds = [.../* @__PURE__ */ new Set([...channel.ids || [], ...idsToAdd])];
|
|
3416
273
|
this.channels[chIndex] = { ...channel, ids: mergedIds };
|
|
3417
274
|
}
|
|
3418
|
-
const
|
|
275
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3419
276
|
const payload = { channels: this.channels };
|
|
3420
277
|
const response = await this.rest.request({
|
|
3421
278
|
method: "PATCH",
|
|
3422
|
-
url
|
|
279
|
+
url,
|
|
3423
280
|
payload
|
|
3424
281
|
});
|
|
3425
|
-
return __privateMethod(this, _Guild_instances,
|
|
282
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3426
283
|
}
|
|
3427
284
|
async setChannelIds(type, ...ids) {
|
|
3428
285
|
const channel = this.channels.find((c) => c.type === type);
|
|
@@ -3434,14 +291,14 @@ var Guild = class {
|
|
|
3434
291
|
const mergedIds = [.../* @__PURE__ */ new Set([...ids])];
|
|
3435
292
|
this.channels[chIndex] = { ...channel, ids: mergedIds };
|
|
3436
293
|
}
|
|
3437
|
-
const
|
|
294
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3438
295
|
const payload = { channels: this.channels };
|
|
3439
296
|
const response = await this.rest.request({
|
|
3440
297
|
method: "PATCH",
|
|
3441
|
-
url
|
|
298
|
+
url,
|
|
3442
299
|
payload
|
|
3443
300
|
});
|
|
3444
|
-
return __privateMethod(this, _Guild_instances,
|
|
301
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3445
302
|
}
|
|
3446
303
|
async removeIdInChannel(type, id) {
|
|
3447
304
|
const chIndex = this.channels.findIndex((c) => c.type === type);
|
|
@@ -3456,14 +313,14 @@ var Guild = class {
|
|
|
3456
313
|
ids: []
|
|
3457
314
|
});
|
|
3458
315
|
}
|
|
3459
|
-
const
|
|
316
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3460
317
|
const payload = { channels: this.channels };
|
|
3461
318
|
const response = await this.rest.request({
|
|
3462
319
|
method: "PATCH",
|
|
3463
|
-
url
|
|
320
|
+
url,
|
|
3464
321
|
payload
|
|
3465
322
|
});
|
|
3466
|
-
return __privateMethod(this, _Guild_instances,
|
|
323
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3467
324
|
}
|
|
3468
325
|
async updateRouletteSettings(data) {
|
|
3469
326
|
const _data = {
|
|
@@ -3477,6 +334,30 @@ var Guild = class {
|
|
|
3477
334
|
};
|
|
3478
335
|
return this.update(_data);
|
|
3479
336
|
}
|
|
337
|
+
async updateLogWebhookUrls(data) {
|
|
338
|
+
const _data = {
|
|
339
|
+
webhook_urls: {
|
|
340
|
+
queues: {
|
|
341
|
+
closed: data?.queues?.closed || this.webhook_urls?.queues?.closed || "",
|
|
342
|
+
managed: data?.queues?.managed || this.webhook_urls?.queues?.managed || "",
|
|
343
|
+
shutted: data?.queues?.shutted || this.webhook_urls?.queues?.shutted || "",
|
|
344
|
+
started: data?.queues?.started || this.webhook_urls?.queues?.started || ""
|
|
345
|
+
},
|
|
346
|
+
users: {
|
|
347
|
+
punished: data?.users?.punished || this.webhook_urls?.users?.punished || "",
|
|
348
|
+
updated: data?.users?.updated || this.webhook_urls?.users?.updated || ""
|
|
349
|
+
},
|
|
350
|
+
shop: {
|
|
351
|
+
redeemed: data?.shop?.redeemed || this.webhook_urls?.shop?.redeemed || ""
|
|
352
|
+
},
|
|
353
|
+
tickets: {
|
|
354
|
+
closed: data?.tickets?.closed || this.webhook_urls?.tickets?.closed || "",
|
|
355
|
+
opened: data?.tickets?.opened || this.webhook_urls?.tickets?.opened || ""
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
return this.update(_data);
|
|
360
|
+
}
|
|
3480
361
|
getActive(key) {
|
|
3481
362
|
return this[key].cache.filter((o) => o.status === "created" || o.status === "on");
|
|
3482
363
|
}
|
|
@@ -3511,48 +392,34 @@ var Guild = class {
|
|
|
3511
392
|
prizes = prizes.filter((p) => p._id !== id);
|
|
3512
393
|
return this.updateRouletteSettings({ prizes });
|
|
3513
394
|
}
|
|
3514
|
-
async _start() {
|
|
3515
|
-
await Promise.all([
|
|
3516
|
-
this.users.fetch(),
|
|
3517
|
-
this.matches.fetch(),
|
|
3518
|
-
this.tickets.fetch(),
|
|
3519
|
-
this.vipMembers.fetch(),
|
|
3520
|
-
this.logEntries.fetch(),
|
|
3521
|
-
this.betusers.fetch(),
|
|
3522
|
-
this.bets.fetch(),
|
|
3523
|
-
this.mediators.fetch(),
|
|
3524
|
-
this.tournaments.fetch()
|
|
3525
|
-
]);
|
|
3526
|
-
return this;
|
|
3527
|
-
}
|
|
3528
395
|
async fetch() {
|
|
3529
|
-
const
|
|
396
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3530
397
|
const response = await this.rest.request({
|
|
3531
398
|
method: "get",
|
|
3532
|
-
url
|
|
399
|
+
url
|
|
3533
400
|
});
|
|
3534
|
-
return __privateMethod(this, _Guild_instances,
|
|
401
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3535
402
|
}
|
|
3536
403
|
async reset() {
|
|
3537
404
|
return this.update({ reset: true });
|
|
3538
405
|
}
|
|
3539
406
|
async update(data) {
|
|
3540
|
-
const
|
|
407
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3541
408
|
const response = await this.rest.request({
|
|
3542
409
|
method: "patch",
|
|
3543
|
-
url
|
|
410
|
+
url,
|
|
3544
411
|
payload: data
|
|
3545
412
|
});
|
|
3546
|
-
return __privateMethod(this, _Guild_instances,
|
|
413
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3547
414
|
}
|
|
3548
415
|
async setStatus(key, status) {
|
|
3549
|
-
Assertion.assertString(key);
|
|
416
|
+
import_Assertion.Assertion.assertString(key);
|
|
3550
417
|
this.status[key] = status;
|
|
3551
|
-
const
|
|
418
|
+
const url = import_Routes.Routes.guilds.resource(this.id, "status");
|
|
3552
419
|
const payload = { set: this.status };
|
|
3553
420
|
const response = await this.rest.request({
|
|
3554
421
|
method: "PATCH",
|
|
3555
|
-
url
|
|
422
|
+
url,
|
|
3556
423
|
payload
|
|
3557
424
|
});
|
|
3558
425
|
this.status = response.status;
|
|
@@ -3561,7 +428,7 @@ var Guild = class {
|
|
|
3561
428
|
return this;
|
|
3562
429
|
}
|
|
3563
430
|
async togglePrice(price) {
|
|
3564
|
-
Assertion.assertNumber(price);
|
|
431
|
+
import_Assertion.Assertion.assertNumber(price);
|
|
3565
432
|
const includesPrice = this.prices.includes(price);
|
|
3566
433
|
if (includesPrice) this.prices = this.prices.filter((p) => p !== price);
|
|
3567
434
|
else this.prices.push(price);
|
|
@@ -3569,30 +436,40 @@ var Guild = class {
|
|
|
3569
436
|
return this;
|
|
3570
437
|
}
|
|
3571
438
|
async addPrefix(prefixes) {
|
|
3572
|
-
const
|
|
439
|
+
const url = import_Routes.Routes.fields(import_Routes.Routes.guilds.resource(this.id, "prefixes"));
|
|
3573
440
|
const _p = Array.isArray(prefixes) ? prefixes : [prefixes];
|
|
3574
441
|
const payload = { set: [.../* @__PURE__ */ new Set([...this.prefixes, ..._p])] };
|
|
3575
442
|
const response = await this.rest.request({
|
|
3576
443
|
method: "PATCH",
|
|
3577
|
-
url
|
|
444
|
+
url,
|
|
3578
445
|
payload
|
|
3579
446
|
});
|
|
3580
|
-
__privateMethod(this, _Guild_instances,
|
|
3581
|
-
|
|
447
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
448
|
+
}
|
|
449
|
+
async removePrefix(prefixes) {
|
|
450
|
+
const url = import_Routes.Routes.fields(import_Routes.Routes.guilds.resource(this.id, "prefixes"));
|
|
451
|
+
const _p = Array.isArray(prefixes) ? prefixes : [prefixes];
|
|
452
|
+
const newPrefixes = [.../* @__PURE__ */ new Set([...this.prefixes, ..._p])].filter((p) => !_p.some((o) => o === p));
|
|
453
|
+
const payload = { set: newPrefixes };
|
|
454
|
+
const response = await this.rest.request({
|
|
455
|
+
method: "PATCH",
|
|
456
|
+
url,
|
|
457
|
+
payload
|
|
458
|
+
});
|
|
459
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3582
460
|
}
|
|
3583
|
-
async
|
|
3584
|
-
const
|
|
461
|
+
async setPrefixes(prefixes) {
|
|
462
|
+
const url = import_Routes.Routes.fields(import_Routes.Routes.guilds.resource(this.id, "prefixes"));
|
|
3585
463
|
const payload = { set: Array.isArray(prefixes) ? prefixes : [prefixes] };
|
|
3586
464
|
const response = await this.rest.request({
|
|
3587
465
|
method: "PATCH",
|
|
3588
|
-
url
|
|
466
|
+
url,
|
|
3589
467
|
payload
|
|
3590
468
|
});
|
|
3591
|
-
__privateMethod(this, _Guild_instances,
|
|
3592
|
-
return this;
|
|
469
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3593
470
|
}
|
|
3594
471
|
async toggleDailyCategory(category) {
|
|
3595
|
-
Assertion.assertString(category);
|
|
472
|
+
import_Assertion.Assertion.assertString(category);
|
|
3596
473
|
let categories = this.daily_categories;
|
|
3597
474
|
const returnCategories = () => {
|
|
3598
475
|
const isCategoryOn = categories.includes(category);
|
|
@@ -3602,30 +479,28 @@ var Guild = class {
|
|
|
3602
479
|
};
|
|
3603
480
|
const _categories = returnCategories();
|
|
3604
481
|
const payload = { daily_categories: _categories };
|
|
3605
|
-
const
|
|
482
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3606
483
|
const response = await this.rest.request({
|
|
3607
484
|
method: "patch",
|
|
3608
|
-
url
|
|
485
|
+
url,
|
|
3609
486
|
payload
|
|
3610
487
|
});
|
|
3611
|
-
__privateMethod(this, _Guild_instances,
|
|
3612
|
-
return this;
|
|
488
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3613
489
|
}
|
|
3614
490
|
async setScores(name, amount) {
|
|
3615
|
-
const
|
|
491
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3616
492
|
let scores = this.scores;
|
|
3617
493
|
scores[name] = amount;
|
|
3618
494
|
const payload = { scores };
|
|
3619
495
|
const response = await this.rest.request({
|
|
3620
496
|
method: "patch",
|
|
3621
|
-
url
|
|
497
|
+
url,
|
|
3622
498
|
payload
|
|
3623
499
|
});
|
|
3624
|
-
__privateMethod(this, _Guild_instances,
|
|
3625
|
-
return this;
|
|
500
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3626
501
|
}
|
|
3627
502
|
async toggleMode(mode) {
|
|
3628
|
-
const
|
|
503
|
+
const url = import_Routes.Routes.guilds.get(this.id);
|
|
3629
504
|
let modes = this.modes;
|
|
3630
505
|
const returnModes = () => {
|
|
3631
506
|
const isModeOn = modes.on.includes(mode);
|
|
@@ -3643,17 +518,16 @@ var Guild = class {
|
|
|
3643
518
|
const payload = { modes: md };
|
|
3644
519
|
const response = await this.rest.request({
|
|
3645
520
|
method: "patch",
|
|
3646
|
-
url
|
|
521
|
+
url,
|
|
3647
522
|
payload
|
|
3648
523
|
});
|
|
3649
|
-
__privateMethod(this, _Guild_instances,
|
|
3650
|
-
return this;
|
|
524
|
+
return __privateMethod(this, _Guild_instances, update_fn).call(this, response);
|
|
3651
525
|
}
|
|
3652
|
-
}
|
|
526
|
+
}
|
|
3653
527
|
_Guild_instances = new WeakSet();
|
|
3654
|
-
|
|
528
|
+
update_fn = function(data) {
|
|
3655
529
|
for (let key in data) {
|
|
3656
|
-
if (key === "id" || key === "createdAt") continue;
|
|
530
|
+
if (key === "id" || key === "createdAt" || key === "shops") continue;
|
|
3657
531
|
if (key in this) {
|
|
3658
532
|
this[key] = data[key];
|
|
3659
533
|
}
|
|
@@ -3686,7 +560,6 @@ updateInternals_fn10 = function(data) {
|
|
|
3686
560
|
}
|
|
3687
561
|
}
|
|
3688
562
|
}
|
|
3689
|
-
this.automaticMessagesManager.set(this.automatic_messages);
|
|
3690
563
|
this.updatedAt = /* @__PURE__ */ new Date();
|
|
3691
564
|
this.rest.guilds.cache.set(this.id, this);
|
|
3692
565
|
this.rest.emit("guildUpdate", this);
|
|
@@ -3696,3 +569,4 @@ updateInternals_fn10 = function(data) {
|
|
|
3696
569
|
0 && (module.exports = {
|
|
3697
570
|
Guild
|
|
3698
571
|
});
|
|
572
|
+
//# sourceMappingURL=Guild.js.map
|