@duque.edits/sdk 0.1.4 → 0.1.6

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.
Files changed (119) hide show
  1. package/dist/index.js +4 -27
  2. package/dist/managers/base.js +26 -0
  3. package/dist/managers/buffer/BufferManager.js +8 -2
  4. package/dist/managers/guild/GuildManager.js +42 -25
  5. package/dist/managers/index.js +23 -0
  6. package/dist/managers/match/GuildMatchManager.js +42 -29
  7. package/dist/managers/message/MessagesManager.js +48 -0
  8. package/dist/managers/permission/GuildPermissionManager.js +29 -52
  9. package/dist/managers/ticket/TicketManager.js +77 -0
  10. package/dist/managers/user/GuildUserManager.js +73 -85
  11. package/dist/managers/vipmember/VipMemberManager.js +124 -0
  12. package/dist/rest/REST.js +40 -21
  13. package/dist/rest/Routes.js +31 -17
  14. package/dist/rest/index.js +19 -0
  15. package/dist/structures/Collection.js +1 -1
  16. package/dist/structures/guild/Guild.js +72 -90
  17. package/dist/structures/index.js +22 -0
  18. package/dist/structures/match/GuildMatch.js +64 -111
  19. package/dist/structures/ticket/Ticket.js +119 -0
  20. package/dist/structures/user/GuildUser.js +48 -40
  21. package/dist/structures/vipmember/VipMember.js +137 -0
  22. package/dist/types/api/APIGiveaway.js +2 -0
  23. package/dist/types/api/APILogMessage.js +2 -0
  24. package/dist/types/api/APIVipMember.js +2 -0
  25. package/dist/types/api/index.js +36 -0
  26. package/dist/types/index.js +1 -20
  27. package/dist/utils/getRandomNumber.js +6 -0
  28. package/package.json +11 -18
  29. package/types/index.d.ts +4 -0
  30. package/types/managers/base.d.ts +17 -0
  31. package/types/managers/buffer/BufferManager.d.ts +19 -0
  32. package/{dist → types}/managers/guild/GuildManager.d.ts +12 -4
  33. package/types/managers/index.d.ts +7 -0
  34. package/{dist → types}/managers/match/GuildMatchManager.d.ts +10 -12
  35. package/types/managers/message/MessagesManager.d.ts +17 -0
  36. package/types/managers/permission/GuildPermissionManager.d.ts +8 -0
  37. package/types/managers/ticket/TicketManager.d.ts +22 -0
  38. package/types/managers/user/GuildUserManager.d.ts +19 -0
  39. package/types/managers/vipmember/VipMemberManager.d.ts +33 -0
  40. package/types/rest/APIEndpoints.d.ts +11 -0
  41. package/{dist → types}/rest/REST.d.ts +9 -16
  42. package/{dist → types}/rest/Routes.d.ts +18 -2
  43. package/types/rest/index.d.ts +3 -0
  44. package/{dist → types}/structures/guild/Guild.d.ts +17 -29
  45. package/types/structures/index.d.ts +6 -0
  46. package/{dist → types}/structures/match/GuildMatch.d.ts +12 -22
  47. package/types/structures/ticket/Ticket.d.ts +30 -0
  48. package/{dist → types}/structures/user/GuildUser.d.ts +5 -3
  49. package/types/structures/vipmember/VipMember.d.ts +54 -0
  50. package/types/types/RestTypes.d.ts +34 -0
  51. package/types/types/api/APIGiveaway.d.ts +27 -0
  52. package/{dist → types}/types/api/APIGuild.d.ts +9 -2
  53. package/{dist → types}/types/api/APIGuildMatch.d.ts +9 -7
  54. package/types/types/api/APIGuildTicket.d.ts +16 -0
  55. package/{dist → types}/types/api/APIGuildUser.d.ts +3 -1
  56. package/types/types/api/APILogMessage.d.ts +7 -0
  57. package/types/types/api/APIMessage.d.ts +11 -0
  58. package/{dist → types}/types/api/APIPlayer.d.ts +1 -1
  59. package/types/types/api/APIVipMember.d.ts +20 -0
  60. package/{dist → types}/types/api/index.d.ts +23 -1
  61. package/types/types/index.d.ts +2 -0
  62. package/types/utils/getRandomNumber.d.ts +1 -0
  63. package/dist/index.d.ts +0 -27
  64. package/dist/managers/bet/GuildBetManager.d.ts +0 -35
  65. package/dist/managers/bet/GuildBetManager.js +0 -126
  66. package/dist/managers/betuser/GuildBetUserManager.d.ts +0 -36
  67. package/dist/managers/betuser/GuildBetUserManager.js +0 -151
  68. package/dist/managers/buffer/BufferManager.d.ts +0 -14
  69. package/dist/managers/channel/ChannelManager.d.ts +0 -39
  70. package/dist/managers/channel/ChannelManager.js +0 -148
  71. package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +0 -34
  72. package/dist/managers/groupedchannel/GroupedChannelManager.js +0 -92
  73. package/dist/managers/mediator/GuildMediatorManager.d.ts +0 -32
  74. package/dist/managers/mediator/GuildMediatorManager.js +0 -98
  75. package/dist/managers/messages/MessagesManager.d.ts +0 -32
  76. package/dist/managers/messages/MessagesManager.js +0 -89
  77. package/dist/managers/permission/GuildPermissionManager.d.ts +0 -26
  78. package/dist/managers/product/GuildProductManager.d.ts +0 -32
  79. package/dist/managers/product/GuildProductManager.js +0 -103
  80. package/dist/managers/ticket/GuildTicketManager.d.ts +0 -32
  81. package/dist/managers/ticket/GuildTicketManager.js +0 -100
  82. package/dist/managers/user/GuildUserManager.d.ts +0 -33
  83. package/dist/rest/APIEndpoints.d.ts +0 -11
  84. package/dist/structures/bet/GuildBet.d.ts +0 -87
  85. package/dist/structures/bet/GuildBet.js +0 -284
  86. package/dist/structures/betuser/GuildBetUser.d.ts +0 -85
  87. package/dist/structures/betuser/GuildBetUser.js +0 -211
  88. package/dist/structures/channel/Channel.d.ts +0 -31
  89. package/dist/structures/channel/Channel.js +0 -57
  90. package/dist/structures/groupedchannel/GroupedChannel.d.ts +0 -34
  91. package/dist/structures/groupedchannel/GroupedChannel.js +0 -121
  92. package/dist/structures/mediator/GuildMediator.d.ts +0 -41
  93. package/dist/structures/mediator/GuildMediator.js +0 -131
  94. package/dist/structures/product/GuildProduct.d.ts +0 -52
  95. package/dist/structures/product/GuildProduct.js +0 -175
  96. package/dist/structures/shop/GuildShop.d.ts +0 -34
  97. package/dist/structures/shop/GuildShop.js +0 -80
  98. package/dist/structures/ticket/GuildTicket.d.ts +0 -52
  99. package/dist/structures/ticket/GuildTicket.js +0 -172
  100. package/dist/types/api/APIGuildTicket.d.ts +0 -26
  101. package/dist/types/api/APIMessage.d.ts +0 -12
  102. package/dist/types/index.d.ts +0 -21
  103. /package/dist/types/{api/APIGuildMessage.js → RestTypes.js} +0 -0
  104. /package/{dist → types}/structures/Collection.d.ts +0 -0
  105. /package/{dist → types}/types/api/APIBaseChannel.d.ts +0 -0
  106. /package/{dist → types}/types/api/APIBetChannel.d.ts +0 -0
  107. /package/{dist → types}/types/api/APIBetMessage.d.ts +0 -0
  108. /package/{dist → types}/types/api/APIGuildBet.d.ts +0 -0
  109. /package/{dist → types}/types/api/APIGuildBetUser.d.ts +0 -0
  110. /package/{dist → types}/types/api/APIGuildChannel.d.ts +0 -0
  111. /package/{dist → types}/types/api/APIGuildEmoji.d.ts +0 -0
  112. /package/{dist → types}/types/api/APIGuildGroupedChannel.d.ts +0 -0
  113. /package/{dist → types}/types/api/APIGuildMediator.d.ts +0 -0
  114. /package/{dist → types}/types/api/APIGuildMessage.d.ts +0 -0
  115. /package/{dist → types}/types/api/APIGuildPermissions.d.ts +0 -0
  116. /package/{dist → types}/types/api/APIGuildRole.d.ts +0 -0
  117. /package/{dist → types}/types/api/APIGuildShop.d.ts +0 -0
  118. /package/{dist → types}/types/api/APIProduct.d.ts +0 -0
  119. /package/{dist → types}/utils/Assertion.d.ts +0 -0
