@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
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuildTicket = void 0;
4
+ const rest_1 = require("../../rest");
5
+ class GuildTicket {
6
+ _id;
7
+ guild_id;
8
+ type;
9
+ status;
10
+ admin_id;
11
+ channel_id;
12
+ closed_by_id;
13
+ creator_id;
14
+ customer_rating;
15
+ messages;
16
+ createdAt;
17
+ updatedAt;
18
+ rest;
19
+ guild;
20
+ manager;
21
+ constructor(data, manager) {
22
+ this.manager = manager;
23
+ this.guild = manager.guild;
24
+ this.rest = manager.rest;
25
+ this._id = data?._id;
26
+ this.type = data?.type;
27
+ this.admin_id = data?.admin_id;
28
+ this.guild_id = data?.guild_id;
29
+ this.channel_id = data?.channel_id;
30
+ this.creator_id = data?.creator_id;
31
+ this.status = data?.status;
32
+ this.customer_rating = data?.customer_rating;
33
+ this.messages = data?.messages;
34
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
35
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
36
+ }
37
+ async fetch() {
38
+ const route = rest_1.Routes.guilds.tickets.get(this.guild.id, this._id);
39
+ const response = await this.rest.request({
40
+ method: "GET",
41
+ url: route,
42
+ });
43
+ return this._updateInternals(response);
44
+ }
45
+ async setCustomerRating(rating) {
46
+ const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "customer_rating");
47
+ const payload = { set: rating };
48
+ const response = await this.rest.request({
49
+ method: "PATCH",
50
+ url: route,
51
+ payload,
52
+ });
53
+ return this._updateInternals(response);
54
+ }
55
+ async setAdminId(id) {
56
+ const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "admin_id");
57
+ const payload = { set: id };
58
+ const response = await this.rest.request({
59
+ method: "PATCH",
60
+ url: route,
61
+ payload,
62
+ });
63
+ return this._updateInternals(response);
64
+ }
65
+ async setChannelId(id) {
66
+ const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "channel_id");
67
+ const payload = { set: id };
68
+ const response = await this.rest.request({
69
+ method: "PATCH",
70
+ url: route,
71
+ payload,
72
+ });
73
+ return this._updateInternals(response);
74
+ }
75
+ async setClosedById(id) {
76
+ const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "closed_by_id");
77
+ const payload = { set: id };
78
+ const response = await this.rest.request({
79
+ method: "PATCH",
80
+ url: route,
81
+ payload,
82
+ });
83
+ return this._updateInternals(response);
84
+ }
85
+ async setStatus(status) {
86
+ const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "status");
87
+ const payload = { set: status };
88
+ const response = await this.rest.request({
89
+ method: "PATCH",
90
+ url: route,
91
+ payload,
92
+ });
93
+ return this._updateInternals(response);
94
+ }
95
+ async addMessage(message) {
96
+ const route = rest_1.Routes.guilds.tickets.resource(this.guild.id, this._id, "messages");
97
+ const payload = { set: [...this.messages, message] };
98
+ const response = await this.rest.request({
99
+ method: "PATCH",
100
+ url: route,
101
+ payload,
102
+ });
103
+ return this._updateInternals(response);
104
+ }
105
+ _updateInternals(data) {
106
+ for (let key in data) {
107
+ if (key === "id" || key === "createdAt")
108
+ continue;
109
+ if (key in this) {
110
+ this[key] = data[key];
111
+ }
112
+ }
113
+ this.updatedAt = new Date();
114
+ this.createdAt = new Date(data.createdAt);
115
+ this.manager.set(this);
116
+ return this;
117
+ }
118
+ }
119
+ exports.GuildTicket = GuildTicket;
@@ -5,6 +5,7 @@ const Routes_1 = require("../../rest/Routes");
5
5
  class GuildUser {
6
6
  /** User's id */
7
7
  id;
8
+ guild_id;
8
9
  /** User name */
9
10
  name;
10
11
  /** User's daily */
@@ -24,7 +25,8 @@ class GuildUser {
24
25
  /** User's accessories such as double point */
25
26
  accessories;
26
27
  /** User's original channels */
27
- originalChannels;
28
+ original_channels;
29
+ creations;
28
30
  /** User's items */
29
31
  items;
30
32
  /** Creation Date */
@@ -41,26 +43,27 @@ class GuildUser {
41
43
  * @param manager The manager
42
44
  * @param rest The rest client
43
45
  */
44
- constructor(data, manager, rest) {
45
- this.name = data.name;
46
- this.id = data.id;
47
- this.wins = data.wins;
48
- this.mvps = data.mvps;
49
- this.losses = data.losses;
50
- this.blacklist = data.blacklist;
51
- this.items = data.items;
52
- this.points = data.points;
53
- this.mvps = data.mvps;
54
- this.losses = data.losses;
55
- this.originalChannels = data.originalChannels;
56
- this.games = data.games;
57
- this.accessories = data.accessories;
58
- this.items = data.items;
46
+ constructor(data, manager) {
47
+ this.id = data?.id;
48
+ this.guild_id = data?.guild_id;
49
+ this.manager = manager;
50
+ this.rest = manager.rest;
51
+ this.name = data?.name;
52
+ this.wins = data?.wins;
53
+ this.creations = data?.creations;
54
+ this.losses = data?.losses;
55
+ this.blacklist = data?.blacklist;
56
+ this.items = data?.items;
57
+ this.points = data?.points;
58
+ this.mvps = data?.mvps;
59
+ this.games = data?.games;
60
+ this.losses = data?.losses;
61
+ this.original_channels = data?.original_channels;
62
+ this.accessories = data?.accessories;
63
+ this.items = data?.items;
59
64
  this.daily = data?.daily;
60
65
  this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
61
66
  this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
62
- this.manager = manager;
63
- this.rest = rest;
64
67
  }
65
68
  /** String representation of this user */
66
69
  toString() {
@@ -76,7 +79,7 @@ class GuildUser {
76
79
  method: "get",
77
80
  url: route,
78
81
  });
79
- const user = new GuildUser(response, this.manager, this.rest);
82
+ const user = new GuildUser(response, this.manager);
80
83
  this.manager.cache.set(user.id, user);
81
84
  this.rest.users.set(user.id, user);
82
85
  return user;
@@ -89,7 +92,7 @@ class GuildUser {
89
92
  */
90
93
  async add(key, value) {
91
94
  const route = Routes_1.Routes.guilds.users.resource(this.manager.guild.id, this.id, key);
92
- const payload = { [key]: value, name: this.name };
95
+ const payload = { set: value };
93
96
  const resp = await this.rest.request({
94
97
  method: "patch",
95
98
  url: route,
@@ -107,7 +110,7 @@ class GuildUser {
107
110
  */
108
111
  async setBlacklist(value) {
109
112
  const route = Routes_1.Routes.guilds.users.resource(this.manager.guild.id, this.id, "blacklist");
110
- const payload = { value, name: this.name };
113
+ const payload = { set: value };
111
114
  await this.rest.request({
112
115
  method: "patch",
113
116
  url: route,
@@ -126,18 +129,21 @@ class GuildUser {
126
129
  url: route,
127
130
  payload,
128
131
  });
129
- this.#updateData(response);
132
+ this._updateInternals(response);
130
133
  return this;
131
134
  }
132
- #updateData(data) {
133
- for (const k in data) {
134
- if (k === "id")
135
+ _updateInternals(data) {
136
+ for (let key in data) {
137
+ if (key === "id" || key === "createdAt")
135
138
  continue;
136
- if (Object.hasOwn(this, k)) {
137
- this[k] = data[k];
138
- this.data[k] = data[k];
139
+ if (key in this) {
140
+ this[key] = data[key];
139
141
  }
140
142
  }
143
+ this.updatedAt = new Date();
144
+ this.createdAt = new Date(data.createdAt);
145
+ this.manager.set(this);
146
+ return this;
141
147
  }
142
148
  /**
143
149
  * Update certain property
@@ -145,13 +151,13 @@ class GuildUser {
145
151
  * @returns
146
152
  */
147
153
  async update(data) {
148
- if (!data.type)
154
+ if (!data?.type)
149
155
  data.type = "add";
150
156
  const route = Routes_1.Routes.guilds.users.get(this.manager.guild.id, this.id);
151
157
  const payload = {};
152
158
  const numericFields = ["coins", "wins", "points", "losses", "mvps", "games"];
153
- const arrayFields = ["items", "originalChannels"];
154
- if (data.type === "add" || data.type === "remove") {
159
+ const arrayFields = ["items", "original_channels"];
160
+ if (data?.type === "add" || data?.type === "remove") {
155
161
  for (const key in data) {
156
162
  if (key === "type")
157
163
  continue;
@@ -159,31 +165,31 @@ class GuildUser {
159
165
  if (numericFields.includes(key)) {
160
166
  const current = this[key];
161
167
  const num = value;
162
- payload[key] = Math.max(0, data.type === "add" ? current + num : num - current);
168
+ payload[key] = Math.max(0, data?.type === "add" ? current + num : num - current);
163
169
  }
164
170
  else if (key === "blacklist") {
165
171
  payload["blacklist"] = value;
166
172
  }
167
173
  else if (arrayFields.includes(key)) {
168
- if (key === "originalChannels") {
169
- const current = this.originalChannels;
170
- const fromData = data["originalChannels"];
174
+ if (key === "original_channels") {
175
+ const current = this.original_channels;
176
+ const fromData = data["original_channels"];
171
177
  let channels = [];
172
- if (data.type === "add") {
178
+ if (data?.type === "add") {
173
179
  const existingIds = new Set(current.map((ch) => ch.matchId));
174
180
  channels = [...current, ...fromData.filter((ch) => !existingIds.has(ch.matchId))];
175
181
  }
176
- else if (data.type === "remove") {
182
+ else if (data?.type === "remove") {
177
183
  const idsToRemove = new Set(fromData.map((ch) => ch.matchId));
178
184
  channels = current.filter((ch) => !idsToRemove.has(ch.matchId));
179
185
  }
180
- payload["originalChannels"] = channels;
186
+ payload["original_channels"] = channels;
181
187
  continue;
182
188
  }
183
189
  const current = this[key];
184
190
  const incoming = value;
185
191
  payload[key] =
186
- data.type === "add"
192
+ data?.type === "add"
187
193
  ? [...new Set([...current, ...incoming])]
188
194
  : current.filter((x) => !incoming.includes(x));
189
195
  }
@@ -201,6 +207,8 @@ class GuildUser {
201
207
  this[k] = response[k];
202
208
  }
203
209
  }
210
+ this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
211
+ this.createdAt = response?.createdAt ? new Date(response?.createdAt) : new Date();
204
212
  this.rest.users.set(this.id, this);
205
213
  this.manager.cache.set(this.id, this);
206
214
  return this;
@@ -211,7 +219,7 @@ class GuildUser {
211
219
  method: "DELETE",
212
220
  url: route,
213
221
  });
214
- this.rest.emit("betUserDelete", this);
222
+ this.rest.emit("userDelete", this);
215
223
  this.manager.cache.delete(this.id);
216
224
  return response;
217
225
  }
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VipMember = void 0;
4
+ const Routes_1 = require("../../rest/Routes");
5
+ class VipMember {
6
+ /** member's id */
7
+ id;
8
+ /** member name */
9
+ name;
10
+ /** Members's roleId */
11
+ roleId;
12
+ /** Members's voiceChannelId */
13
+ voiceChannelId;
14
+ /** Vip's type */
15
+ type;
16
+ /** Member's Guild Id */
17
+ guild_id;
18
+ duration;
19
+ status;
20
+ /** member's daily */
21
+ createdAt;
22
+ /** Updated Date */
23
+ updatedAt;
24
+ /** The given manager */
25
+ manager;
26
+ /** The rest client */
27
+ rest;
28
+ guild;
29
+ /**
30
+ * Bet member
31
+ * @param data The member's data
32
+ * @param manager The manager
33
+ * @param rest The rest client
34
+ */
35
+ constructor(data, manager) {
36
+ this.name = data?.name;
37
+ this.id = data?.id;
38
+ this.manager = manager;
39
+ this.rest = manager.rest;
40
+ this.guild = manager.guild;
41
+ this.duration = data?.duration ? new Date(data?.duration) : new Date();
42
+ this.status = data?.status;
43
+ this.type = data?.type;
44
+ this.roleId = data?.roleId;
45
+ this.voiceChannelId = data?.voiceChannelId;
46
+ this.guild_id = data?.guild_id;
47
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
48
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
49
+ }
50
+ /** String representation of this member */
51
+ toString() {
52
+ return `<@${this.id}>`;
53
+ }
54
+ /**
55
+ * Fetches the member
56
+ * @returns New Instance of the member
57
+ */
58
+ async fetch() {
59
+ const route = Routes_1.Routes.vipmembers.get(this.guild_id, this.id);
60
+ const response = await this.rest.request({
61
+ method: "get",
62
+ url: route,
63
+ });
64
+ const member = new VipMember(response, this.manager);
65
+ this.manager.cache.set(member.id, member);
66
+ return member;
67
+ }
68
+ async reset() {
69
+ const route = Routes_1.Routes.vipmembers.get(this.guild_id, this.id);
70
+ const payload = { reset: true };
71
+ const response = await this.rest.request({
72
+ method: "DELETE",
73
+ url: route,
74
+ payload,
75
+ });
76
+ this.#updateData(response);
77
+ this.type = response.type;
78
+ this.manager.set(response);
79
+ return this;
80
+ }
81
+ #updateData(data) {
82
+ for (const k in data) {
83
+ if (k === "id")
84
+ continue;
85
+ if (Object.hasOwn(this, k)) {
86
+ this[k] = data[k];
87
+ this.data[k] = data[k];
88
+ }
89
+ }
90
+ }
91
+ /**
92
+ * Update certain property
93
+ * @param data The new data to update with
94
+ * @returns
95
+ */
96
+ async update(data) {
97
+ const route = Routes_1.Routes.vipmembers.get(this.guild.id, this.id);
98
+ const payload = data;
99
+ const response = await this.rest.request({
100
+ method: "patch",
101
+ url: route,
102
+ payload,
103
+ });
104
+ for (const k in response) {
105
+ if (k === "id")
106
+ continue;
107
+ if (Object.hasOwn(this, k)) {
108
+ this[k] = response[k];
109
+ }
110
+ }
111
+ this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
112
+ this.duration = response?.duration ? new Date(response?.duration) : new Date();
113
+ this.createdAt = response?.createdAt ? new Date(response?.createdAt) : new Date();
114
+ this.type = response.type;
115
+ this.manager.cache.set(this.id, this);
116
+ return this;
117
+ }
118
+ async delete() {
119
+ const route = Routes_1.Routes.vipmembers.delete(this.guild_id, this.id);
120
+ const response = await this.rest.request({
121
+ method: "DELETE",
122
+ url: route,
123
+ });
124
+ this.manager.cache.delete(this.id);
125
+ return response;
126
+ }
127
+ toJSON() {
128
+ let json;
129
+ for (const [key, value] of Object.entries(this)) {
130
+ if (typeof value !== "function") {
131
+ json[key] = value;
132
+ }
133
+ }
134
+ return json;
135
+ }
136
+ }
137
+ exports.VipMember = VipMember;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.STATES = exports.BETSTATUS = exports.MATCHSTATUS = exports.MATCHTYPES = void 0;
4
18
  var MATCHTYPES;
@@ -33,3 +47,25 @@ var STATES;
33
47
  STATES["SHUTTED"] = "shutted";
34
48
  STATES["WAITING"] = "waiting";
35
49
  })(STATES || (exports.STATES = STATES = {}));
50
+ __exportStar(require("./APIBaseChannel"), exports);
51
+ __exportStar(require("./APIBetChannel"), exports);
52
+ __exportStar(require("./APIBetMessage"), exports);
53
+ __exportStar(require("./APIGuild"), exports);
54
+ __exportStar(require("./APIGuildBet"), exports);
55
+ __exportStar(require("./APIGuildBetUser"), exports);
56
+ __exportStar(require("./APIGuildChannel"), exports);
57
+ __exportStar(require("./APIGuildEmoji"), exports);
58
+ __exportStar(require("./APIGuildGroupedChannel"), exports);
59
+ __exportStar(require("./APIGuildMatch"), exports);
60
+ __exportStar(require("./APIGuildMediator"), exports);
61
+ __exportStar(require("./APIGuildPermissions"), exports);
62
+ __exportStar(require("./APIGuildRole"), exports);
63
+ __exportStar(require("./APIGuildShop"), exports);
64
+ __exportStar(require("./APIGuildTicket"), exports);
65
+ __exportStar(require("./APIGuildUser"), exports);
66
+ __exportStar(require("./APIMessage"), exports);
67
+ __exportStar(require("./APIPlayer"), exports);
68
+ __exportStar(require("./APIProduct"), exports);
69
+ __exportStar(require("./APIVipMember"), exports);
70
+ __exportStar(require("./APIGiveaway"), exports);
71
+ __exportStar(require("./APILogMessage"), exports);
@@ -14,24 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./api/APIBaseChannel"), exports);
18
- __exportStar(require("./api/APIBetChannel"), exports);
19
- __exportStar(require("./api/APIBetMessage"), exports);
20
- __exportStar(require("./api/APIGuild"), exports);
21
- __exportStar(require("./api/APIGuildBet"), exports);
22
- __exportStar(require("./api/APIGuildBetUser"), exports);
23
- __exportStar(require("./api/APIGuildChannel"), exports);
24
- __exportStar(require("./api/APIGuildEmoji"), exports);
25
- __exportStar(require("./api/APIGuildGroupedChannel"), exports);
26
- __exportStar(require("./api/APIGuildMatch"), exports);
27
- __exportStar(require("./api/APIGuildMediator"), exports);
28
- __exportStar(require("./api/APIGuildMessage"), exports);
29
- __exportStar(require("./api/APIGuildPermissions"), exports);
30
- __exportStar(require("./api/APIGuildRole"), exports);
31
- __exportStar(require("./api/APIGuildShop"), exports);
32
- __exportStar(require("./api/APIGuildTicket"), exports);
33
- __exportStar(require("./api/APIGuildUser"), exports);
34
- __exportStar(require("./api/APIMessage"), exports);
35
- __exportStar(require("./api/APIPlayer"), exports);
36
- __exportStar(require("./api/APIProduct"), exports);
37
17
  __exportStar(require("./api/index"), exports);
18
+ __exportStar(require("./RestTypes"), exports);
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRandomNumber = getRandomNumber;
4
+ function getRandomNumber(min, max) {
5
+ return Math.floor(Math.random() * (max - min + 1)) + min;
6
+ }
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "@duque.edits/sdk",
3
- "version": "0.1.4",
4
- "main": "./dist/index.js",
5
- "types": "./dist/index.d.ts",
6
- "typings": "./dist/index.d.ts",
3
+ "version": "0.1.6",
4
+ "main": "dist/index",
5
+ "types": "./types/index.d.ts",
6
+ "typings": "./types/index.d.ts",
7
7
  "type": "commonjs",
8
8
  "description": "An SDK that facilitates interaction with my API.",
9
+ "module": "dist/duque.edits-sdk.esm.js",
9
10
  "keywords": [
10
11
  "REST",
11
12
  "API",
@@ -13,11 +14,13 @@
13
14
  "DuqueEdits"
14
15
  ],
15
16
  "files": [
16
- "./dist",
17
- "./package.json"
17
+ "dist",
18
+ "types"
18
19
  ],
19
20
  "scripts": {
20
- "test": "ts-node tests/index.ts"
21
+ "test": "ts-node tests/index.ts",
22
+ "match": "ts-node tests/match.ts",
23
+ "guild": "ts-node tests/guild.ts"
21
24
  },
22
25
  "author": "Duque Edits jedits077@gmail.com",
23
26
  "license": "ISC",
@@ -42,20 +45,10 @@
42
45
  "ts-node": "^10.9.2",
43
46
  "typescript": "^5.8.3"
44
47
  },
45
- "exports": {
46
- ".": {
47
- "require": "./dist/index.js",
48
- "types": "./dist/index.d.ts"
49
- },
50
- "./v1": {
51
- "require": "./dist/v1",
52
- "types": "./dist/index.d.ts"
53
- }
54
- },
55
48
  "publishConfig": {
56
49
  "access": "public"
57
50
  },
58
51
  "engines": {
59
- "node": ">=14"
52
+ "node": ">=20"
60
53
  }
61
54
  }
@@ -0,0 +1,4 @@
1
+ export * from "./managers";
2
+ export * from "./structures";
3
+ export * from "./rest";
4
+ export * from "./types";
@@ -0,0 +1,17 @@
1
+ import { REST } from "../rest/REST";
2
+ import { Collection } from "../structures/Collection";
3
+ import { Guild } from "../structures/guild/Guild";
4
+ export declare class BaseManager<S> {
5
+ /** This url of the manager */
6
+ base_url: string;
7
+ /** The rest client */
8
+ rest: REST;
9
+ /** The guild of the manager */
10
+ guild: Guild;
11
+ /** Cache */
12
+ cache: Collection<string, S>;
13
+ /** Internal data when manager is initialized */
14
+ _data: unknown;
15
+ constructor(guild: Guild, data?: unknown);
16
+ get data(): unknown;
17
+ }
@@ -0,0 +1,19 @@
1
+ import { Collection } from "../../structures/Collection";
2
+ import { Guild } from "../../structures/guild/Guild";
3
+ import { GuildMatch } from "../../structures/match/GuildMatch";
4
+ import { APIGuildMatch, APIGuildTicket, Optional } from "../../types";
5
+ export type BufferMatch = Optional<APIGuildMatch & {
6
+ id: string;
7
+ }>;
8
+ export type BufferTicket = Optional<APIGuildTicket & {
9
+ id: string;
10
+ }>;
11
+ export declare class BufferManager {
12
+ matches: Collection<string, BufferMatch | GuildMatch>;
13
+ tickets: Collection<string, BufferTicket>;
14
+ guild: Guild;
15
+ constructor(guild: Guild);
16
+ flush(key: "matches" | "tickets"): Promise<APIGuildMatch[] & APIGuildTicket[]>;
17
+ createMatch(id: string, data: BufferMatch): void;
18
+ createTicket(id: string, data: BufferTicket): void;
19
+ }
@@ -1,6 +1,14 @@
1
1
  import { REST } from "../../rest/REST";
2
2
  import { Collection } from "../../structures/Collection";
3
3
  import { Guild } from "../../structures/guild/Guild";
4
+ import { APIGuild } from "../../types/api/APIGuild";
5
+ type FetchOptions = {
6
+ guildId?: string;
7
+ cache?: boolean;
8
+ };
9
+ type DeleteOptions = {
10
+ guildId?: string;
11
+ };
4
12
  export declare class GuildManager {
5
13
  /** A cache of guilds */
6
14
  cache: Collection<string, Guild>;
@@ -17,8 +25,8 @@ export declare class GuildManager {
17
25
  * @param id Id of the guild to fetch
18
26
  * @returns APIGuild
19
27
  */
20
- fetch(id: string): Promise<Guild>;
21
- fetchAll(): Promise<Collection<string, Guild>>;
22
- delete(id: string): Promise<Collection<string, Guild>>;
23
- deleteAll(): Promise<boolean>;
28
+ fetch(options?: FetchOptions): Promise<Collection<string, Guild> | Guild>;
29
+ delete(options: DeleteOptions): Promise<Collection<string, Guild> | boolean>;
30
+ set(data: APIGuild | APIGuild[]): Guild | Collection<string, Guild>;
24
31
  }
32
+ export {};
@@ -0,0 +1,7 @@
1
+ export * from "./buffer/BufferManager";
2
+ export * from "./guild/GuildManager";
3
+ export * from "./match/GuildMatchManager";
4
+ export * from "./permission/GuildPermissionManager";
5
+ export * from "./user/GuildUserManager";
6
+ export * from "./vipmember/VipMemberManager";
7
+ export * from "./ticket/TicketManager";