@duque.edits/sdk 1.3.0 → 1.3.2
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/README.md +1 -1
- package/dist/{index-0BFrnm6S.d.ts → index-xkfp9hFj.d.ts} +27 -22
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/dist/managers/automaticmessage/AutomaticMessageManager.d.ts +1 -1
- package/dist/managers/automaticmessage/AutomaticMessageManager.js +0 -1
- package/dist/managers/base.d.ts +1 -1
- package/dist/managers/base.js +0 -1
- package/dist/managers/bet/GuildBetManager.d.ts +1 -1
- package/dist/managers/bet/GuildBetManager.js +0 -1
- package/dist/managers/betuser/GuildBetUserManager.d.ts +1 -1
- package/dist/managers/betuser/GuildBetUserManager.js +0 -1
- package/dist/managers/buffer/BufferManager.d.ts +1 -1
- package/dist/managers/buffer/BufferManager.js +0 -1
- package/dist/managers/guild/GuildManager.d.ts +1 -1
- package/dist/managers/guild/GuildManager.js +0 -1
- package/dist/managers/index.d.ts +1 -1
- package/dist/managers/index.js +0 -1
- package/dist/managers/logs/LogManager.d.ts +1 -1
- package/dist/managers/logs/LogManager.js +0 -1
- package/dist/managers/match/GuildMatchManager.d.ts +1 -1
- package/dist/managers/match/GuildMatchManager.js +0 -1
- package/dist/managers/mediator/GuildMediatorManager.d.ts +1 -1
- package/dist/managers/mediator/GuildMediatorManager.js +0 -1
- package/dist/managers/message/MessagesManager.d.ts +1 -1
- package/dist/managers/message/MessagesManager.js +0 -1
- package/dist/managers/minesgame/MinesGameManager.d.ts +1 -1
- package/dist/managers/minesgame/MinesGameManager.js +0 -1
- package/dist/managers/permission/GuildPermissionManager.d.ts +1 -1
- package/dist/managers/permission/GuildPermissionManager.js +0 -1
- package/dist/managers/player/PlayerManager.d.ts +1 -1
- package/dist/managers/player/PlayerManager.js +0 -1
- package/dist/managers/product/ProductManager.d.ts +1 -1
- package/dist/managers/product/ProductManager.js +0 -1
- package/dist/managers/shop/ShopManager.d.ts +1 -1
- package/dist/managers/shop/ShopManager.js +0 -1
- package/dist/managers/ticket/TicketManager.d.ts +1 -1
- package/dist/managers/ticket/TicketManager.js +0 -1
- package/dist/managers/ticketpanel/TicketPanelManager.d.ts +1 -1
- package/dist/managers/ticketpanel/TicketPanelManager.js +0 -1
- package/dist/managers/tournament/TournamentManager.d.ts +1 -1
- package/dist/managers/tournament/TournamentManager.js +0 -1
- package/dist/managers/user/GuildUserManager.d.ts +1 -1
- package/dist/managers/user/GuildUserManager.js +5 -6
- package/dist/managers/vipmember/VipMemberManager.d.ts +1 -1
- package/dist/managers/vipmember/VipMemberManager.js +0 -1
- package/dist/rest/APIEndpoints.js +0 -1
- package/dist/rest/REST.d.ts +1 -1
- package/dist/rest/REST.js +0 -1
- package/dist/rest/Routes.d.ts +1 -1
- package/dist/rest/Routes.js +1 -2
- package/dist/rest/index.d.ts +1 -1
- package/dist/rest/index.js +0 -1
- package/dist/structures/Collection.js +0 -1
- package/dist/structures/automaticmessage/AutomaticMessage.d.ts +1 -1
- package/dist/structures/automaticmessage/AutomaticMessage.js +0 -1
- package/dist/structures/bet/GuildBet.d.ts +1 -1
- package/dist/structures/bet/GuildBet.js +0 -1
- package/dist/structures/betuser/GuildBetUser.d.ts +1 -1
- package/dist/structures/betuser/GuildBetUser.js +0 -1
- package/dist/structures/guild/Guild.d.ts +1 -1
- package/dist/structures/guild/Guild.js +2 -2
- package/dist/structures/index.d.ts +1 -1
- package/dist/structures/index.js +0 -1
- package/dist/structures/logentry/LogEntry.d.ts +1 -1
- package/dist/structures/logentry/LogEntry.js +0 -1
- package/dist/structures/match/GuildMatch.d.ts +1 -1
- package/dist/structures/match/GuildMatch.js +0 -1
- package/dist/structures/mediator/GuildMediator.d.ts +1 -1
- package/dist/structures/mediator/GuildMediator.js +0 -1
- package/dist/structures/minesgame/MinesGame.d.ts +1 -1
- package/dist/structures/minesgame/MinesGame.js +0 -1
- package/dist/structures/product/Product.d.ts +1 -1
- package/dist/structures/product/Product.js +4 -1
- package/dist/structures/shop/Shop.d.ts +1 -1
- package/dist/structures/shop/Shop.js +0 -1
- package/dist/structures/ticket/Ticket.d.ts +1 -1
- package/dist/structures/ticket/Ticket.js +9 -1
- package/dist/structures/ticketpanel/TicketPanel.d.ts +1 -1
- package/dist/structures/ticketpanel/TicketPanel.js +0 -2
- package/dist/structures/tournament/Tournament.d.ts +1 -1
- package/dist/structures/tournament/Tournament.js +0 -1
- package/dist/structures/user/GuildUser.d.ts +1 -1
- package/dist/structures/user/GuildUser.js +132 -38
- package/dist/structures/vipmember/VipMember.d.ts +1 -1
- package/dist/structures/vipmember/VipMember.js +0 -1
- package/dist/types/RestTypes.d.ts +1 -1
- package/dist/types/RestTypes.js +0 -1
- package/dist/types/api/APIAdvert.js +0 -1
- package/dist/types/api/APIAutomaticMessage.d.ts +1 -1
- package/dist/types/api/APIAutomaticMessage.js +0 -1
- package/dist/types/api/APIBaseChannel.js +0 -1
- package/dist/types/api/APIBetChannel.js +0 -1
- package/dist/types/api/APICode.js +0 -1
- package/dist/types/api/APIGiveaway.js +0 -1
- package/dist/types/api/APIGuild.d.ts +1 -1
- package/dist/types/api/APIGuild.js +0 -1
- package/dist/types/api/APIGuildAdvert.js +0 -1
- package/dist/types/api/APIGuildBet.d.ts +1 -1
- package/dist/types/api/APIGuildBet.js +0 -1
- package/dist/types/api/APIGuildBetUser.d.ts +1 -1
- package/dist/types/api/APIGuildBetUser.js +0 -1
- package/dist/types/api/APIGuildChannel.js +0 -1
- package/dist/types/api/APIGuildGroupedChannel.d.ts +1 -1
- package/dist/types/api/APIGuildGroupedChannel.js +0 -1
- package/dist/types/api/APIGuildMatch.d.ts +1 -1
- package/dist/types/api/APIGuildMatch.js +0 -1
- package/dist/types/api/APIGuildMediator.js +0 -1
- package/dist/types/api/APIGuildPermissions.js +0 -1
- package/dist/types/api/APIGuildShop.js +0 -1
- package/dist/types/api/APIGuildTicket.js +0 -1
- package/dist/types/api/APIGuildUser.d.ts +1 -1
- package/dist/types/api/APIGuildUser.js +0 -1
- package/dist/types/api/APILogEntry.js +0 -1
- package/dist/types/api/APIMessage.js +0 -1
- package/dist/types/api/APIMinesGame.js +0 -1
- package/dist/types/api/APIPlayer.js +0 -1
- package/dist/types/api/APIProduct.d.ts +1 -0
- package/dist/types/api/APIProduct.js +0 -1
- package/dist/types/api/APITicketPanel.d.ts +1 -1
- package/dist/types/api/APITicketPanel.js +0 -1
- package/dist/types/api/APITournament.js +0 -1
- package/dist/types/api/APIVipMember.js +0 -1
- package/dist/types/api/index.d.ts +1 -1
- package/dist/types/api/index.js +8 -10
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +0 -1
- package/dist/utils/Assertion.js +0 -1
- package/dist/utils/clamp0.d.ts +3 -0
- package/dist/utils/clamp0.js +31 -0
- package/dist/utils/getRandomNumber.js +0 -1
- package/dist/utils/isSameDayUTC.js +0 -1
- package/dist/utils/randomKeyGenerator.js +0 -1
- package/package.json +1 -1
- package/dist/index.js.map +0 -1
- package/dist/managers/automaticmessage/AutomaticMessageManager.js.map +0 -1
- package/dist/managers/base.js.map +0 -1
- package/dist/managers/bet/GuildBetManager.js.map +0 -1
- package/dist/managers/betuser/GuildBetUserManager.js.map +0 -1
- package/dist/managers/buffer/BufferManager.js.map +0 -1
- package/dist/managers/guild/GuildManager.js.map +0 -1
- package/dist/managers/index.js.map +0 -1
- package/dist/managers/logs/LogManager.js.map +0 -1
- package/dist/managers/match/GuildMatchManager.js.map +0 -1
- package/dist/managers/mediator/GuildMediatorManager.js.map +0 -1
- package/dist/managers/message/MessagesManager.js.map +0 -1
- package/dist/managers/minesgame/MinesGameManager.js.map +0 -1
- package/dist/managers/permission/GuildPermissionManager.js.map +0 -1
- package/dist/managers/player/PlayerManager.js.map +0 -1
- package/dist/managers/product/ProductManager.js.map +0 -1
- package/dist/managers/shop/ShopManager.js.map +0 -1
- package/dist/managers/ticket/TicketManager.js.map +0 -1
- package/dist/managers/ticketpanel/TicketPanelManager.js.map +0 -1
- package/dist/managers/tournament/TournamentManager.js.map +0 -1
- package/dist/managers/user/GuildUserManager.js.map +0 -1
- package/dist/managers/vipmember/VipMemberManager.js.map +0 -1
- package/dist/rest/APIEndpoints.js.map +0 -1
- package/dist/rest/REST.js.map +0 -1
- package/dist/rest/Routes.js.map +0 -1
- package/dist/rest/index.js.map +0 -1
- package/dist/structures/Collection.js.map +0 -1
- package/dist/structures/automaticmessage/AutomaticMessage.js.map +0 -1
- package/dist/structures/bet/GuildBet.js.map +0 -1
- package/dist/structures/betuser/GuildBetUser.js.map +0 -1
- package/dist/structures/guild/Guild.js.map +0 -1
- package/dist/structures/index.js.map +0 -1
- package/dist/structures/logentry/LogEntry.js.map +0 -1
- package/dist/structures/match/GuildMatch.js.map +0 -1
- package/dist/structures/mediator/GuildMediator.js.map +0 -1
- package/dist/structures/minesgame/MinesGame.js.map +0 -1
- package/dist/structures/product/Product.js.map +0 -1
- package/dist/structures/shop/Shop.js.map +0 -1
- package/dist/structures/ticket/Ticket.js.map +0 -1
- package/dist/structures/ticketpanel/TicketPanel.js.map +0 -1
- package/dist/structures/tournament/Tournament.js.map +0 -1
- package/dist/structures/user/GuildUser.js.map +0 -1
- package/dist/structures/vipmember/VipMember.js.map +0 -1
- package/dist/types/RestTypes.js.map +0 -1
- package/dist/types/api/APIAdvert.js.map +0 -1
- package/dist/types/api/APIAutomaticMessage.js.map +0 -1
- package/dist/types/api/APIBaseChannel.js.map +0 -1
- package/dist/types/api/APIBetChannel.js.map +0 -1
- package/dist/types/api/APICode.js.map +0 -1
- package/dist/types/api/APIGiveaway.js.map +0 -1
- package/dist/types/api/APIGuild.js.map +0 -1
- package/dist/types/api/APIGuildAdvert.js.map +0 -1
- package/dist/types/api/APIGuildBet.js.map +0 -1
- package/dist/types/api/APIGuildBetUser.js.map +0 -1
- package/dist/types/api/APIGuildChannel.js.map +0 -1
- package/dist/types/api/APIGuildGroupedChannel.js.map +0 -1
- package/dist/types/api/APIGuildMatch.js.map +0 -1
- package/dist/types/api/APIGuildMediator.js.map +0 -1
- package/dist/types/api/APIGuildPermissions.js.map +0 -1
- package/dist/types/api/APIGuildShop.js.map +0 -1
- package/dist/types/api/APIGuildTicket.js.map +0 -1
- package/dist/types/api/APIGuildUser.js.map +0 -1
- package/dist/types/api/APILogEntry.js.map +0 -1
- package/dist/types/api/APIMessage.js.map +0 -1
- package/dist/types/api/APIMinesGame.js.map +0 -1
- package/dist/types/api/APIPlayer.js.map +0 -1
- package/dist/types/api/APIProduct.js.map +0 -1
- package/dist/types/api/APITicketPanel.js.map +0 -1
- package/dist/types/api/APITournament.js.map +0 -1
- package/dist/types/api/APIVipMember.js.map +0 -1
- package/dist/types/api/index.js.map +0 -1
- package/dist/types/index.js.map +0 -1
- package/dist/utils/Assertion.js.map +0 -1
- package/dist/utils/getRandomNumber.js.map +0 -1
- package/dist/utils/isSameDayUTC.js.map +0 -1
- package/dist/utils/randomKeyGenerator.js.map +0 -1
package/dist/structures/index.js
CHANGED
|
@@ -45,6 +45,7 @@ class Product {
|
|
|
45
45
|
__publicField(this, "buyers");
|
|
46
46
|
/** Product's emoji */
|
|
47
47
|
__publicField(this, "emoji");
|
|
48
|
+
__publicField(this, "units_in_stock");
|
|
48
49
|
/** Creation Date */
|
|
49
50
|
__publicField(this, "createdAt");
|
|
50
51
|
/** Updated Date */
|
|
@@ -61,6 +62,7 @@ class Product {
|
|
|
61
62
|
this.buyers = data?.buyers;
|
|
62
63
|
this.emoji = data?.emoji;
|
|
63
64
|
this.price = data?.price;
|
|
65
|
+
this.units_in_stock = data?.units_in_stock;
|
|
64
66
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : /* @__PURE__ */ new Date();
|
|
65
67
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : /* @__PURE__ */ new Date();
|
|
66
68
|
}
|
|
@@ -77,6 +79,7 @@ class Product {
|
|
|
77
79
|
buyers: data.buyers || this.buyers,
|
|
78
80
|
emoji: data.emoji || this.emoji,
|
|
79
81
|
price: data.price || this.price,
|
|
82
|
+
units_in_stock: data.units_in_stock || this.units_in_stock,
|
|
80
83
|
createdAt: this.createdAt,
|
|
81
84
|
updatedAt: data.updatedAt || this.updatedAt
|
|
82
85
|
};
|
|
@@ -94,6 +97,7 @@ class Product {
|
|
|
94
97
|
emoji: this.emoji,
|
|
95
98
|
name: this.name,
|
|
96
99
|
price: this.price,
|
|
100
|
+
units_in_stock: this.units_in_stock,
|
|
97
101
|
createdAt: this.createdAt,
|
|
98
102
|
updatedAt: this.updatedAt
|
|
99
103
|
};
|
|
@@ -117,4 +121,3 @@ update_fn = async function(data) {
|
|
|
117
121
|
0 && (module.exports = {
|
|
118
122
|
Product
|
|
119
123
|
});
|
|
120
|
-
//# sourceMappingURL=Product.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'discord-api-types/v10';
|
|
2
|
-
export {
|
|
2
|
+
export { an as Shop } from '../../index-xkfp9hFj.js';
|
|
3
3
|
import '../../types/api/APIGuildShop.js';
|
|
4
4
|
import '../../types/api/APIAdvert.js';
|
|
5
5
|
import '../../types/api/APIBaseChannel.js';
|
|
@@ -74,6 +74,15 @@ class GuildTicket {
|
|
|
74
74
|
});
|
|
75
75
|
return __privateMethod(this, _GuildTicket_instances, update_fn).call(this, response);
|
|
76
76
|
}
|
|
77
|
+
async delete() {
|
|
78
|
+
this.manager.cache.delete(this._id);
|
|
79
|
+
const url = import_rest.Routes.guilds.tickets.get(this.guild.id, this._id);
|
|
80
|
+
const response = await this.rest.request({
|
|
81
|
+
method: "delete",
|
|
82
|
+
url
|
|
83
|
+
});
|
|
84
|
+
return response;
|
|
85
|
+
}
|
|
77
86
|
async setCustomerRating(rating) {
|
|
78
87
|
const url = import_rest.Routes.guilds.tickets.resource(this.guild.id, this._id, "customer_rating");
|
|
79
88
|
const payload = { set: rating };
|
|
@@ -144,4 +153,3 @@ update_fn = function(data) {
|
|
|
144
153
|
0 && (module.exports = {
|
|
145
154
|
GuildTicket
|
|
146
155
|
});
|
|
147
|
-
//# sourceMappingURL=Ticket.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'discord-api-types/v10';
|
|
2
|
-
export {
|
|
2
|
+
export { ar as TicketPanel } from '../../index-xkfp9hFj.js';
|
|
3
3
|
import '../../types/api/APIAdvert.js';
|
|
4
4
|
import '../../types/api/APIBaseChannel.js';
|
|
5
5
|
import '../../types/api/APIBetChannel.js';
|
|
@@ -107,7 +107,6 @@ class TicketPanel {
|
|
|
107
107
|
cat.role_ids = [.../* @__PURE__ */ new Set([...roles])];
|
|
108
108
|
this.categories[index] = cat;
|
|
109
109
|
}
|
|
110
|
-
console.dir({ categories: this.categories }, { depth: null });
|
|
111
110
|
return await this.update({ categories: this.categories });
|
|
112
111
|
}
|
|
113
112
|
async removeRoleIdToCategory(id, ...roles) {
|
|
@@ -174,4 +173,3 @@ update_fn = function(data) {
|
|
|
174
173
|
0 && (module.exports = {
|
|
175
174
|
TicketPanel
|
|
176
175
|
});
|
|
177
|
-
//# sourceMappingURL=TicketPanel.js.map
|
|
@@ -31,6 +31,7 @@ __export(GuildUser_exports, {
|
|
|
31
31
|
module.exports = __toCommonJS(GuildUser_exports);
|
|
32
32
|
var import_Routes = require("../../rest/Routes");
|
|
33
33
|
var import_isSameDayUTC = require("../../utils/isSameDayUTC");
|
|
34
|
+
var import_clamp0 = require("../../utils/clamp0");
|
|
34
35
|
var _GuildUser_instances, update_fn;
|
|
35
36
|
const _GuildUser = class _GuildUser {
|
|
36
37
|
/**
|
|
@@ -167,11 +168,13 @@ const _GuildUser = class _GuildUser {
|
|
|
167
168
|
profile: {
|
|
168
169
|
avatarUrl: data.avatarUrl || this.profile.avatarUrl || "",
|
|
169
170
|
bannerUrl: data.bannerUrl || this.profile.bannerUrl || "",
|
|
170
|
-
bio: data.bio || this.profile.bio || "
|
|
171
|
+
bio: data.bio || this.profile.bio || "Melhorzinho(a) do momento!",
|
|
171
172
|
name: data.name || this.profile.name || "",
|
|
173
|
+
extra: data.extra || this.profile.extra || "",
|
|
172
174
|
textColor: data.textColor || this.profile.textColor || "#ffffff",
|
|
173
175
|
primaryColor: data.primaryColor || this.profile.primaryColor || "#272727",
|
|
174
176
|
secondaryColor: data.secondaryColor || this.profile.secondaryColor || "#151515",
|
|
177
|
+
tertiaryColor: data.tertiaryColor || this.profile.tertiaryColor || "#151515",
|
|
175
178
|
booster: {
|
|
176
179
|
expires: data?.booster?.expires || this.profile.booster.expires,
|
|
177
180
|
status: data?.booster?.status || this.profile.booster.status || "off"
|
|
@@ -191,7 +194,8 @@ const _GuildUser = class _GuildUser {
|
|
|
191
194
|
name: "",
|
|
192
195
|
textColor: "#ffffff",
|
|
193
196
|
primaryColor: "#272727",
|
|
194
|
-
secondaryColor: "#151515"
|
|
197
|
+
secondaryColor: "#151515",
|
|
198
|
+
tertiaryColor: "#272727"
|
|
195
199
|
}
|
|
196
200
|
};
|
|
197
201
|
}
|
|
@@ -211,39 +215,117 @@ const _GuildUser = class _GuildUser {
|
|
|
211
215
|
acc = {
|
|
212
216
|
type,
|
|
213
217
|
time: 0,
|
|
214
|
-
units: 0
|
|
218
|
+
units: 0,
|
|
219
|
+
active: {
|
|
220
|
+
time: 0,
|
|
221
|
+
units: 0
|
|
222
|
+
}
|
|
215
223
|
};
|
|
216
224
|
this.accessories.push(acc);
|
|
217
|
-
await this.
|
|
225
|
+
await this.setUpdate({ accessories: this.accessories });
|
|
218
226
|
return acc;
|
|
219
227
|
}
|
|
220
228
|
async addAccessory(type, data) {
|
|
221
|
-
const { units, time } = data;
|
|
222
|
-
let acc = this
|
|
223
|
-
if (!acc) acc = { type, units, time };
|
|
229
|
+
const { units, time, active } = data;
|
|
230
|
+
let acc = this?.accessories?.find((a) => a.type === type);
|
|
231
|
+
if (!acc) acc = { type, units, time, active };
|
|
224
232
|
else
|
|
225
233
|
acc = {
|
|
226
234
|
type,
|
|
227
|
-
time:
|
|
228
|
-
units:
|
|
235
|
+
time: (0, import_clamp0.clamp0)(0, acc.time + (time || 0)),
|
|
236
|
+
units: (0, import_clamp0.clamp0)(0, acc.units + (units || 0)),
|
|
237
|
+
active: {
|
|
238
|
+
time: active && active?.time ? (0, import_clamp0.clamp0)(acc?.active?.time || 0 + active.time || 0) : 0,
|
|
239
|
+
units: active && active?.units ? (0, import_clamp0.clamp0)(acc?.active?.units || 0 + active.units || 0) : 0
|
|
240
|
+
}
|
|
229
241
|
};
|
|
230
242
|
const index = this.accessories.findIndex((a) => a.type === type);
|
|
231
243
|
this.accessories[index] = acc;
|
|
232
|
-
|
|
244
|
+
await this.setUpdate({ accessories: this.accessories });
|
|
245
|
+
return acc;
|
|
233
246
|
}
|
|
234
|
-
async
|
|
235
|
-
const { units, time } = data;
|
|
247
|
+
async setAccessory(type, data) {
|
|
248
|
+
const { units, time, active } = data;
|
|
236
249
|
let acc = this.accessories.find((a) => a.type === type);
|
|
237
|
-
|
|
238
|
-
|
|
250
|
+
const payload = {
|
|
251
|
+
type,
|
|
252
|
+
units: units !== void 0 ? units : acc?.units || 0,
|
|
253
|
+
time: time !== void 0 ? time : acc?.time || 0,
|
|
254
|
+
active: {
|
|
255
|
+
time: active?.time !== void 0 ? active?.time : acc?.active?.time || 0,
|
|
256
|
+
units: active?.units !== void 0 ? active?.units : acc?.active?.units || 0
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
if (!acc) acc = payload;
|
|
260
|
+
else acc = payload;
|
|
261
|
+
const index = this.accessories.findIndex((a) => a.type === type);
|
|
262
|
+
this.accessories[index] = acc;
|
|
263
|
+
await this.setUpdate({ accessories: this.accessories });
|
|
264
|
+
return acc;
|
|
265
|
+
}
|
|
266
|
+
async reduceAccessory(type, data) {
|
|
267
|
+
const { units = 0, time = 0 } = data;
|
|
268
|
+
let acc = this.accessories.find((a) => a.type === type);
|
|
269
|
+
if (!acc) {
|
|
239
270
|
acc = {
|
|
240
271
|
type,
|
|
241
|
-
|
|
242
|
-
|
|
272
|
+
units: 0,
|
|
273
|
+
time: 0,
|
|
274
|
+
active: { time: 0, units: 0 }
|
|
243
275
|
};
|
|
276
|
+
}
|
|
277
|
+
acc = {
|
|
278
|
+
type,
|
|
279
|
+
time: (0, import_clamp0.clamp0)(acc.time - time),
|
|
280
|
+
units: (0, import_clamp0.clamp0)(acc.units - units),
|
|
281
|
+
active: acc.active
|
|
282
|
+
};
|
|
283
|
+
const index = this.accessories.findIndex((a) => a.type === type);
|
|
284
|
+
this.accessories[index] = acc;
|
|
285
|
+
await this.setUpdate({ accessories: this.accessories });
|
|
286
|
+
return acc;
|
|
287
|
+
}
|
|
288
|
+
async reduceActiveAccessory(type, data) {
|
|
289
|
+
const { units = 0, time = 0 } = data;
|
|
290
|
+
let acc = await this.getAccessory(type);
|
|
291
|
+
acc = {
|
|
292
|
+
...acc,
|
|
293
|
+
active: {
|
|
294
|
+
time: (0, import_clamp0.clamp0)(acc?.active?.time - time),
|
|
295
|
+
units: (0, import_clamp0.clamp0)(acc?.active?.units - units)
|
|
296
|
+
}
|
|
297
|
+
};
|
|
244
298
|
const index = this.accessories.findIndex((a) => a.type === type);
|
|
245
299
|
this.accessories[index] = acc;
|
|
246
|
-
|
|
300
|
+
await this.setUpdate({ accessories: this.accessories });
|
|
301
|
+
return acc;
|
|
302
|
+
}
|
|
303
|
+
async activateAccessory(type, data) {
|
|
304
|
+
const acc = await this.reduceAccessory(type, data);
|
|
305
|
+
const timeToAdd = (0, import_clamp0.clamp0)(data.time);
|
|
306
|
+
const unitsToAdd = (0, import_clamp0.clamp0)(acc.active.units + data.units);
|
|
307
|
+
const _dateBefore = new Date(acc.active.time === 0 ? Date.now() : acc.active.time);
|
|
308
|
+
const dateBefore = _dateBefore.getTime() <= Date.now() ? /* @__PURE__ */ new Date() : _dateBefore;
|
|
309
|
+
const finalTime = dateBefore.getTime() + timeToAdd;
|
|
310
|
+
acc.active = { time: finalTime, units: unitsToAdd };
|
|
311
|
+
const index = this.accessories.findIndex((a) => a.type === type);
|
|
312
|
+
this.accessories[index] = acc;
|
|
313
|
+
await this.setUpdate({ accessories: this.accessories });
|
|
314
|
+
return acc;
|
|
315
|
+
}
|
|
316
|
+
async isAccessoryActive(type) {
|
|
317
|
+
const acc = await this.getAccessory(type);
|
|
318
|
+
if (acc.active.time === 0 && acc.active.units === 0) return { value: false, type: "both" };
|
|
319
|
+
const hasTimeExpired = new Date(acc.active.time).getTime() <= Date.now();
|
|
320
|
+
if (hasTimeExpired && acc.units === 0) return { value: false, type: "both" };
|
|
321
|
+
if (!hasTimeExpired && acc.units === 0) return { value: true, type: "time" };
|
|
322
|
+
if (hasTimeExpired && acc.units !== 0) return { value: true, type: "units" };
|
|
323
|
+
return { value: true, type: "units" };
|
|
324
|
+
}
|
|
325
|
+
async hasAccessory(type) {
|
|
326
|
+
const acc = await this.getAccessory(type);
|
|
327
|
+
if (acc?.time === 0 && acc?.units === 0) return false;
|
|
328
|
+
else return true;
|
|
247
329
|
}
|
|
248
330
|
async addAdvert(data) {
|
|
249
331
|
const url = import_Routes.Routes.guilds.users.resource(this.manager.guild.id, this.id, "adverts");
|
|
@@ -280,7 +362,7 @@ const _GuildUser = class _GuildUser {
|
|
|
280
362
|
"coins",
|
|
281
363
|
"consecutive_wins"
|
|
282
364
|
];
|
|
283
|
-
const arrayFields = ["items", "original_channels", "adverts", "
|
|
365
|
+
const arrayFields = ["items", "original_channels", "adverts", "used_codes"];
|
|
284
366
|
if (data?.type === "add" || data?.type === "remove") {
|
|
285
367
|
for (const key in data) {
|
|
286
368
|
if (key === "type") continue;
|
|
@@ -314,6 +396,7 @@ const _GuildUser = class _GuildUser {
|
|
|
314
396
|
}
|
|
315
397
|
}
|
|
316
398
|
}
|
|
399
|
+
if ("accessories" in data) payload["accessories"] = data["accessories"];
|
|
317
400
|
payload["daily"] = this.userDailyWrapper(data).daily;
|
|
318
401
|
payload["consecutive_wins"] = this.userDailyWrapper(data).consecutive_wins;
|
|
319
402
|
const response = await this.rest.request({
|
|
@@ -321,8 +404,7 @@ const _GuildUser = class _GuildUser {
|
|
|
321
404
|
url,
|
|
322
405
|
payload
|
|
323
406
|
});
|
|
324
|
-
__privateMethod(this, _GuildUser_instances, update_fn).call(this, response);
|
|
325
|
-
return this;
|
|
407
|
+
return __privateMethod(this, _GuildUser_instances, update_fn).call(this, response);
|
|
326
408
|
}
|
|
327
409
|
async setUpdate(data) {
|
|
328
410
|
const url = import_Routes.Routes.guilds.users.get(this.manager.guild.id, this.id);
|
|
@@ -345,20 +427,33 @@ const _GuildUser = class _GuildUser {
|
|
|
345
427
|
return response;
|
|
346
428
|
}
|
|
347
429
|
toJSON() {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
430
|
+
return {
|
|
431
|
+
accessories: this.accessories,
|
|
432
|
+
adverts: this.adverts,
|
|
433
|
+
blacklist: this.blacklist,
|
|
434
|
+
coins: this.coins,
|
|
435
|
+
consecutive_wins: this.consecutive_wins,
|
|
436
|
+
createdAt: this.createdAt,
|
|
437
|
+
creations: this.creations,
|
|
438
|
+
daily: this.daily,
|
|
439
|
+
games: this.games,
|
|
440
|
+
guild_id: this.guild_id,
|
|
441
|
+
id: this.id,
|
|
442
|
+
losses: this.losses,
|
|
443
|
+
mvps: this.mvps,
|
|
444
|
+
original_channels: this.original_channels,
|
|
445
|
+
points: this.points,
|
|
446
|
+
profile: this.profile,
|
|
447
|
+
spins: this.spins,
|
|
448
|
+
updatedAt: this.updatedAt,
|
|
449
|
+
used_codes: this.used_codes,
|
|
450
|
+
wins: this.wins
|
|
451
|
+
};
|
|
357
452
|
}
|
|
358
453
|
userDailyWrapper(user) {
|
|
359
454
|
const now = /* @__PURE__ */ new Date();
|
|
360
455
|
const sameDay = !!this.daily?.date && (0, import_isSameDayUTC.isSameDateUTC)(this.daily.date, now);
|
|
361
|
-
const
|
|
456
|
+
const clamp02 = (n) => Math.max(0, n);
|
|
362
457
|
const prev = this.daily ?? { points: 0, wins: 0, coins: 0, losses: 0, mvps: 0 };
|
|
363
458
|
const inc = {
|
|
364
459
|
points: user?.points || 0,
|
|
@@ -368,16 +463,16 @@ const _GuildUser = class _GuildUser {
|
|
|
368
463
|
mvps: user?.mvps || 0
|
|
369
464
|
};
|
|
370
465
|
user.daily = {
|
|
371
|
-
points:
|
|
372
|
-
wins:
|
|
373
|
-
coins:
|
|
374
|
-
losses:
|
|
375
|
-
mvps:
|
|
466
|
+
points: clamp02((sameDay ? prev.points : 0) + inc.points),
|
|
467
|
+
wins: clamp02((sameDay ? prev.wins : 0) + inc.wins),
|
|
468
|
+
coins: clamp02((sameDay ? prev.coins : 0) + inc.coins),
|
|
469
|
+
losses: clamp02((sameDay ? prev.losses : 0) + inc.losses),
|
|
470
|
+
mvps: clamp02((sameDay ? prev.mvps : 0) + inc.mvps),
|
|
376
471
|
date: now
|
|
377
472
|
};
|
|
378
473
|
const gainedWins = inc.wins;
|
|
379
|
-
const hasLostToday =
|
|
380
|
-
user.consecutive_wins = hasLostToday ? 0 : (this.consecutive_wins || 0) +
|
|
474
|
+
const hasLostToday = user.losses !== 0;
|
|
475
|
+
user.consecutive_wins = hasLostToday && !gainedWins ? 0 : (this.consecutive_wins || 0) + 1;
|
|
381
476
|
return user;
|
|
382
477
|
}
|
|
383
478
|
};
|
|
@@ -416,4 +511,3 @@ let GuildUser = _GuildUser;
|
|
|
416
511
|
0 && (module.exports = {
|
|
417
512
|
GuildUser
|
|
418
513
|
});
|
|
419
|
-
//# sourceMappingURL=GuildUser.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../structures/Collection.js';
|
|
2
|
-
export {
|
|
2
|
+
export { ai as RequestOptions, aj as RestEvents } from '../index-xkfp9hFj.js';
|
|
3
3
|
import './api/APIAdvert.js';
|
|
4
4
|
import './api/APIBaseChannel.js';
|
|
5
5
|
import './api/APIBetChannel.js';
|
package/dist/types/RestTypes.js
CHANGED
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIAutomaticMessage_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIAutomaticMessage_exports);
|
|
17
|
-
//# sourceMappingURL=APIAutomaticMessage.js.map
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIBaseChannel_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIBaseChannel_exports);
|
|
17
|
-
//# sourceMappingURL=APIBaseChannel.js.map
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIBetChannel_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIBetChannel_exports);
|
|
17
|
-
//# sourceMappingURL=APIBetChannel.js.map
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIGiveaway_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIGiveaway_exports);
|
|
17
|
-
//# sourceMappingURL=APIGiveaway.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { a as APIGuild,
|
|
1
|
+
export { a as APIGuild, l as AutomaticMessagesTypes, v as DailyCategories, H as GuildChannelsType, I as GuildLogsWebhookUrls, Q as GuildModes, T as GuildPrices, U as GuildScores, V as GuildStatus, W as GuildStatusEnum, Y as GuildTicketConfiguration, ak as RoulettePrize, al as RouletteSettings } from '../../index-xkfp9hFj.js';
|
|
2
2
|
import './APIGuildPermissions.js';
|
|
3
3
|
import './APIGuildAdvert.js';
|
|
4
4
|
import './APICode.js';
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIGuildAdvert_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIGuildAdvert_exports);
|
|
17
|
-
//# sourceMappingURL=APIGuildAdvert.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { b as APIGuildBet,
|
|
1
|
+
export { b as APIGuildBet, q as BetChannelTypes, r as BetQueue } from '../../index-xkfp9hFj.js';
|
|
2
2
|
import './APIBetChannel.js';
|
|
3
3
|
import './APIMessage.js';
|
|
4
4
|
import './APIPlayer.js';
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIGuildBetUser_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIGuildBetUser_exports);
|
|
17
|
-
//# sourceMappingURL=APIGuildBetUser.js.map
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIGuildChannel_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIGuildChannel_exports);
|
|
17
|
-
//# sourceMappingURL=APIGuildChannel.js.map
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIGuildGroupedChannel_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIGuildGroupedChannel_exports);
|
|
17
|
-
//# sourceMappingURL=APIGuildGroupedChannel.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { e as APIGuildMatch,
|
|
1
|
+
export { e as APIGuildMatch, L as GuildMatchChannelsType, N as GuildMatchMessagesType, a6 as MatchSelection } from '../../index-xkfp9hFj.js';
|
|
2
2
|
import './APIPlayer.js';
|
|
3
3
|
import './APIBaseChannel.js';
|
|
4
4
|
import './APIMessage.js';
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIGuildMediator_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIGuildMediator_exports);
|
|
17
|
-
//# sourceMappingURL=APIGuildMediator.js.map
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIGuildShop_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIGuildShop_exports);
|
|
17
|
-
//# sourceMappingURL=APIGuildShop.js.map
|
|
@@ -14,4 +14,3 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
14
14
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
15
|
var APIGuildTicket_exports = {};
|
|
16
16
|
module.exports = __toCommonJS(APIGuildTicket_exports);
|
|
17
|
-
//# sourceMappingURL=APIGuildTicket.js.map
|