@@ -22,9 +22,15 @@ export interface GuildStatus {
22
22
  /** Bets status */
23
23
  bets: "on" | "off";
24
24
  /** Daily Ranking status */
25
- dailyRank: "on" | "off";
25
+ daily_rank: "on" | "off";
26
26
  /** Voice Channels for a bet */
27
27
  createVoiceChannels: "on" | "off";
28
+ two_mvps: "on" | "off";
29
+ ranking_name: "on" | "off";
30
+ }
31
+ export interface GuildModes {
32
+ on: string[];
33
+ off: string[];
28
34
  }
29
35
  export type DailyCategories = "coins" | "credit" | "wins" | "points" | "losses" | "mvps";
30
36
  export interface GuildPrices {
@@ -46,6 +52,7 @@ export interface GuildScores {
46
52
  export interface APIGuild {
47
53
  /** Guild's id */
48
54
  id: string;
55
+ modes: GuildModes;
49
56
  /** Guild's client key */
50
57
  clientKey: string;
51
58
  /** Guild Permissions */
@@ -53,7 +60,7 @@ export interface APIGuild {
53
60
  /** Guild Ticket */
54
61
  tickets: APIGuildTicket[];
55
62
  /** Guild Ticket Configuration */
56
- ticketsConfiguration: GuildTicketConfiguration;
63
+ tickets_configuration: GuildTicketConfiguration;
57
64
  /** Guild Daily Categories */
58
65
  dailyCategories: DailyCategories[];
59
66
  /** Guild Scores */
@@ -2,9 +2,16 @@ import { BaseMatchModes, BaseMatchStatus, Confirm } from ".";
2
2
  import { APIBaseChannel } from "./APIBaseChannel";
3
3
  import { APIMessage } from "./APIMessage";
4
4
  import { APIPlayer } from "./APIPlayer";
5
+ export type MatchSelection = {
6
+ type: "creator" | "mvps" | "winners";
7
+ selected: string[];
8
+ confirmed: string[];
9
+ };
5
10
  export interface APIGuildMatch {
11
+ selections: MatchSelection[];
6
12
  /** Match's type */
7
13
  type: BaseMatchModes;
14
+ guild_id: string;
8
15
  /** Match's status */
9
16
  status: BaseMatchStatus;
10
17
  /** Match's challenge */
@@ -23,17 +30,11 @@ export interface APIGuildMatch {
23
30
  maximumSize: number;
24
31
  /** Match's kicked out */
25
32
  kickedOut: APIPlayer[];
26
- /** Match's team a */
27
- teamA: APIPlayer[];
28
- /** Match's team b */
29
- teamB: APIPlayer[];
30
33
  /** Match's confirmed */
31
34
  confirmed: Confirm[];
32
35
  /** Match's leaders */
33
36
  leaders: APIPlayer[];
34
- /** Match's mvp */
35
- mvpId: string;
36
- /** Match's creator id */
37
+ teams: APIPlayer[][];
37
38
  creatorId: string;
38
39
  /** Match's room creator id */
39
40
  roomCreatorId: string;
@@ -43,4 +44,5 @@ export interface APIGuildMatch {
43
44
  updatedAt: Date;
44
45
  /** Match's id */
45
46
  _id: string;
47
+ mvps: [];
46
48
  }
@@ -0,0 +1,16 @@
1
+ import { APILogMessage } from "./APILogMessage";
2
+ export interface APIGuildTicket {
3
+ /** Ticket's id */
4
+ _id: string;
5
+ guild_id: string;
6
+ type: string;
7
+ status: "on" | "off";
8
+ creator_id: string;
9
+ channel_id: string;
10
+ admin_id: string;
11
+ customer_rating: number;
12
+ closed_by_id: string;
13
+ messages: APILogMessage[];
14
+ createdAt: Date;
15
+ updatedAt: Date;
16
+ }
@@ -2,12 +2,14 @@ import { Accessory, Daily, Items, OriginalChannels } from ".";
2
2
  export interface APIGuildUser {
3
3
  /** User's id */
4
4
  id: string;
5
+ guild_id: string;
5
6
  /** User name */
6
7
  name: string;
7
8
  /** User's daily */
8
9
  daily: Omit<Daily, "credit">;
9
10
  /** User's points */
10
11
  points: number;
12
+ creations: number;
11
13
  /** User's wins */
12
14
  wins: number;
13
15
  /** User's mvps */
@@ -21,7 +23,7 @@ export interface APIGuildUser {
21
23
  /** User's accessories such as double point */
22
24
  accessories: Accessory[];
23
25
  /** User's original channels */
24
- originalChannels: OriginalChannels;
26
+ original_channels: OriginalChannels;
25
27
  /** User's items */
26
28
  items: Items;
27
29
  /** Creation Date */
@@ -0,0 +1,7 @@
1
+ export interface APILogMessage {
2
+ type: string;
3
+ content: any;
4
+ user_id: string;
5
+ createdAt: Date;
6
+ updatedAt: Date;
7
+ }
@@ -0,0 +1,11 @@
1
+ export interface APIMessage {
2
+ /** Message's content */
3
+ content?: string | object;
4
+ _id: string;
5
+ /** Message's type */
6
+ type: string;
7
+ /** Creation Date */
8
+ createdAt?: Date;
9
+ /** Updated Date */
10
+ updatedAt?: Date;
11
+ }
@@ -2,7 +2,7 @@ export interface APIPlayer {
2
2
  /** The player's id */
3
3
  id: string;
4
4
  /** The player's name */
5
- name: string;
5
+ name?: string;
6
6
  /** When player was created */
7
7
  createdAt?: Date;
8
8
  /** Last time player was updated */
@@ -0,0 +1,20 @@
1
+ export interface APIVipMember {
2
+ /** Members's name */
3
+ name: string;
4
+ /** Members's id */
5
+ id: string;
6
+ /** Members's roleId */
7
+ roleId: string;
8
+ duration: Date;
9
+ status: "on" | "off";
10
+ /** Members's voiceChannelId */
11
+ voiceChannelId: string;
12
+ /** Vip's type */
13
+ type: "both" | "role" | "channel";
14
+ /** Member's Guild Id */
15
+ guild_id: string;
16
+ /** User's daily */
17
+ createdAt: Date;
18
+ /** Updated Date */
19
+ updatedAt: Date;
20
+ }
@@ -32,7 +32,7 @@ export interface LogMessage {
32
32
  updatedAt: Date;
33
33
  }
34
34
  /** Base match modes */
35
- export type BaseMatchModes = "1x1" | "2x2" | "3x3" | "4x4" | "5x5" | "6x6" | "1v1" | "2v2" | "3v3" | "4v4" | "5v5" | "6v6";
35
+ export type BaseMatchModes = "1v1" | "2v2" | "3v3" | "4v4" | "5v5" | "6v6";
36
36
  /** Base match status */
37
37
  export type BaseMatchStatus = "on" | "created" | "off" | "shutted";
38
38
  /** The logs of the structure */
@@ -132,3 +132,25 @@ export declare enum STATES {
132
132
  SHUTTED = "shutted",
133
133
  WAITING = "waiting"
134
134
  }
135
+ export * from "./APIBaseChannel";
136
+ export * from "./APIBetChannel";
137
+ export * from "./APIBetMessage";
138
+ export * from "./APIGuild";
139
+ export * from "./APIGuildBet";
140
+ export * from "./APIGuildBetUser";
141
+ export * from "./APIGuildChannel";
142
+ export * from "./APIGuildEmoji";
143
+ export * from "./APIGuildGroupedChannel";
144
+ export * from "./APIGuildMatch";
145
+ export * from "./APIGuildMediator";
146
+ export * from "./APIGuildPermissions";
147
+ export * from "./APIGuildRole";
148
+ export * from "./APIGuildShop";
149
+ export * from "./APIGuildTicket";
150
+ export * from "./APIGuildUser";
151
+ export * from "./APIMessage";
152
+ export * from "./APIPlayer";
153
+ export * from "./APIProduct";
154
+ export * from "./APIVipMember";
155
+ export * from "./APIGiveaway";
156
+ export * from "./APILogMessage";
@@ -0,0 +1,2 @@
1
+ export * from "./api/index";
2
+ export * from "./RestTypes";
@@ -0,0 +1 @@
1
+ export declare function getRandomNumber(min: number, max: number): number;
package/dist/index.d.ts DELETED
@@ -1,27 +0,0 @@
1
- export * from "./managers/bet/GuildBetManager";
2
- export * from "./managers/betuser/GuildBetUserManager";
3
- export * from "./managers/channel/ChannelManager";
4
- export * from "./managers/groupedchannel/GroupedChannelManager";
5
- export * from "./managers/guild/GuildManager";
6
- export * from "./managers/match/GuildMatchManager";
7
- export * from "./managers/mediator/GuildMediatorManager";
8
- export * from "./managers/messages/MessagesManager";
9
- export * from "./managers/permission/GuildPermissionManager";
10
- export * from "./managers/product/GuildProductManager";
11
- export * from "./managers/ticket/GuildTicketManager";
12
- export * from "./managers/user/GuildUserManager";
13
- export * from "./structures/bet/GuildBet";
14
- export * from "./structures/betuser/GuildBetUser";
15
- export * from "./structures/channel/Channel";
16
- export * from "./structures/groupedchannel/GroupedChannel";
17
- export * from "./structures/guild/Guild";
18
- export * from "./structures/match/GuildMatch";
19
- export * from "./structures/mediator/GuildMediator";
20
- export * from "./structures/product/GuildProduct";
21
- export * from "./structures/shop/GuildShop";
22
- export * from "./structures/ticket/GuildTicket";
23
- export * from "./structures/user/GuildUser";
24
- export * from "./structures/Collection";
25
- export * from "./rest/REST";
26
- export * from "./rest/Routes";
27
- export * from "./types/index";
@@ -1,35 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { GuildBet } from "../../structures/bet/GuildBet";
3
- import { Collection } from "../../structures/Collection";
4
- import { Guild } from "../../structures/guild/Guild";
5
- import { Optional } from "../../types/api";
6
- import { APIGuildBet } from "../../types/api/APIGuildBet";
7
- type OptionalGuildBet = Optional<APIGuildBet>;
8
- export declare class GuildBetManager {
9
- /** A cache of users */
10
- cache: Collection<string, GuildBet>;
11
- /** The rest client */
12
- rest: REST;
13
- /** GuildBet bet guild */
14
- guild: Guild;
15
- /**
16
- * Manage users with the given client
17
- * @param users An array of users
18
- * @param rest The rest client
19
- */
20
- constructor(guild: Guild, rest: REST);
21
- create(payload: Optional<APIGuildBet>): Promise<GuildBet>;
22
- createMany(bets: OptionalGuildBet[]): Promise<Collection<string, GuildBet>>;
23
- /**
24
- * Fetch a bet
25
- * @param id Id of the bet to fetch
26
- * @returns APIBetUser
27
- */
28
- fetch(id: string): Promise<GuildBet>;
29
- fetchAll(): Promise<Collection<string, GuildBet>>;
30
- set(data: APIGuildBet): GuildBet;
31
- setAll(data: APIGuildBet[]): Collection<string, GuildBet>;
32
- delete(id: string): Promise<Collection<string, GuildBet>>;
33
- deleteAll(): Promise<boolean>;
34
- }
35
- export {};
@@ -1,126 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildBetManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const GuildBet_1 = require("../../structures/bet/GuildBet");
6
- const Collection_1 = require("../../structures/Collection");
7
- const Assertion_1 = require("../../utils/Assertion");
8
- class GuildBetManager {
9
- /** A cache of users */
10
- cache;
11
- /** The rest client */
12
- rest;
13
- /** GuildBet bet guild */
14
- guild;
15
- /**
16
- * Manage users with the given client
17
- * @param users An array of users
18
- * @param rest The rest client
19
- */
20
- constructor(guild, rest) {
21
- this.guild = guild;
22
- this.rest = rest;
23
- this.cache = new Collection_1.Collection("bets");
24
- }
25
- async create(payload) {
26
- Assertion_1.Assertion.assertObject(payload);
27
- const route = Routes_1.Routes.guilds.bets.create(this.guild.id);
28
- const response = await this.rest.request({
29
- method: "POST",
30
- url: route,
31
- payload,
32
- });
33
- const bet = this.set(response);
34
- return bet;
35
- }
36
- async createMany(bets) {
37
- Assertion_1.Assertion.assertArray(bets);
38
- const route = Routes_1.Routes.guilds.bets.resource(this.guild.id, "bulk");
39
- const payload = { bets };
40
- const response = await this.rest.request({
41
- method: "POST",
42
- url: route,
43
- payload,
44
- });
45
- this.rest.emit("betBulkCreate", response);
46
- this.setAll(response);
47
- const coll = new Collection_1.Collection();
48
- for (let bt of response) {
49
- const bet = new GuildBet_1.GuildBet(bt, this.guild, this, this.rest);
50
- coll.set(bt._id, bet);
51
- }
52
- return coll;
53
- }
54
- /**
55
- * Fetch a bet
56
- * @param id Id of the bet to fetch
57
- * @returns APIBetUser
58
- */
59
- async fetch(id) {
60
- const route = Routes_1.Routes.guilds.bets.get(this.guild.id, id);
61
- const response = await this.rest.request({
62
- method: "get",
63
- url: route,
64
- });
65
- const bet = new GuildBet_1.GuildBet(response, this.guild, this, this.rest);
66
- this.cache.set(bet._id, bet);
67
- this.rest.bets.set(bet._id, bet);
68
- return bet;
69
- }
70
- async fetchAll() {
71
- const route = Routes_1.Routes.guilds.bets.getAll(this.guild.id);
72
- const response = await this.rest.request({
73
- method: "get",
74
- url: route,
75
- });
76
- if (Array.isArray(response) && response.length === 0) {
77
- this.cache.clear();
78
- return this.cache;
79
- }
80
- for (let betData of response) {
81
- const bet = new GuildBet_1.GuildBet(betData, this.guild, this, this.rest);
82
- this.cache.set(bet._id, bet);
83
- }
84
- return this.cache;
85
- }
86
- set(data) {
87
- if (!data?._id)
88
- return;
89
- if (!this.guild)
90
- return;
91
- const bet = new GuildBet_1.GuildBet(data, this.guild, this, this.rest);
92
- this.cache.set(bet._id, bet);
93
- this.rest.bets.set(bet._id, bet);
94
- return bet;
95
- }
96
- setAll(data) {
97
- if (!data)
98
- return this.cache;
99
- for (let bet of data)
100
- this.set(bet);
101
- return this.cache;
102
- }
103
- async delete(id) {
104
- Assertion_1.Assertion.assertString(id);
105
- const route = Routes_1.Routes.guilds.bets.delete(id, this.guild.id);
106
- const bet = this.cache.get(id);
107
- this.rest.emit("betDelete", bet);
108
- await this.rest.request({
109
- method: "DELETE",
110
- url: route,
111
- });
112
- this.cache.delete(id);
113
- return this.cache;
114
- }
115
- async deleteAll() {
116
- const route = Routes_1.Routes.guilds.bets.deleteAll(this.guild.id);
117
- this.rest.emit("betsDelete", this.cache);
118
- const value = await this.rest.request({
119
- method: "DELETE",
120
- url: route,
121
- });
122
- this.cache.clear();
123
- return value;
124
- }
125
- }
126
- exports.GuildBetManager = GuildBetManager;
@@ -1,36 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { GuildBetUser } from "../../structures/betuser/GuildBetUser";
3
- import { Collection } from "../../structures/Collection";
4
- import { Guild } from "../../structures/guild/Guild";
5
- import { APIPlayer, Optional } from "../../types";
6
- import { APIGuildBetUser } from "../../types/api/APIGuildBetUser";
7
- export declare class GuildBetUserManager {
8
- /** A cache of users */
9
- cache: Collection<string, GuildBetUser>;
10
- /** The rest client */
11
- rest: REST;
12
- /** Bet user guild */
13
- guild: Guild;
14
- /**
15
- * Manage users with the given client
16
- * @param users An array of users
17
- * @param rest The rest client
18
- */
19
- constructor(guild: Guild, rest: REST);
20
- updateMany(data: Optional<APIPlayer>[]): Promise<Collection<string, GuildBetUser>>;
21
- update(id: string, data: Optional<APIGuildBetUser> & {
22
- type: "add" | "remove";
23
- }): Promise<GuildBetUser>;
24
- set(data: APIGuildBetUser): Collection<string, GuildBetUser>;
25
- setAll(data: APIGuildBetUser[]): Collection<string, GuildBetUser>;
26
- resetAll(): Promise<Collection<string, GuildBetUser>>;
27
- /**
28
- * Fetch a user
29
- * @param id Id of the user to fetch
30
- * @returns GuildBetUser
31
- */
32
- fetch(id: string, name: string): Promise<GuildBetUser>;
33
- fetchAll(): Promise<Collection<string, GuildBetUser>>;
34
- delete(id: string): Promise<Collection<string, GuildBetUser>>;
35
- deleteAll(): Promise<boolean>;
36
- }
@@ -1,151 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildBetUserManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const GuildBetUser_1 = require("../../structures/betuser/GuildBetUser");
6
- const Collection_1 = require("../../structures/Collection");
7
- const Assertion_1 = require("../../utils/Assertion");
8
- class GuildBetUserManager {
9
- /** A cache of users */
10
- cache;
11
- /** The rest client */
12
- rest;
13
- /** Bet user guild */
14
- guild;
15
- /**
16
- * Manage users with the given client
17
- * @param users An array of users
18
- * @param rest The rest client
19
- */
20
- constructor(guild, rest) {
21
- this.guild = guild;
22
- this.rest = rest;
23
- this.cache = new Collection_1.Collection("betUsers");
24
- }
25
- async updateMany(data) {
26
- const route = Routes_1.Routes.guilds.resources(this.guild.id, "betUsers", "bulk");
27
- const payload = { betUsers: data };
28
- const response = await this.rest.request({
29
- method: "PATCH",
30
- url: route,
31
- payload,
32
- });
33
- this.setAll(response);
34
- return this.cache;
35
- }
36
- async update(id, data) {
37
- const route = Routes_1.Routes.guilds.betUsers.update(this.guild.id, id);
38
- const payload = {};
39
- const numericFields = ["coins", "wins", "credit", "losses", "mvps", "games"];
40
- const arrayFields = ["items", "betsPlayed"];
41
- if (data.type === "add" || data.type === "remove") {
42
- for (const key in data) {
43
- if (key === "type")
44
- continue;
45
- const value = data[key];
46
- if (numericFields.includes(key)) {
47
- const current = this[key];
48
- const num = value;
49
- payload[key] = Math.max(0, data.type === "add" ? current + num : num - current);
50
- }
51
- else if (key === "blacklist") {
52
- payload["blacklist"] = value;
53
- }
54
- else if (arrayFields.includes(key)) {
55
- const current = this[key];
56
- const incoming = value;
57
- payload[key] =
58
- data.type === "add"
59
- ? [...new Set([...current, ...incoming])]
60
- : current.filter((x) => !incoming.includes(x));
61
- }
62
- }
63
- }
64
- const response = await this.rest.request({
65
- method: "patch",
66
- url: route,
67
- payload,
68
- });
69
- const user = new GuildBetUser_1.GuildBetUser(response, this, this.rest);
70
- this.cache.set(user.id, user);
71
- return user;
72
- }
73
- set(data) {
74
- if (!data?.id)
75
- return;
76
- const user = new GuildBetUser_1.GuildBetUser(data, this, this.rest);
77
- this.rest.betUsers.set(user.id, user);
78
- return this.cache.set(user.id, user);
79
- }
80
- setAll(data) {
81
- if (!data)
82
- return this.cache;
83
- for (let user of data)
84
- this.set(user);
85
- return this.cache;
86
- }
87
- async resetAll() {
88
- const route = Routes_1.Routes.guilds.betUsers.getAll(this.guild.id);
89
- const response = await this.rest.request({
90
- method: "PUT",
91
- url: route,
92
- });
93
- this.setAll(response);
94
- return this.cache;
95
- }
96
- /**
97
- * Fetch a user
98
- * @param id Id of the user to fetch
99
- * @returns GuildBetUser
100
- */
101
- async fetch(id, name) {
102
- const route = Routes_1.Routes.guilds.betUsers.get(this.guild.id, id);
103
- const response = await this.rest.request({
104
- method: "get",
105
- url: route,
106
- payload: { name },
107
- });
108
- if (!response)
109
- return this.cache.get(id);
110
- const user = new GuildBetUser_1.GuildBetUser(response, this, this.rest);
111
- this.cache.set(user?.id, user);
112
- this.rest.betUsers.set(user?.id, user);
113
- return user;
114
- }
115
- async fetchAll() {
116
- const route = Routes_1.Routes.guilds.betUsers.getAll(this.guild.id);
117
- const response = await this.rest.request({
118
- method: "get",
119
- url: route,
120
- });
121
- if (Array.isArray(response) && response.length === 0) {
122
- this.cache.clear();
123
- return this.cache;
124
- }
125
- this.setAll(response);
126
- return this.cache;
127
- }
128
- async delete(id) {
129
- Assertion_1.Assertion.assertString(id);
130
- const route = Routes_1.Routes.guilds.betUsers.delete(id, this.guild.id);
131
- const betUser = this.cache.get(id);
132
- this.rest.emit("betDelete", betUser);
133
- await this.rest.request({
134
- method: "DELETE",
135
- url: route,
136
- });
137
- this.cache.delete(id);
138
- return this.cache;
139
- }
140
- async deleteAll() {
141
- const route = Routes_1.Routes.guilds.betUsers.deleteAll(this.guild.id);
142
- this.rest.emit("betsDelete", this.cache);
143
- const value = await this.rest.request({
144
- method: "DELETE",
145
- url: route,
146
- });
147
- this.cache.clear();
148
- return value;
149
- }
150
- }
151
- exports.GuildBetUserManager = GuildBetUserManager;
@@ -1,14 +0,0 @@
1
- import { Collection } from "../../structures/Collection";
2
- import { Guild } from "../../structures/guild/Guild";
3
- import { APIGuildMatch, APIGuildTicket, Optional } from "../../types";
4
- export declare class BufferManager {
5
- matches: Collection<string, Optional<APIGuildMatch & {
6
- id: string;
7
- }>>;
8
- tickets: Collection<string, Optional<APIGuildTicket & {
9
- id: string;
10
- }>>;
11
- guild: Guild;
12
- constructor(guild: Guild);
13
- flush(key: "matches" | "tickets"): Promise<APIGuildMatch[] & APIGuildTicket[]>;
14
- }
@@ -1,39 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { GuildBet } from "../../structures/bet/GuildBet";
3
- import { Channel } from "../../structures/channel/Channel";
4
- import { Collection } from "../../structures/Collection";
5
- import { Guild } from "../../structures/guild/Guild";
6
- import { GuildMatch } from "../../structures/match/GuildMatch";
7
- import { Optional } from "../../types/api";
8
- import { APIBaseChannel } from "../../types/api/APIBaseChannel";
9
- type Channels = Optional<APIBaseChannel>;
10
- export declare class ChannelManager<Structure extends GuildBet | GuildMatch> {
11
- /** A cache of bet channels */
12
- cache: Collection<string, Channel<Structure>>;
13
- /** The rest client */
14
- rest: REST;
15
- /** GuildBet user guild */
16
- guild: Guild;
17
- /** The bet */
18
- structure: Structure;
19
- /** Base Url */
20
- baseUrl: string;
21
- /**
22
- * Manage channels of a bet
23
- * @param guild The guild at hand
24
- * @param bet The bet at hand
25
- * @param rest The rest client
26
- */
27
- constructor(guild: Guild, structure: Structure, rest: REST);
28
- create(data: Optional<APIBaseChannel>): Promise<Channel<Structure>>;
29
- createMany(...channels: Channels[]): Promise<Collection<string, Channel<Structure>>>;
30
- deleteMany(...channels: Optional<APIBaseChannel>[]): Promise<Collection<string, Channel<Structure>>>;
31
- setAll(data: APIBaseChannel[]): Collection<string, Channel<Structure>>;
32
- set(data: APIBaseChannel): Channel<Structure>;
33
- update(type: string, payload: Optional<APIBaseChannel>): Promise<Channel<Structure>>;
34
- fetch(type: string): Promise<Channel<Structure>>;
35
- fetchAll(): Promise<Collection<string, Channel<Structure>>>;
36
- delete(type: string): Promise<Collection<string, Channel<Structure>>>;
37
- deleteAll(): Promise<boolean>;
38
- }
39
- export {};