@duque.edits/sdk 1.0.1 → 1.0.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/dist/managers/bet/GuildBetManager.js +56 -0
- package/dist/managers/betuser/GuildBetUserManager.js +1 -5
- package/dist/managers/guild/GuildManager.js +3 -0
- package/dist/managers/index.js +1 -0
- package/dist/managers/ticket/TicketManager.js +12 -1
- package/dist/rest/REST.js +11 -2
- package/dist/rest/Routes.js +1 -1
- package/dist/structures/bet/GuildBet.js +137 -0
- package/dist/structures/betuser/GuildBetUser.js +0 -1
- package/dist/structures/guild/Guild.js +16 -30
- package/dist/structures/index.js +1 -0
- package/dist/structures/logentry/LogEntry.js +1 -1
- package/dist/structures/match/GuildMatch.js +1 -3
- package/dist/types/api/APIGuild.js +21 -1
- package/package.json +1 -1
- package/types/managers/bet/GuildBetManager.d.ts +14 -0
- package/types/managers/index.d.ts +1 -0
- package/types/rest/REST.d.ts +6 -0
- package/types/structures/bet/GuildBet.d.ts +51 -0
- package/types/structures/guild/Guild.d.ts +5 -4
- package/types/structures/index.d.ts +1 -0
- package/types/types/RestTypes.d.ts +8 -1
- package/types/types/api/APIGuild.d.ts +22 -5
- package/types/types/api/APIGuildBet.d.ts +4 -13
- package/types/types/api/APIGuildBetUser.d.ts +0 -2
- package/types/types/api/APIMessage.d.ts +1 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildBetManager = void 0;
|
|
4
|
+
const rest_1 = require("../../rest");
|
|
5
|
+
const structures_1 = require("../../structures");
|
|
6
|
+
const base_1 = require("../base");
|
|
7
|
+
class GuildBetManager extends base_1.BaseManager {
|
|
8
|
+
constructor(guild) {
|
|
9
|
+
super(guild);
|
|
10
|
+
this.guild = guild;
|
|
11
|
+
this.rest = guild.rest;
|
|
12
|
+
this.base_url = rest_1.Routes.guilds.bets.getAll(guild.id);
|
|
13
|
+
this.cache = new structures_1.Collection("bets");
|
|
14
|
+
}
|
|
15
|
+
toString() {
|
|
16
|
+
return this.cache.size;
|
|
17
|
+
}
|
|
18
|
+
async fetch(options) {
|
|
19
|
+
const route = this.base_url;
|
|
20
|
+
if (options && options.cache)
|
|
21
|
+
return this.cache;
|
|
22
|
+
if (options && options.betId) {
|
|
23
|
+
const response = await this.rest.request({ url: `${route}/${options.betId}`, method: "GET" });
|
|
24
|
+
return this.set(response);
|
|
25
|
+
}
|
|
26
|
+
const response = await this.rest.request({ url: route, method: "GET" });
|
|
27
|
+
return this.set(response);
|
|
28
|
+
}
|
|
29
|
+
async delete(betId) {
|
|
30
|
+
const route = rest_1.Routes.fields(this.base_url, betId);
|
|
31
|
+
const response = await this.rest.request({ url: route, method: "DELETE" });
|
|
32
|
+
return this.set(response);
|
|
33
|
+
}
|
|
34
|
+
set(data) {
|
|
35
|
+
if (!data)
|
|
36
|
+
return;
|
|
37
|
+
if (Array.isArray(data)) {
|
|
38
|
+
for (let _bet of data) {
|
|
39
|
+
if (!_bet._id)
|
|
40
|
+
continue;
|
|
41
|
+
const bet = new structures_1.GuildBet(_bet, this);
|
|
42
|
+
this.cache.set(bet._id, bet);
|
|
43
|
+
this.rest.bets.set(bet._id, bet);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
if (!data._id)
|
|
48
|
+
return;
|
|
49
|
+
const bet = new structures_1.GuildBet(data, this);
|
|
50
|
+
this.cache.set(bet._id, bet);
|
|
51
|
+
this.rest.bets.set(bet._id, bet);
|
|
52
|
+
return bet;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.GuildBetManager = GuildBetManager;
|
|
@@ -41,11 +41,7 @@ class GuildBetUserManager extends base_1.BaseManager {
|
|
|
41
41
|
url: route,
|
|
42
42
|
payload: { betusers },
|
|
43
43
|
});
|
|
44
|
-
|
|
45
|
-
const user = new GuildBetUser_1.GuildBetUser(userData, this);
|
|
46
|
-
this.set(user);
|
|
47
|
-
}
|
|
48
|
-
return this.cache;
|
|
44
|
+
return this.set(response);
|
|
49
45
|
}
|
|
50
46
|
async deleteAll() {
|
|
51
47
|
const route = this.base_url;
|
package/dist/managers/index.js
CHANGED
|
@@ -14,6 +14,7 @@ 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("./bet/GuildBetManager"), exports);
|
|
17
18
|
__exportStar(require("./betuser/GuildBetUserManager"), exports);
|
|
18
19
|
__exportStar(require("./buffer/BufferManager"), exports);
|
|
19
20
|
__exportStar(require("./guild/GuildManager"), exports);
|
|
@@ -75,7 +75,9 @@ class GuildTicketManager {
|
|
|
75
75
|
url: route,
|
|
76
76
|
payload: data,
|
|
77
77
|
});
|
|
78
|
-
|
|
78
|
+
const ticket = this.set(response);
|
|
79
|
+
this.rest.emit("ticketCreate", ticket);
|
|
80
|
+
return ticket;
|
|
79
81
|
}
|
|
80
82
|
async delete(options) {
|
|
81
83
|
if (options && options.ticketId) {
|
|
@@ -84,6 +86,8 @@ class GuildTicketManager {
|
|
|
84
86
|
method: "DELETE",
|
|
85
87
|
url: route,
|
|
86
88
|
});
|
|
89
|
+
this.rest.emit("ticketDelete", this.cache.get(options.ticketId));
|
|
90
|
+
this.cache.delete(options.ticketId);
|
|
87
91
|
return true;
|
|
88
92
|
}
|
|
89
93
|
const route = rest_1.Routes.guilds.tickets.deleteAll(this.guild.id);
|
|
@@ -91,6 +95,7 @@ class GuildTicketManager {
|
|
|
91
95
|
method: "DELETE",
|
|
92
96
|
url: route,
|
|
93
97
|
});
|
|
98
|
+
this.rest.emit("ticketsDelete", this.cache);
|
|
94
99
|
this.cache.clear();
|
|
95
100
|
return true;
|
|
96
101
|
}
|
|
@@ -99,14 +104,20 @@ class GuildTicketManager {
|
|
|
99
104
|
return this.cache;
|
|
100
105
|
if (Array.isArray(data)) {
|
|
101
106
|
for (let _ticket of data) {
|
|
107
|
+
if (!_ticket._id)
|
|
108
|
+
return;
|
|
102
109
|
const ticket = new structures_1.GuildTicket(_ticket, this);
|
|
103
110
|
this.cache.set(ticket._id, ticket);
|
|
111
|
+
this.rest.tickets.set(ticket._id, ticket);
|
|
104
112
|
}
|
|
105
113
|
return this.cache;
|
|
106
114
|
}
|
|
107
115
|
else {
|
|
116
|
+
if (data._id)
|
|
117
|
+
return;
|
|
108
118
|
const ticket = new structures_1.GuildTicket(data, this);
|
|
109
119
|
this.cache.set(ticket._id, ticket);
|
|
120
|
+
this.rest.tickets.set(ticket._id, ticket);
|
|
110
121
|
return ticket;
|
|
111
122
|
}
|
|
112
123
|
}
|
package/dist/rest/REST.js
CHANGED
|
@@ -27,12 +27,16 @@ class REST extends events_1.default {
|
|
|
27
27
|
*/
|
|
28
28
|
clientKey;
|
|
29
29
|
authKey;
|
|
30
|
+
guildId;
|
|
30
31
|
/** The guild manager */
|
|
31
32
|
guilds;
|
|
32
33
|
minesGames;
|
|
33
34
|
users;
|
|
34
35
|
betusers;
|
|
35
36
|
matches;
|
|
37
|
+
bets;
|
|
38
|
+
tickets;
|
|
39
|
+
vipmembers;
|
|
36
40
|
/**
|
|
37
41
|
*
|
|
38
42
|
* @param key The unique key for he client
|
|
@@ -41,17 +45,22 @@ class REST extends events_1.default {
|
|
|
41
45
|
super({ captureRejections: true });
|
|
42
46
|
this.clientKey = options.clientKey ?? "";
|
|
43
47
|
this.authKey = options.authKey ?? "";
|
|
48
|
+
this.guildId = options.guildId ?? "";
|
|
44
49
|
this.guilds = new GuildManager_1.GuildManager(this);
|
|
45
50
|
this.minesGames = new managers_1.MinesGameManager(this);
|
|
46
51
|
this.users = new Collection_1.Collection("rest:users");
|
|
47
52
|
this.matches = new Collection_1.Collection("rest:matches");
|
|
53
|
+
this.bets = new Collection_1.Collection("rest:bets");
|
|
54
|
+
this.betusers = new Collection_1.Collection("rest:betusers");
|
|
55
|
+
this.tickets = new Collection_1.Collection("rest:tickets");
|
|
56
|
+
this.vipmembers = new Collection_1.Collection("rest:vipmembers");
|
|
48
57
|
this.setMaxListeners(999);
|
|
49
58
|
}
|
|
50
59
|
/** Initialize the caching sistem */
|
|
51
60
|
async init() {
|
|
52
|
-
if (!this.clientKey || !this.authKey)
|
|
61
|
+
if (!this.clientKey || !this.authKey || !this.guildId)
|
|
53
62
|
throw new Error("Key is necessary");
|
|
54
|
-
await Promise.all([this.guilds.fetch(), this.minesGames.fetch()]);
|
|
63
|
+
await Promise.all([this.guilds.fetch({ guildId: this.guildId }), this.minesGames.fetch()]);
|
|
55
64
|
return this;
|
|
56
65
|
}
|
|
57
66
|
/**
|
package/dist/rest/Routes.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Routes = void 0;
|
|
4
4
|
exports.Routes = {
|
|
5
5
|
//base: "http://localhost:80/api/v1",
|
|
6
|
-
base: "https://
|
|
6
|
+
base: "https://duque-api.up.railway.app/api/v1",
|
|
7
7
|
field: (field) => `/${field}`,
|
|
8
8
|
fields: (...fields) => `${fields.join("/")}`,
|
|
9
9
|
guilds: {
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildBet = void 0;
|
|
4
|
+
const rest_1 = require("../../rest");
|
|
5
|
+
class GuildBet {
|
|
6
|
+
/** The bet's type */
|
|
7
|
+
type;
|
|
8
|
+
/** The bet's mode */
|
|
9
|
+
mode;
|
|
10
|
+
/** The bet's status */
|
|
11
|
+
status;
|
|
12
|
+
/** The bet's maximum size */
|
|
13
|
+
maximumSize;
|
|
14
|
+
/** The bet's price */
|
|
15
|
+
price;
|
|
16
|
+
/** The bet's players */
|
|
17
|
+
players;
|
|
18
|
+
teams;
|
|
19
|
+
/** The bet's channel */
|
|
20
|
+
channels;
|
|
21
|
+
/** The bet's messages */
|
|
22
|
+
messages;
|
|
23
|
+
/** The id of the winner */
|
|
24
|
+
winners;
|
|
25
|
+
/** The id of the loser */
|
|
26
|
+
losers;
|
|
27
|
+
/** The bet's creator id */
|
|
28
|
+
creatorId;
|
|
29
|
+
/** The bet's mediator */
|
|
30
|
+
mediatorId;
|
|
31
|
+
/** The bet's confirmers */
|
|
32
|
+
confirmed;
|
|
33
|
+
/** Creation Date */
|
|
34
|
+
createdAt;
|
|
35
|
+
/** Updated Date */
|
|
36
|
+
updatedAt;
|
|
37
|
+
/** Bet's id */
|
|
38
|
+
_id;
|
|
39
|
+
rest;
|
|
40
|
+
guild;
|
|
41
|
+
manager;
|
|
42
|
+
constructor(data, manager) {
|
|
43
|
+
this.manager = manager;
|
|
44
|
+
this.guild = manager.guild;
|
|
45
|
+
this.rest = manager.rest;
|
|
46
|
+
this._id = data?._id;
|
|
47
|
+
this.type = data?.type;
|
|
48
|
+
this.mode = data?.mode;
|
|
49
|
+
this.status = data?.status;
|
|
50
|
+
this.maximumSize = data?.maximumSize;
|
|
51
|
+
this.price = data?.price;
|
|
52
|
+
this.players = data?.players;
|
|
53
|
+
this.teams = data?.teams;
|
|
54
|
+
this.channels = data?.channels;
|
|
55
|
+
this.messages = data?.messages;
|
|
56
|
+
this.winners = data?.winners;
|
|
57
|
+
this.losers = data?.losers;
|
|
58
|
+
this.creatorId = data?.creatorId;
|
|
59
|
+
this.mediatorId = data?.mediatorId;
|
|
60
|
+
this.confirmed = data?.confirmed;
|
|
61
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
62
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
63
|
+
}
|
|
64
|
+
toString() {
|
|
65
|
+
return this._id;
|
|
66
|
+
}
|
|
67
|
+
async fetch() {
|
|
68
|
+
const route = rest_1.Routes.guilds.bets.get(this.guild.id, this._id);
|
|
69
|
+
const response = await this.rest.request({ url: route, method: "GET" });
|
|
70
|
+
return this._updateInternals(response);
|
|
71
|
+
}
|
|
72
|
+
async addPlayer(player) {
|
|
73
|
+
const isFull = this.players.length === 2;
|
|
74
|
+
if (isFull)
|
|
75
|
+
return this;
|
|
76
|
+
const isPlayerIn = this.players.findIndex((p) => p.id === player.id);
|
|
77
|
+
if (isPlayerIn !== -1)
|
|
78
|
+
return this;
|
|
79
|
+
this.players.push(player);
|
|
80
|
+
const payload = { set: this.players };
|
|
81
|
+
const route = rest_1.Routes.guilds.bets.resource(this.guild.id, this._id, "players");
|
|
82
|
+
const response = await this.rest.request({ method: "PATCH", payload, url: route });
|
|
83
|
+
return this._updateInternals(response);
|
|
84
|
+
}
|
|
85
|
+
async removePlayer(player) {
|
|
86
|
+
const isPlayerIn = this.players.findIndex((p) => p.id === player.id);
|
|
87
|
+
if (isPlayerIn === -1)
|
|
88
|
+
return this;
|
|
89
|
+
this.players = this.players.filter((p) => p.id !== player.id);
|
|
90
|
+
const payload = { set: this.players };
|
|
91
|
+
const route = rest_1.Routes.guilds.bets.resource(this.guild.id, this._id, "players");
|
|
92
|
+
const response = await this.rest.request({ method: "PATCH", payload, url: route });
|
|
93
|
+
return this._updateInternals(response);
|
|
94
|
+
}
|
|
95
|
+
async update(data) {
|
|
96
|
+
const payload = data;
|
|
97
|
+
const route = rest_1.Routes.guilds.bets.update(this.guild.id, this._id);
|
|
98
|
+
const response = await this.rest.request({ method: "patch", url: route, payload });
|
|
99
|
+
return this._updateInternals(response);
|
|
100
|
+
}
|
|
101
|
+
async delete() {
|
|
102
|
+
const route = rest_1.Routes.guilds.bets.delete(this.manager.guild.id, this._id);
|
|
103
|
+
const response = await this.rest.request({
|
|
104
|
+
method: "DELETE",
|
|
105
|
+
url: route,
|
|
106
|
+
});
|
|
107
|
+
this.rest.emit("betDelete", this);
|
|
108
|
+
this.manager.cache.delete(this._id);
|
|
109
|
+
return response;
|
|
110
|
+
}
|
|
111
|
+
_updateInternals(data) {
|
|
112
|
+
for (let key in data) {
|
|
113
|
+
if (key === "_id" || key === "createdAt")
|
|
114
|
+
continue;
|
|
115
|
+
if (key in this) {
|
|
116
|
+
this[key] = data[key];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
this.updatedAt = new Date();
|
|
120
|
+
this.createdAt = new Date(data.createdAt);
|
|
121
|
+
this.manager.set(this);
|
|
122
|
+
return this;
|
|
123
|
+
}
|
|
124
|
+
toJSON() {
|
|
125
|
+
let json = {};
|
|
126
|
+
for (const [key, value] of Object.entries(this)) {
|
|
127
|
+
const exclude = ["rest", "guilds", "manager"];
|
|
128
|
+
if (exclude.includes(key))
|
|
129
|
+
continue;
|
|
130
|
+
if (typeof value !== "function") {
|
|
131
|
+
json[key] = value;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return json;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.GuildBet = GuildBet;
|
|
@@ -45,8 +45,10 @@ class Guild {
|
|
|
45
45
|
logEntries;
|
|
46
46
|
shop;
|
|
47
47
|
betusers;
|
|
48
|
+
bets;
|
|
48
49
|
adverts;
|
|
49
50
|
codes;
|
|
51
|
+
coin_symbol;
|
|
50
52
|
/**
|
|
51
53
|
* The guild structure
|
|
52
54
|
* @param data The guild's data
|
|
@@ -68,6 +70,7 @@ class Guild {
|
|
|
68
70
|
this.tickets_configuration = data?.tickets_configuration;
|
|
69
71
|
this.channels = data?.channels;
|
|
70
72
|
this.shop = data?.shop;
|
|
73
|
+
this.coin_symbol = data?.coin_symbol;
|
|
71
74
|
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
72
75
|
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
73
76
|
this.permissionsManager = new managers_1.GuildPermissionManager(this);
|
|
@@ -78,6 +81,7 @@ class Guild {
|
|
|
78
81
|
this.vipMembers = new managers_1.VipMemberManager(this);
|
|
79
82
|
this.logEntries = new managers_1.LogManager(this);
|
|
80
83
|
this.betusers = new GuildBetUserManager_1.GuildBetUserManager(this);
|
|
84
|
+
this.bets = new managers_1.GuildBetManager(this);
|
|
81
85
|
this.adverts = [];
|
|
82
86
|
for (let _adv of data?.adverts || []) {
|
|
83
87
|
this.adverts.push({
|
|
@@ -210,14 +214,11 @@ class Guild {
|
|
|
210
214
|
const chIndex = this.channels.findIndex((c) => c.type === type);
|
|
211
215
|
if (chIndex !== -1) {
|
|
212
216
|
const existing = this.channels[chIndex];
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
ids: updatedIds,
|
|
217
|
-
};
|
|
217
|
+
const idsToRemove = Array.isArray(id) ? id : [id];
|
|
218
|
+
existing.ids = existing.ids.filter((i) => !idsToRemove.includes(i));
|
|
219
|
+
this.channels[chIndex] = existing;
|
|
218
220
|
}
|
|
219
221
|
else {
|
|
220
|
-
// If channel doesn't exist, create it with empty ids
|
|
221
222
|
this.channels.push({
|
|
222
223
|
type,
|
|
223
224
|
ids: [],
|
|
@@ -239,7 +240,8 @@ class Guild {
|
|
|
239
240
|
this.tickets.fetch(),
|
|
240
241
|
this.vipMembers.fetch(),
|
|
241
242
|
this.logEntries.fetch(),
|
|
242
|
-
|
|
243
|
+
this.betusers.fetch(),
|
|
244
|
+
this.bets.fetch(),
|
|
243
245
|
]);
|
|
244
246
|
return this;
|
|
245
247
|
}
|
|
@@ -326,30 +328,14 @@ class Guild {
|
|
|
326
328
|
this.rest.emit("guildUpdate", this);
|
|
327
329
|
return this;
|
|
328
330
|
}
|
|
329
|
-
async
|
|
331
|
+
async togglePrice(price) {
|
|
330
332
|
Assertion_1.Assertion.assertNumber(price);
|
|
331
|
-
const
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
});
|
|
338
|
-
this._updateInternals(response);
|
|
339
|
-
return this;
|
|
340
|
-
}
|
|
341
|
-
async removePrice(price) {
|
|
342
|
-
Assertion_1.Assertion.assertNumber(price);
|
|
343
|
-
const route = Routes_1.Routes.fields(Routes_1.Routes.guilds.resource(this.id, "prices"), "used", price.toString());
|
|
344
|
-
const payload = { set: price };
|
|
345
|
-
const response = await this.rest.request({
|
|
346
|
-
method: "DELETE",
|
|
347
|
-
url: route,
|
|
348
|
-
payload,
|
|
349
|
-
});
|
|
350
|
-
this.prices.used = response;
|
|
351
|
-
this.rest.guilds.cache.set(this.id, this);
|
|
352
|
-
this.rest.emit("guildUpdate", this);
|
|
333
|
+
const includesPrice = this.prices.includes(price);
|
|
334
|
+
if (includesPrice)
|
|
335
|
+
this.prices = this.prices.filter((p) => p !== price);
|
|
336
|
+
else
|
|
337
|
+
this.prices.push(price);
|
|
338
|
+
await this.update({ prices: this.prices });
|
|
353
339
|
return this;
|
|
354
340
|
}
|
|
355
341
|
async setPrefix(prefix) {
|
package/dist/structures/index.js
CHANGED
|
@@ -14,6 +14,7 @@ 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("./bet/GuildBet"), exports);
|
|
17
18
|
__exportStar(require("./betuser/GuildBetUser"), exports);
|
|
18
19
|
__exportStar(require("./guild/Guild"), exports);
|
|
19
20
|
__exportStar(require("./logentry/LogEntry"), exports);
|
|
@@ -239,9 +239,7 @@ class GuildMatch {
|
|
|
239
239
|
}
|
|
240
240
|
}
|
|
241
241
|
this.updatedAt = new Date();
|
|
242
|
-
this.manager.
|
|
243
|
-
this.rest.matches.set(this._id, this);
|
|
244
|
-
this.guild.buffer.matches.set(this._id, this);
|
|
242
|
+
this.manager.set(this);
|
|
245
243
|
return this;
|
|
246
244
|
}
|
|
247
245
|
}
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GuildChannelsType = void 0;
|
|
3
|
+
exports.GuildChannelsType = exports.GuildStatusEnum = void 0;
|
|
4
|
+
var GuildStatusEnum;
|
|
5
|
+
(function (GuildStatusEnum) {
|
|
6
|
+
/** Matches status */
|
|
7
|
+
GuildStatusEnum["Matches"] = "matches";
|
|
8
|
+
/** Bets status */
|
|
9
|
+
GuildStatusEnum["Bets"] = "bets";
|
|
10
|
+
/** Daily Ranking status */
|
|
11
|
+
GuildStatusEnum["DailyRank"] = "daily_rank";
|
|
12
|
+
/** Voice Channels for a bet */
|
|
13
|
+
GuildStatusEnum["CreateVoiceChannels"] = "create_voice_channels";
|
|
14
|
+
GuildStatusEnum["TwoMvps"] = "two_mvps";
|
|
15
|
+
GuildStatusEnum["RankingName"] = "ranking_name";
|
|
16
|
+
GuildStatusEnum["LogsQueues"] = "logs_queues";
|
|
17
|
+
GuildStatusEnum["LogsUsers"] = "logs_users";
|
|
18
|
+
GuildStatusEnum["LogsManaging"] = "logs_managing";
|
|
19
|
+
GuildStatusEnum["NameHidden"] = "name_hidden";
|
|
20
|
+
})(GuildStatusEnum || (exports.GuildStatusEnum = GuildStatusEnum = {}));
|
|
4
21
|
var GuildChannelsType;
|
|
5
22
|
(function (GuildChannelsType) {
|
|
6
23
|
GuildChannelsType["DailyRank"] = "daily_rank";
|
|
@@ -16,4 +33,7 @@ var GuildChannelsType;
|
|
|
16
33
|
GuildChannelsType["MatchTextChannelParent"] = "match_text_channel_parent";
|
|
17
34
|
GuildChannelsType["VoiceChannelMatchCreation"] = "voice_channel_match_creation";
|
|
18
35
|
GuildChannelsType["WaitingVC"] = "waiting_vc";
|
|
36
|
+
GuildChannelsType["BetMobileCategory"] = "bet_mobile_category";
|
|
37
|
+
GuildChannelsType["BetEmulatorCategory"] = "bet_emulator_category";
|
|
38
|
+
GuildChannelsType["BetMixCategory"] = "bet_mix_category";
|
|
19
39
|
})(GuildChannelsType || (exports.GuildChannelsType = GuildChannelsType = {}));
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Collection, Guild, GuildBet } from "../../structures";
|
|
2
|
+
import { APIGuildBet, Optional } from "../../types";
|
|
3
|
+
import { BaseManager } from "../base";
|
|
4
|
+
export interface FetchOptions {
|
|
5
|
+
cache?: boolean;
|
|
6
|
+
betId?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class GuildBetManager extends BaseManager<GuildBet> {
|
|
9
|
+
constructor(guild: Guild);
|
|
10
|
+
toString(): number;
|
|
11
|
+
fetch(options?: FetchOptions): Promise<GuildBet | Collection<string, GuildBet>>;
|
|
12
|
+
delete(betId?: string): Promise<GuildBet>;
|
|
13
|
+
set(data: Optional<APIGuildBet> | Optional<APIGuildBet>[]): GuildBet;
|
|
14
|
+
}
|
package/types/rest/REST.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ import { RestEvents, RequestOptions } from "../types/RestTypes";
|
|
|
7
7
|
import { MinesGameManager } from "../managers";
|
|
8
8
|
import { StatusResponse } from "../types";
|
|
9
9
|
import { GuildBetUser } from "../structures/betuser/GuildBetUser";
|
|
10
|
+
import { GuildBet, GuildTicket, VipMember } from "../structures";
|
|
10
11
|
interface ClientOptions {
|
|
11
12
|
clientKey: string;
|
|
13
|
+
guildId: string;
|
|
12
14
|
authKey: string;
|
|
13
15
|
}
|
|
14
16
|
/**
|
|
@@ -20,12 +22,16 @@ export declare class REST extends EventEmitter {
|
|
|
20
22
|
*/
|
|
21
23
|
clientKey: string;
|
|
22
24
|
authKey: string;
|
|
25
|
+
guildId: string;
|
|
23
26
|
/** The guild manager */
|
|
24
27
|
guilds: GuildManager;
|
|
25
28
|
minesGames: MinesGameManager;
|
|
26
29
|
users: Collection<string, GuildUser>;
|
|
27
30
|
betusers: Collection<string, GuildBetUser>;
|
|
28
31
|
matches: Collection<string, GuildMatch>;
|
|
32
|
+
bets: Collection<string, GuildBet>;
|
|
33
|
+
tickets: Collection<string, GuildTicket>;
|
|
34
|
+
vipmembers: Collection<string, VipMember>;
|
|
29
35
|
/**
|
|
30
36
|
*
|
|
31
37
|
* @param key The unique key for he client
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { GuildBetManager } from "../../managers";
|
|
2
|
+
import { REST } from "../../rest";
|
|
3
|
+
import { APIBetChannel, APIGuildBet, APIMessage, APIPlayer, BaseMatchModes, Confirm, Optional } from "../../types";
|
|
4
|
+
import { Guild } from "../guild/Guild";
|
|
5
|
+
export declare class GuildBet {
|
|
6
|
+
/** The bet's type */
|
|
7
|
+
type: Omit<BaseMatchModes, "5x5" | "6x6" | "5v5" | "6v6">;
|
|
8
|
+
/** The bet's mode */
|
|
9
|
+
mode: "misto" | "emu" | "mob" | "MISTO" | "EMU" | "MOB";
|
|
10
|
+
/** The bet's status */
|
|
11
|
+
status: "off" | "created" | "on" | "shutted" | "waiting";
|
|
12
|
+
/** The bet's maximum size */
|
|
13
|
+
maximumSize: number;
|
|
14
|
+
/** The bet's price */
|
|
15
|
+
price: number;
|
|
16
|
+
/** The bet's players */
|
|
17
|
+
players: APIPlayer[];
|
|
18
|
+
teams: APIPlayer[][];
|
|
19
|
+
/** The bet's channel */
|
|
20
|
+
channels: APIBetChannel[];
|
|
21
|
+
/** The bet's messages */
|
|
22
|
+
messages: APIMessage[];
|
|
23
|
+
/** The id of the winner */
|
|
24
|
+
winners: APIPlayer[];
|
|
25
|
+
/** The id of the loser */
|
|
26
|
+
losers: APIPlayer[];
|
|
27
|
+
/** The bet's creator id */
|
|
28
|
+
creatorId: string;
|
|
29
|
+
/** The bet's mediator */
|
|
30
|
+
mediatorId: string;
|
|
31
|
+
/** The bet's confirmers */
|
|
32
|
+
confirmed: Confirm[];
|
|
33
|
+
/** Creation Date */
|
|
34
|
+
createdAt: Date;
|
|
35
|
+
/** Updated Date */
|
|
36
|
+
updatedAt: Date;
|
|
37
|
+
/** Bet's id */
|
|
38
|
+
_id: string;
|
|
39
|
+
rest: REST;
|
|
40
|
+
guild: Guild;
|
|
41
|
+
manager: GuildBetManager;
|
|
42
|
+
constructor(data: Optional<APIGuildBet>, manager: GuildBetManager);
|
|
43
|
+
toString(): string;
|
|
44
|
+
fetch(): Promise<this>;
|
|
45
|
+
addPlayer(player: APIPlayer): Promise<this>;
|
|
46
|
+
removePlayer(player: APIPlayer): Promise<this>;
|
|
47
|
+
update(data: Optional<APIGuildBet>): Promise<this>;
|
|
48
|
+
delete(): Promise<boolean>;
|
|
49
|
+
_updateInternals(data: Optional<APIGuildBet>): this;
|
|
50
|
+
toJSON(): Optional<APIGuildBet>;
|
|
51
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BufferManager, GuildMatchManager, GuildPermissionManager, GuildTicketManager, GuildUserManager, LogManager, VipMemberManager } from "../../managers";
|
|
1
|
+
import { BufferManager, GuildBetManager, GuildMatchManager, GuildPermissionManager, GuildTicketManager, GuildUserManager, LogManager, VipMemberManager } from "../../managers";
|
|
2
2
|
import { GuildBetUserManager } from "../../managers/betuser/GuildBetUserManager";
|
|
3
3
|
import { REST } from "../../rest/REST";
|
|
4
4
|
import { APICode, APIGuildAdvert, APIGuildGroupedChannel, APIGuildPermissions, APIGuildShop, Daily, GuildPermissionsTypes, Optional, Permission } from "../../types/api";
|
|
@@ -43,8 +43,10 @@ export declare class Guild {
|
|
|
43
43
|
logEntries: LogManager;
|
|
44
44
|
shop: APIGuildShop;
|
|
45
45
|
betusers: GuildBetUserManager;
|
|
46
|
+
bets: GuildBetManager;
|
|
46
47
|
adverts: APIGuildAdvert[];
|
|
47
48
|
codes: APICode[];
|
|
49
|
+
coin_symbol: string;
|
|
48
50
|
/**
|
|
49
51
|
* The guild structure
|
|
50
52
|
* @param data The guild's data
|
|
@@ -59,14 +61,13 @@ export declare class Guild {
|
|
|
59
61
|
removeCode(codeId: string): Promise<this>;
|
|
60
62
|
addIdToChannel(type: GuildChannelsType, id: string | string[]): Promise<this>;
|
|
61
63
|
setChannelIds(type: GuildChannelsType, ...ids: string[]): Promise<this>;
|
|
62
|
-
removeIdInChannel(type: GuildChannelsType, id: string): Promise<this>;
|
|
64
|
+
removeIdInChannel(type: GuildChannelsType, id: string | string[]): Promise<this>;
|
|
63
65
|
_start(): Promise<this>;
|
|
64
66
|
_updateInternals(data: Optional<APIGuild>): this;
|
|
65
67
|
fetch(): Promise<Guild>;
|
|
66
68
|
update(data: Optional<APIGuild>): Promise<Guild>;
|
|
67
69
|
setStatus(key: keyof GuildStatus, status: "on" | "off"): Promise<this>;
|
|
68
|
-
|
|
69
|
-
removePrice(price: number): Promise<this>;
|
|
70
|
+
togglePrice(price: number): Promise<this>;
|
|
70
71
|
setPrefix(prefix: string): Promise<this>;
|
|
71
72
|
toggleDailyCategory(category: keyof Omit<Daily, "date">): Promise<this>;
|
|
72
73
|
setScores(name: AvailableScores, amount: number): Promise<this>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogEntry } from "../structures";
|
|
1
|
+
import { GuildBet, GuildTicket, LogEntry } from "../structures";
|
|
2
2
|
import { GuildBetUser } from "../structures/betuser/GuildBetUser";
|
|
3
3
|
import { Collection } from "../structures/Collection";
|
|
4
4
|
import { Guild } from "../structures/guild/Guild";
|
|
@@ -23,10 +23,17 @@ export interface RestEvents {
|
|
|
23
23
|
}];
|
|
24
24
|
error: [Error];
|
|
25
25
|
debug: [string];
|
|
26
|
+
ticketCreate: [GuildTicket];
|
|
27
|
+
ticketDelete: [GuildTicket];
|
|
28
|
+
ticketsDelete: [Collection<string, GuildTicket>];
|
|
26
29
|
matchCreate: [GuildMatch];
|
|
27
30
|
matchUpdate: [GuildMatch, GuildMatch];
|
|
28
31
|
matchDelete: [GuildMatch];
|
|
29
32
|
matchesDelete: [Collection<string, GuildMatch>];
|
|
33
|
+
betCreate: [GuildBet];
|
|
34
|
+
betUpdate: [GuildBet, GuildBet];
|
|
35
|
+
betDelete: [GuildBet];
|
|
36
|
+
betsDelete: [Collection<string, GuildBet>];
|
|
30
37
|
guildUpdate: [Guild];
|
|
31
38
|
guildDelete: [Guild];
|
|
32
39
|
guildsDelete: [Collection<string, Guild>];
|
|
@@ -25,15 +25,28 @@ export interface GuildStatus {
|
|
|
25
25
|
logs_managing: "on" | "off";
|
|
26
26
|
name_hidden: "on" | "off";
|
|
27
27
|
}
|
|
28
|
+
export declare enum GuildStatusEnum {
|
|
29
|
+
/** Matches status */
|
|
30
|
+
Matches = "matches",
|
|
31
|
+
/** Bets status */
|
|
32
|
+
Bets = "bets",
|
|
33
|
+
/** Daily Ranking status */
|
|
34
|
+
DailyRank = "daily_rank",
|
|
35
|
+
/** Voice Channels for a bet */
|
|
36
|
+
CreateVoiceChannels = "create_voice_channels",
|
|
37
|
+
TwoMvps = "two_mvps",
|
|
38
|
+
RankingName = "ranking_name",
|
|
39
|
+
LogsQueues = "logs_queues",
|
|
40
|
+
LogsUsers = "logs_users",
|
|
41
|
+
LogsManaging = "logs_managing",
|
|
42
|
+
NameHidden = "name_hidden"
|
|
43
|
+
}
|
|
28
44
|
export interface GuildModes {
|
|
29
45
|
on: string[];
|
|
30
46
|
off: string[];
|
|
31
47
|
}
|
|
32
48
|
export type DailyCategories = "coins" | "credit" | "wins" | "points" | "losses" | "mvps";
|
|
33
|
-
export
|
|
34
|
-
on: number[];
|
|
35
|
-
used: number[];
|
|
36
|
-
}
|
|
49
|
+
export type GuildPrices = number[];
|
|
37
50
|
export interface GuildScores {
|
|
38
51
|
/** Win */
|
|
39
52
|
win: number;
|
|
@@ -79,6 +92,7 @@ export interface APIGuild {
|
|
|
79
92
|
adverts: APIGuildAdvert[];
|
|
80
93
|
max_advert_per_user: number;
|
|
81
94
|
codes: APICode[];
|
|
95
|
+
coin_symbol: string;
|
|
82
96
|
}
|
|
83
97
|
export declare enum GuildChannelsType {
|
|
84
98
|
DailyRank = "daily_rank",
|
|
@@ -93,5 +107,8 @@ export declare enum GuildChannelsType {
|
|
|
93
107
|
ChallengeQueue = "challenge_queue",
|
|
94
108
|
MatchTextChannelParent = "match_text_channel_parent",
|
|
95
109
|
VoiceChannelMatchCreation = "voice_channel_match_creation",
|
|
96
|
-
WaitingVC = "waiting_vc"
|
|
110
|
+
WaitingVC = "waiting_vc",
|
|
111
|
+
BetMobileCategory = "bet_mobile_category",
|
|
112
|
+
BetEmulatorCategory = "bet_emulator_category",
|
|
113
|
+
BetMixCategory = "bet_mix_category"
|
|
97
114
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseMatchModes, Confirm
|
|
1
|
+
import { BaseMatchModes, Confirm } from ".";
|
|
2
2
|
import { APIBetChannel } from "./APIBetChannel";
|
|
3
3
|
import { APIMessage } from "./APIMessage";
|
|
4
4
|
import { APIPlayer } from "./APIPlayer";
|
|
@@ -13,32 +13,23 @@ export interface APIGuildBet {
|
|
|
13
13
|
maximumSize: number;
|
|
14
14
|
/** The bet's price */
|
|
15
15
|
price: number;
|
|
16
|
-
/** Who has payed the bet */
|
|
17
|
-
payedBy: APIPlayer[];
|
|
18
16
|
/** The bet's players */
|
|
19
17
|
players: APIPlayer[];
|
|
20
|
-
|
|
21
|
-
teamA: APIPlayer[];
|
|
22
|
-
/** An array of team b */
|
|
23
|
-
teamB: APIPlayer[];
|
|
18
|
+
teams: APIPlayer[][];
|
|
24
19
|
/** The bet's channel */
|
|
25
20
|
channels: APIBetChannel[];
|
|
26
21
|
/** The bet's messages */
|
|
27
22
|
messages: APIMessage[];
|
|
28
23
|
/** The id of the winner */
|
|
29
|
-
|
|
24
|
+
winners: APIPlayer[];
|
|
30
25
|
/** The id of the loser */
|
|
31
|
-
|
|
26
|
+
losers: APIPlayer[];
|
|
32
27
|
/** The bet's creator id */
|
|
33
28
|
creatorId: string;
|
|
34
29
|
/** The bet's mediator */
|
|
35
30
|
mediatorId: string;
|
|
36
31
|
/** The bet's confirmers */
|
|
37
32
|
confirmed: Confirm[];
|
|
38
|
-
/** The bet's embed id */
|
|
39
|
-
embedMessageId: string;
|
|
40
|
-
/** The bet's logs */
|
|
41
|
-
logs: Logs;
|
|
42
33
|
/** Creation Date */
|
|
43
34
|
createdAt: Date;
|
|
44
35
|
/** Updated Date */
|