@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.
- package/dist/index.js +4 -27
- package/dist/managers/base.js +26 -0
- package/dist/managers/buffer/BufferManager.js +8 -2
- package/dist/managers/guild/GuildManager.js +42 -25
- package/dist/managers/index.js +23 -0
- package/dist/managers/match/GuildMatchManager.js +42 -29
- package/dist/managers/message/MessagesManager.js +48 -0
- package/dist/managers/permission/GuildPermissionManager.js +29 -52
- package/dist/managers/ticket/TicketManager.js +77 -0
- package/dist/managers/user/GuildUserManager.js +73 -85
- package/dist/managers/vipmember/VipMemberManager.js +124 -0
- package/dist/rest/REST.js +40 -21
- package/dist/rest/Routes.js +31 -17
- package/dist/rest/index.js +19 -0
- package/dist/structures/Collection.js +1 -1
- package/dist/structures/guild/Guild.js +72 -90
- package/dist/structures/index.js +22 -0
- package/dist/structures/match/GuildMatch.js +64 -111
- package/dist/structures/ticket/Ticket.js +119 -0
- package/dist/structures/user/GuildUser.js +48 -40
- package/dist/structures/vipmember/VipMember.js +137 -0
- package/dist/types/api/APIGiveaway.js +2 -0
- package/dist/types/api/APILogMessage.js +2 -0
- package/dist/types/api/APIVipMember.js +2 -0
- package/dist/types/api/index.js +36 -0
- package/dist/types/index.js +1 -20
- package/dist/utils/getRandomNumber.js +6 -0
- package/package.json +11 -18
- package/types/index.d.ts +4 -0
- package/types/managers/base.d.ts +17 -0
- package/types/managers/buffer/BufferManager.d.ts +19 -0
- package/{dist → types}/managers/guild/GuildManager.d.ts +12 -4
- package/types/managers/index.d.ts +7 -0
- package/{dist → types}/managers/match/GuildMatchManager.d.ts +10 -12
- package/types/managers/message/MessagesManager.d.ts +17 -0
- package/types/managers/permission/GuildPermissionManager.d.ts +8 -0
- package/types/managers/ticket/TicketManager.d.ts +22 -0
- package/types/managers/user/GuildUserManager.d.ts +19 -0
- package/types/managers/vipmember/VipMemberManager.d.ts +33 -0
- package/types/rest/APIEndpoints.d.ts +11 -0
- package/{dist → types}/rest/REST.d.ts +9 -16
- package/{dist → types}/rest/Routes.d.ts +18 -2
- package/types/rest/index.d.ts +3 -0
- package/{dist → types}/structures/guild/Guild.d.ts +17 -29
- package/types/structures/index.d.ts +6 -0
- package/{dist → types}/structures/match/GuildMatch.d.ts +12 -22
- package/types/structures/ticket/Ticket.d.ts +30 -0
- package/{dist → types}/structures/user/GuildUser.d.ts +5 -3
- package/types/structures/vipmember/VipMember.d.ts +54 -0
- package/types/types/RestTypes.d.ts +34 -0
- package/types/types/api/APIGiveaway.d.ts +27 -0
- package/{dist → types}/types/api/APIGuild.d.ts +9 -2
- package/{dist → types}/types/api/APIGuildMatch.d.ts +9 -7
- package/types/types/api/APIGuildTicket.d.ts +16 -0
- package/{dist → types}/types/api/APIGuildUser.d.ts +3 -1
- package/types/types/api/APILogMessage.d.ts +7 -0
- package/types/types/api/APIMessage.d.ts +11 -0
- package/{dist → types}/types/api/APIPlayer.d.ts +1 -1
- package/types/types/api/APIVipMember.d.ts +20 -0
- package/{dist → types}/types/api/index.d.ts +23 -1
- package/types/types/index.d.ts +2 -0
- package/types/utils/getRandomNumber.d.ts +1 -0
- package/dist/index.d.ts +0 -27
- package/dist/managers/bet/GuildBetManager.d.ts +0 -35
- package/dist/managers/bet/GuildBetManager.js +0 -126
- package/dist/managers/betuser/GuildBetUserManager.d.ts +0 -36
- package/dist/managers/betuser/GuildBetUserManager.js +0 -151
- package/dist/managers/buffer/BufferManager.d.ts +0 -14
- package/dist/managers/channel/ChannelManager.d.ts +0 -39
- package/dist/managers/channel/ChannelManager.js +0 -148
- package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +0 -34
- package/dist/managers/groupedchannel/GroupedChannelManager.js +0 -92
- package/dist/managers/mediator/GuildMediatorManager.d.ts +0 -32
- package/dist/managers/mediator/GuildMediatorManager.js +0 -98
- package/dist/managers/messages/MessagesManager.d.ts +0 -32
- package/dist/managers/messages/MessagesManager.js +0 -89
- package/dist/managers/permission/GuildPermissionManager.d.ts +0 -26
- package/dist/managers/product/GuildProductManager.d.ts +0 -32
- package/dist/managers/product/GuildProductManager.js +0 -103
- package/dist/managers/ticket/GuildTicketManager.d.ts +0 -32
- package/dist/managers/ticket/GuildTicketManager.js +0 -100
- package/dist/managers/user/GuildUserManager.d.ts +0 -33
- package/dist/rest/APIEndpoints.d.ts +0 -11
- package/dist/structures/bet/GuildBet.d.ts +0 -87
- package/dist/structures/bet/GuildBet.js +0 -284
- package/dist/structures/betuser/GuildBetUser.d.ts +0 -85
- package/dist/structures/betuser/GuildBetUser.js +0 -211
- package/dist/structures/channel/Channel.d.ts +0 -31
- package/dist/structures/channel/Channel.js +0 -57
- package/dist/structures/groupedchannel/GroupedChannel.d.ts +0 -34
- package/dist/structures/groupedchannel/GroupedChannel.js +0 -121
- package/dist/structures/mediator/GuildMediator.d.ts +0 -41
- package/dist/structures/mediator/GuildMediator.js +0 -131
- package/dist/structures/product/GuildProduct.d.ts +0 -52
- package/dist/structures/product/GuildProduct.js +0 -175
- package/dist/structures/shop/GuildShop.d.ts +0 -34
- package/dist/structures/shop/GuildShop.js +0 -80
- package/dist/structures/ticket/GuildTicket.d.ts +0 -52
- package/dist/structures/ticket/GuildTicket.js +0 -172
- package/dist/types/api/APIGuildTicket.d.ts +0 -26
- package/dist/types/api/APIMessage.d.ts +0 -12
- package/dist/types/index.d.ts +0 -21
- /package/dist/types/{api/APIGuildMessage.js → RestTypes.js} +0 -0
- /package/{dist → types}/structures/Collection.d.ts +0 -0
- /package/{dist → types}/types/api/APIBaseChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIBetChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIBetMessage.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildBet.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildBetUser.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildEmoji.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildGroupedChannel.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildMediator.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildMessage.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildPermissions.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildRole.d.ts +0 -0
- /package/{dist → types}/types/api/APIGuildShop.d.ts +0 -0
- /package/{dist → types}/types/api/APIProduct.d.ts +0 -0
- /package/{dist → types}/utils/Assertion.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -14,30 +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("./managers
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
__exportStar(require("./
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./managers/guild/GuildManager"), exports);
|
|
22
|
-
__exportStar(require("./managers/match/GuildMatchManager"), exports);
|
|
23
|
-
__exportStar(require("./managers/mediator/GuildMediatorManager"), exports);
|
|
24
|
-
__exportStar(require("./managers/messages/MessagesManager"), exports);
|
|
25
|
-
__exportStar(require("./managers/permission/GuildPermissionManager"), exports);
|
|
26
|
-
__exportStar(require("./managers/product/GuildProductManager"), exports);
|
|
27
|
-
__exportStar(require("./managers/ticket/GuildTicketManager"), exports);
|
|
28
|
-
__exportStar(require("./managers/user/GuildUserManager"), exports);
|
|
29
|
-
__exportStar(require("./structures/bet/GuildBet"), exports);
|
|
30
|
-
__exportStar(require("./structures/betuser/GuildBetUser"), exports);
|
|
31
|
-
__exportStar(require("./structures/channel/Channel"), exports);
|
|
32
|
-
__exportStar(require("./structures/groupedchannel/GroupedChannel"), exports);
|
|
33
|
-
__exportStar(require("./structures/guild/Guild"), exports);
|
|
34
|
-
__exportStar(require("./structures/match/GuildMatch"), exports);
|
|
35
|
-
__exportStar(require("./structures/mediator/GuildMediator"), exports);
|
|
36
|
-
__exportStar(require("./structures/product/GuildProduct"), exports);
|
|
37
|
-
__exportStar(require("./structures/shop/GuildShop"), exports);
|
|
38
|
-
__exportStar(require("./structures/ticket/GuildTicket"), exports);
|
|
39
|
-
__exportStar(require("./structures/user/GuildUser"), exports);
|
|
40
|
-
__exportStar(require("./structures/Collection"), exports);
|
|
41
|
-
__exportStar(require("./rest/REST"), exports);
|
|
42
|
-
__exportStar(require("./rest/Routes"), exports);
|
|
43
|
-
__exportStar(require("./types/index"), exports);
|
|
17
|
+
__exportStar(require("./managers"), exports);
|
|
18
|
+
__exportStar(require("./structures"), exports);
|
|
19
|
+
__exportStar(require("./rest"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseManager = void 0;
|
|
4
|
+
const Collection_1 = require("../structures/Collection");
|
|
5
|
+
class BaseManager {
|
|
6
|
+
/** This url of the manager */
|
|
7
|
+
base_url;
|
|
8
|
+
/** The rest client */
|
|
9
|
+
rest;
|
|
10
|
+
/** The guild of the manager */
|
|
11
|
+
guild;
|
|
12
|
+
/** Cache */
|
|
13
|
+
cache;
|
|
14
|
+
/** Internal data when manager is initialized */
|
|
15
|
+
_data;
|
|
16
|
+
constructor(guild, data) {
|
|
17
|
+
this.guild = guild;
|
|
18
|
+
this.rest = guild.rest;
|
|
19
|
+
this.cache = new Collection_1.Collection();
|
|
20
|
+
this._data = data;
|
|
21
|
+
}
|
|
22
|
+
get data() {
|
|
23
|
+
return this._data;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.BaseManager = BaseManager;
|
|
@@ -16,17 +16,23 @@ class BufferManager {
|
|
|
16
16
|
const { rest } = this.guild;
|
|
17
17
|
const cache = this[key];
|
|
18
18
|
const { size, clear } = cache;
|
|
19
|
-
if (size >=
|
|
19
|
+
if (size >= 2) {
|
|
20
20
|
const response = await rest.request({
|
|
21
21
|
method: "POST",
|
|
22
22
|
url: Routes_1.Routes.guilds.resources(this.guild.id, key, "bulk"),
|
|
23
23
|
payload: { [key]: this[key].toArray() },
|
|
24
24
|
});
|
|
25
|
-
this.guild[key].
|
|
25
|
+
this.guild[key].set(response);
|
|
26
26
|
clear();
|
|
27
27
|
return response;
|
|
28
28
|
}
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
+
createMatch(id, data) {
|
|
32
|
+
this.matches.set(id, data);
|
|
33
|
+
}
|
|
34
|
+
createTicket(id, data) {
|
|
35
|
+
this.tickets.set(id, data);
|
|
36
|
+
}
|
|
31
37
|
}
|
|
32
38
|
exports.BufferManager = BufferManager;
|
|
@@ -24,17 +24,19 @@ class GuildManager {
|
|
|
24
24
|
* @param id Id of the guild to fetch
|
|
25
25
|
* @returns APIGuild
|
|
26
26
|
*/
|
|
27
|
-
async fetch(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
async fetch(options) {
|
|
28
|
+
if (options && options.cache)
|
|
29
|
+
return this.cache;
|
|
30
|
+
if (options && options.guildId) {
|
|
31
|
+
const route = Routes_1.Routes.guilds.get(options.guildId);
|
|
32
|
+
const response = await this.rest.request({
|
|
33
|
+
method: "get",
|
|
34
|
+
url: route,
|
|
35
|
+
});
|
|
36
|
+
const guild = new Guild_1.Guild(response, this.rest);
|
|
37
|
+
this.cache.set(guild.id, guild);
|
|
38
|
+
return guild;
|
|
39
|
+
}
|
|
38
40
|
const route = Routes_1.Routes.guilds.getAll();
|
|
39
41
|
const response = await this.rest.request({
|
|
40
42
|
method: "get",
|
|
@@ -45,23 +47,22 @@ class GuildManager {
|
|
|
45
47
|
continue;
|
|
46
48
|
const guild = new Guild_1.Guild(guildData, this.rest);
|
|
47
49
|
this.cache.set(guild.id, guild);
|
|
48
|
-
this.rest.guilds.cache.set(guild.id, guild);
|
|
49
50
|
}
|
|
50
51
|
return this.cache;
|
|
51
52
|
}
|
|
52
|
-
async delete(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
async delete(options) {
|
|
54
|
+
if (options && options.guildId) {
|
|
55
|
+
Assertion_1.Assertion.assertString(options.guildId);
|
|
56
|
+
const route = Routes_1.Routes.guilds.delete(options.guildId);
|
|
57
|
+
const guild = this.cache.get(options.guildId);
|
|
58
|
+
this.rest.emit("guildDelete", guild);
|
|
59
|
+
await this.rest.request({
|
|
60
|
+
method: "DELETE",
|
|
61
|
+
url: route,
|
|
62
|
+
});
|
|
63
|
+
this.cache.delete(options.guildId);
|
|
64
|
+
return this.cache;
|
|
65
|
+
}
|
|
65
66
|
const route = Routes_1.Routes.guilds.deleteAll();
|
|
66
67
|
this.rest.emit("guildsDelete", this.cache);
|
|
67
68
|
const value = await this.rest.request({
|
|
@@ -71,5 +72,21 @@ class GuildManager {
|
|
|
71
72
|
this.cache.clear();
|
|
72
73
|
return value;
|
|
73
74
|
}
|
|
75
|
+
set(data) {
|
|
76
|
+
if (!data)
|
|
77
|
+
return this.cache;
|
|
78
|
+
if (Array.isArray(data)) {
|
|
79
|
+
for (let _guild of data) {
|
|
80
|
+
const guild = new Guild_1.Guild(_guild, this.rest);
|
|
81
|
+
this.cache.set(guild.id, guild);
|
|
82
|
+
}
|
|
83
|
+
return this.cache;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
const guild = new Guild_1.Guild(data, this.rest);
|
|
87
|
+
this.cache.set(guild.id, guild);
|
|
88
|
+
return guild;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
74
91
|
}
|
|
75
92
|
exports.GuildManager = GuildManager;
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./buffer/BufferManager"), exports);
|
|
18
|
+
__exportStar(require("./guild/GuildManager"), exports);
|
|
19
|
+
__exportStar(require("./match/GuildMatchManager"), exports);
|
|
20
|
+
__exportStar(require("./permission/GuildPermissionManager"), exports);
|
|
21
|
+
__exportStar(require("./user/GuildUserManager"), exports);
|
|
22
|
+
__exportStar(require("./vipmember/VipMemberManager"), exports);
|
|
23
|
+
__exportStar(require("./ticket/TicketManager"), exports);
|
|
@@ -5,38 +5,51 @@ const Routes_1 = require("../../rest/Routes");
|
|
|
5
5
|
const GuildMatch_1 = require("../../structures/match/GuildMatch");
|
|
6
6
|
const Collection_1 = require("../../structures/Collection");
|
|
7
7
|
const Assertion_1 = require("../../utils/Assertion");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
cache;
|
|
11
|
-
/** The rest client */
|
|
12
|
-
rest;
|
|
13
|
-
/** GuildMatch match guild */
|
|
14
|
-
guild;
|
|
8
|
+
const base_1 = require("../base");
|
|
9
|
+
class GuildMatchManager extends base_1.BaseManager {
|
|
15
10
|
/**
|
|
16
11
|
* Manage users with the given client
|
|
17
12
|
* @param users An array of users
|
|
18
13
|
* @param rest The rest client
|
|
19
14
|
*/
|
|
20
|
-
constructor(guild
|
|
15
|
+
constructor(guild) {
|
|
16
|
+
super(guild, guild.rest);
|
|
21
17
|
this.guild = guild;
|
|
18
|
+
this.rest = guild.rest;
|
|
19
|
+
this.base_url = Routes_1.Routes.guilds.resource(guild.id, "matches");
|
|
22
20
|
this.cache = new Collection_1.Collection("matches");
|
|
23
|
-
this.rest = rest;
|
|
24
21
|
}
|
|
25
22
|
/**
|
|
26
23
|
* Fetch a match
|
|
27
24
|
* @param id Id of the match to fetch
|
|
28
25
|
* @returns APIBetUser
|
|
29
26
|
*/
|
|
30
|
-
async fetch(
|
|
31
|
-
|
|
27
|
+
async fetch(options) {
|
|
28
|
+
if (options && options.cache)
|
|
29
|
+
return this.cache;
|
|
30
|
+
if (options && options.matchId) {
|
|
31
|
+
const route = Routes_1.Routes.guilds.matches.get(this.guild.id, options.matchId);
|
|
32
|
+
const response = await this.rest.request({
|
|
33
|
+
method: "get",
|
|
34
|
+
url: route,
|
|
35
|
+
});
|
|
36
|
+
return this.set(response);
|
|
37
|
+
}
|
|
38
|
+
const route = Routes_1.Routes.guilds.matches.getAll(this.guild.id);
|
|
32
39
|
const response = await this.rest.request({
|
|
33
40
|
method: "get",
|
|
34
41
|
url: route,
|
|
35
42
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
if (!response)
|
|
44
|
+
return this.cache;
|
|
45
|
+
const coll = new Collection_1.Collection();
|
|
46
|
+
for (let match of response ?? []) {
|
|
47
|
+
const guildMatch = new GuildMatch_1.GuildMatch(match, this);
|
|
48
|
+
coll.set(match._id, guildMatch);
|
|
49
|
+
this.rest.matches.set(match._id, guildMatch);
|
|
50
|
+
}
|
|
51
|
+
this.cache = coll;
|
|
52
|
+
return coll;
|
|
40
53
|
}
|
|
41
54
|
async fetchAll() {
|
|
42
55
|
const route = Routes_1.Routes.guilds.matches.getAll(this.guild.id);
|
|
@@ -48,23 +61,24 @@ class GuildMatchManager {
|
|
|
48
61
|
this.cache.clear();
|
|
49
62
|
return this.cache;
|
|
50
63
|
}
|
|
51
|
-
this.
|
|
64
|
+
this.set(response);
|
|
52
65
|
return this.cache;
|
|
53
66
|
}
|
|
54
67
|
set(data) {
|
|
55
|
-
if (!data?._id)
|
|
56
|
-
return;
|
|
57
|
-
const match = new GuildMatch_1.GuildMatch(data, this?.guild, this, this.rest);
|
|
58
|
-
this.cache.set(data?._id, match);
|
|
59
|
-
this.rest.matches.set(data?._id, match);
|
|
60
|
-
return match;
|
|
61
|
-
}
|
|
62
|
-
setAll(data) {
|
|
63
68
|
if (!data)
|
|
64
69
|
return this.cache;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
70
|
+
if (Array.isArray(data)) {
|
|
71
|
+
for (let _match of data) {
|
|
72
|
+
const match = new GuildMatch_1.GuildMatch(_match, this);
|
|
73
|
+
this.cache.set(match._id, match);
|
|
74
|
+
}
|
|
75
|
+
return this.cache;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
const match = new GuildMatch_1.GuildMatch(data, this);
|
|
79
|
+
this.cache.set(match._id, match);
|
|
80
|
+
return match;
|
|
81
|
+
}
|
|
68
82
|
}
|
|
69
83
|
async create(payload) {
|
|
70
84
|
Assertion_1.Assertion.assertObject(payload);
|
|
@@ -74,8 +88,7 @@ class GuildMatchManager {
|
|
|
74
88
|
url: route,
|
|
75
89
|
payload,
|
|
76
90
|
});
|
|
77
|
-
|
|
78
|
-
return match;
|
|
91
|
+
return this.set(response);
|
|
79
92
|
}
|
|
80
93
|
async delete(id) {
|
|
81
94
|
Assertion_1.Assertion.assertString(id);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessagesManager = void 0;
|
|
4
|
+
const Collection_1 = require("../../structures/Collection");
|
|
5
|
+
class MessagesManager {
|
|
6
|
+
cache;
|
|
7
|
+
base_url;
|
|
8
|
+
rest;
|
|
9
|
+
constructor(structure, base_url) {
|
|
10
|
+
this.rest = structure.rest;
|
|
11
|
+
this.cache = new Collection_1.Collection();
|
|
12
|
+
this.base_url = base_url;
|
|
13
|
+
}
|
|
14
|
+
async fetch() {
|
|
15
|
+
const response = await this.rest.request({
|
|
16
|
+
method: "GET",
|
|
17
|
+
url: this.base_url,
|
|
18
|
+
payload: {},
|
|
19
|
+
});
|
|
20
|
+
this.cache.set(response._id, response);
|
|
21
|
+
return response;
|
|
22
|
+
}
|
|
23
|
+
async create(data) {
|
|
24
|
+
const messages = [...this.cache.toArray()];
|
|
25
|
+
if (Array.isArray(data))
|
|
26
|
+
messages.push(...data);
|
|
27
|
+
else
|
|
28
|
+
messages.push(data);
|
|
29
|
+
const response = await this.rest.request({
|
|
30
|
+
method: "POST",
|
|
31
|
+
url: this.base_url,
|
|
32
|
+
payload: { messages },
|
|
33
|
+
});
|
|
34
|
+
for (let message of response)
|
|
35
|
+
this.cache.set(message._id, message);
|
|
36
|
+
return response;
|
|
37
|
+
}
|
|
38
|
+
setAll(data) {
|
|
39
|
+
if (Array.isArray(data)) {
|
|
40
|
+
for (let message of data)
|
|
41
|
+
this.cache.set(message._id, message);
|
|
42
|
+
}
|
|
43
|
+
else
|
|
44
|
+
this.cache.set(data._id, data);
|
|
45
|
+
return this.cache;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.MessagesManager = MessagesManager;
|
|
@@ -2,69 +2,46 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GuildPermissionManager = void 0;
|
|
4
4
|
const Routes_1 = require("../../rest/Routes");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
guild;
|
|
10
|
-
permissions;
|
|
11
|
-
/**
|
|
12
|
-
* Manage users with the given client
|
|
13
|
-
* @param users An array of users
|
|
14
|
-
* @param rest The rest client
|
|
15
|
-
*/
|
|
16
|
-
constructor(guild, rest) {
|
|
5
|
+
const base_1 = require("../base");
|
|
6
|
+
class GuildPermissionManager extends base_1.BaseManager {
|
|
7
|
+
constructor(guild) {
|
|
8
|
+
super(guild, guild.permissions);
|
|
17
9
|
this.guild = guild;
|
|
18
|
-
this.rest = rest;
|
|
10
|
+
this.rest = guild.rest;
|
|
11
|
+
this.base_url = Routes_1.Routes.guilds.resource(guild.id, "permissions");
|
|
19
12
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
13
|
+
async addRole(permissionId, roleId) {
|
|
14
|
+
const perm = this.guild.permissions[permissionId];
|
|
15
|
+
if (perm.includes(roleId))
|
|
16
|
+
return this.guild;
|
|
17
|
+
perm.push(roleId);
|
|
18
|
+
const perms = { ...this.guild.permissions, perm };
|
|
19
|
+
const payload = { set: perms };
|
|
27
20
|
const response = await this.rest.request({
|
|
28
|
-
method: "
|
|
29
|
-
url:
|
|
30
|
-
});
|
|
31
|
-
this.setAll(response);
|
|
32
|
-
}
|
|
33
|
-
async addId(permissionId, roleId) {
|
|
34
|
-
const route = Routes_1.Routes.guilds.resources(this.guild.id, "permissions", permissionId, "ids");
|
|
35
|
-
const payload = { id: roleId };
|
|
36
|
-
const response = await this.rest.request({
|
|
37
|
-
method: "post",
|
|
38
|
-
url: route,
|
|
21
|
+
method: "PATCH",
|
|
22
|
+
url: this.base_url,
|
|
39
23
|
payload,
|
|
40
24
|
});
|
|
41
|
-
this.permissions
|
|
25
|
+
this.guild.permissions = response.permissions;
|
|
26
|
+
this.rest.guilds.cache.set(this.guild.id, this.guild);
|
|
42
27
|
return response;
|
|
43
28
|
}
|
|
44
|
-
async
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
async removeRole(permissionId, roleId) {
|
|
30
|
+
let perm = this.guild.permissions[permissionId];
|
|
31
|
+
if (!perm.includes(roleId))
|
|
32
|
+
return this.guild;
|
|
33
|
+
perm = perm.filter((i) => i !== roleId);
|
|
34
|
+
let perms = { ...this.guild.permissions };
|
|
35
|
+
perms[permissionId] = perm;
|
|
36
|
+
const payload = { set: perms };
|
|
47
37
|
const response = await this.rest.request({
|
|
48
|
-
method: "
|
|
49
|
-
url:
|
|
38
|
+
method: "PATCH",
|
|
39
|
+
url: this.base_url,
|
|
50
40
|
payload,
|
|
51
41
|
});
|
|
52
|
-
this.permissions
|
|
42
|
+
this.guild.permissions = response.permissions;
|
|
43
|
+
this.rest.guilds.cache.set(this.guild.id, this.guild);
|
|
53
44
|
return response;
|
|
54
45
|
}
|
|
55
|
-
setAll(data) {
|
|
56
|
-
if (!data)
|
|
57
|
-
return this.permissions;
|
|
58
|
-
this.permissions = data;
|
|
59
|
-
}
|
|
60
|
-
toJSON() {
|
|
61
|
-
const json = {};
|
|
62
|
-
for (const [key, value] of Object.entries(this)) {
|
|
63
|
-
if (typeof value !== "function") {
|
|
64
|
-
json[key] = value;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return json;
|
|
68
|
-
}
|
|
69
46
|
}
|
|
70
47
|
exports.GuildPermissionManager = GuildPermissionManager;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TicketManager = void 0;
|
|
4
|
+
const rest_1 = require("../../rest");
|
|
5
|
+
const structures_1 = require("../../structures");
|
|
6
|
+
const Collection_1 = require("../../structures/Collection");
|
|
7
|
+
class TicketManager {
|
|
8
|
+
cache;
|
|
9
|
+
guild;
|
|
10
|
+
rest;
|
|
11
|
+
constructor(guild) {
|
|
12
|
+
this.guild = guild;
|
|
13
|
+
this.rest = guild.rest;
|
|
14
|
+
this.cache = new Collection_1.Collection("tickets");
|
|
15
|
+
}
|
|
16
|
+
async fetch(options) {
|
|
17
|
+
if (options && options.cache)
|
|
18
|
+
return this.cache;
|
|
19
|
+
if (options && options.ticketId) {
|
|
20
|
+
const route = rest_1.Routes.guilds.tickets.get(this.guild.id, options.ticketId);
|
|
21
|
+
const response = await this.rest.request({
|
|
22
|
+
method: "GET",
|
|
23
|
+
url: route,
|
|
24
|
+
});
|
|
25
|
+
return this.set(response);
|
|
26
|
+
}
|
|
27
|
+
const route = rest_1.Routes.guilds.tickets.getAll(this.guild.id);
|
|
28
|
+
const response = await this.rest.request({
|
|
29
|
+
method: "GET",
|
|
30
|
+
url: route,
|
|
31
|
+
});
|
|
32
|
+
return this.set(response);
|
|
33
|
+
}
|
|
34
|
+
async create(data) {
|
|
35
|
+
const route = rest_1.Routes.guilds.tickets.create(this.guild.id);
|
|
36
|
+
const response = await this.rest.request({
|
|
37
|
+
method: "POST",
|
|
38
|
+
url: route,
|
|
39
|
+
payload: data,
|
|
40
|
+
});
|
|
41
|
+
return this.set(response);
|
|
42
|
+
}
|
|
43
|
+
async delete(options) {
|
|
44
|
+
if (options && options.ticketId) {
|
|
45
|
+
const route = rest_1.Routes.guilds.tickets.delete(this.guild.id, options.ticketId);
|
|
46
|
+
await this.rest.request({
|
|
47
|
+
method: "DELETE",
|
|
48
|
+
url: route,
|
|
49
|
+
});
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
const route = rest_1.Routes.guilds.tickets.deleteAll(this.guild.id);
|
|
53
|
+
await this.rest.request({
|
|
54
|
+
method: "DELETE",
|
|
55
|
+
url: route,
|
|
56
|
+
});
|
|
57
|
+
this.cache.clear();
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
set(data) {
|
|
61
|
+
if (!data)
|
|
62
|
+
return this.cache;
|
|
63
|
+
if (Array.isArray(data)) {
|
|
64
|
+
for (let _ticket of data) {
|
|
65
|
+
const ticket = new structures_1.GuildTicket(_ticket, this);
|
|
66
|
+
this.cache.set(ticket._id, ticket);
|
|
67
|
+
}
|
|
68
|
+
return this.cache;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const ticket = new structures_1.GuildTicket(data, this);
|
|
72
|
+
this.cache.set(ticket._id, ticket);
|
|
73
|
+
return ticket;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.TicketManager = TicketManager;
|