@duque.edits/sdk 0.0.4 → 0.0.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/{v1/index.ts → dist/index.d.ts} +27 -30
- package/dist/index.js +43 -0
- package/dist/managers/bet/GuildBetManager.d.ts +32 -0
- package/dist/managers/bet/GuildBetManager.js +107 -0
- package/dist/managers/betuser/GuildBetUserManager.d.ts +30 -0
- package/dist/managers/betuser/GuildBetUserManager.js +94 -0
- package/dist/managers/channel/ChannelManager.d.ts +39 -0
- package/dist/managers/channel/ChannelManager.js +147 -0
- package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +34 -0
- package/dist/managers/groupedchannel/GroupedChannelManager.js +92 -0
- package/dist/managers/guild/GuildManager.d.ts +24 -0
- package/dist/managers/guild/GuildManager.js +75 -0
- package/dist/managers/match/GuildMatchManager.d.ts +32 -0
- package/dist/managers/match/GuildMatchManager.js +103 -0
- package/dist/managers/mediator/GuildMediatorManager.d.ts +32 -0
- package/dist/managers/mediator/GuildMediatorManager.js +97 -0
- package/dist/managers/messages/MessagesManager.d.ts +32 -0
- package/dist/managers/messages/MessagesManager.js +82 -0
- package/dist/managers/permission/GuildPermissionManager.d.ts +26 -0
- package/dist/managers/permission/GuildPermissionManager.js +70 -0
- package/dist/managers/product/GuildProductManager.d.ts +32 -0
- package/dist/managers/product/GuildProductManager.js +102 -0
- package/dist/managers/ticket/GuildTicketManager.d.ts +32 -0
- package/dist/managers/ticket/GuildTicketManager.js +99 -0
- package/dist/managers/user/GuildUserManager.d.ts +32 -0
- package/dist/managers/user/GuildUserManager.js +106 -0
- package/dist/rest/APIEndpoints.d.ts +11 -0
- package/dist/rest/APIEndpoints.js +12 -0
- package/dist/rest/REST.d.ts +51 -0
- package/dist/rest/REST.js +96 -0
- package/dist/rest/Routes.d.ts +84 -0
- package/dist/rest/Routes.js +89 -0
- package/dist/structures/Collection.d.ts +17 -0
- package/dist/structures/Collection.js +87 -0
- package/dist/structures/bet/GuildBet.d.ts +86 -0
- package/dist/structures/bet/GuildBet.js +276 -0
- package/dist/structures/betuser/GuildBetUser.d.ts +82 -0
- package/dist/structures/betuser/GuildBetUser.js +194 -0
- package/dist/structures/channel/Channel.d.ts +31 -0
- package/dist/structures/channel/Channel.js +57 -0
- package/dist/structures/groupedchannel/GroupedChannel.d.ts +34 -0
- package/dist/structures/groupedchannel/GroupedChannel.js +121 -0
- package/dist/structures/guild/Guild.d.ts +90 -0
- package/dist/structures/guild/Guild.js +254 -0
- package/dist/structures/match/GuildMatch.d.ts +84 -0
- package/dist/structures/match/GuildMatch.js +327 -0
- package/dist/structures/mediator/GuildMediator.d.ts +41 -0
- package/dist/structures/mediator/GuildMediator.js +131 -0
- package/dist/structures/product/GuildProduct.d.ts +52 -0
- package/dist/structures/product/GuildProduct.js +175 -0
- package/dist/structures/shop/GuildShop.d.ts +34 -0
- package/dist/structures/shop/GuildShop.js +80 -0
- package/dist/structures/ticket/GuildTicket.d.ts +51 -0
- package/dist/structures/ticket/GuildTicket.js +170 -0
- package/dist/structures/user/GuildUser.d.ts +82 -0
- package/dist/structures/user/GuildUser.js +208 -0
- package/dist/types/api/APIBaseChannel.d.ts +10 -0
- package/dist/types/api/APIBaseChannel.js +2 -0
- package/dist/types/api/APIBetChannel.d.ts +10 -0
- package/dist/types/api/APIBetChannel.js +2 -0
- package/dist/types/api/APIBetMessage.d.ts +10 -0
- package/dist/types/api/APIBetMessage.js +2 -0
- package/dist/types/api/APIGuild.d.ts +93 -0
- package/dist/types/api/APIGuild.js +2 -0
- package/dist/types/api/APIGuildBet.d.ts +48 -0
- package/dist/types/api/APIGuildBet.js +2 -0
- package/dist/types/api/APIGuildBetUser.d.ts +32 -0
- package/dist/types/api/APIGuildBetUser.js +2 -0
- package/dist/types/api/APIGuildChannel.d.ts +10 -0
- package/dist/types/api/APIGuildChannel.js +2 -0
- package/dist/types/api/APIGuildEmoji.d.ts +12 -0
- package/dist/types/api/APIGuildEmoji.js +2 -0
- package/dist/types/api/APIGuildGroupedChannel.d.ts +10 -0
- package/dist/types/api/APIGuildGroupedChannel.js +2 -0
- package/dist/types/api/APIGuildMatch.d.ts +46 -0
- package/dist/types/api/APIGuildMatch.js +2 -0
- package/dist/types/api/APIGuildMediator.d.ts +13 -0
- package/dist/types/api/APIGuildMediator.js +3 -0
- package/dist/types/api/APIGuildMessage.d.ts +10 -0
- package/dist/types/api/APIGuildMessage.js +2 -0
- package/dist/types/api/APIGuildPermissions.d.ts +6 -0
- package/dist/types/api/APIGuildPermissions.js +2 -0
- package/dist/types/api/APIGuildRole.d.ts +10 -0
- package/dist/types/api/APIGuildRole.js +2 -0
- package/dist/types/api/APIGuildShop.d.ts +11 -0
- package/dist/types/api/APIGuildShop.js +2 -0
- package/dist/types/api/APIGuildTicket.d.ts +25 -0
- package/dist/types/api/APIGuildTicket.js +3 -0
- package/dist/types/api/APIGuildUser.d.ts +31 -0
- package/dist/types/api/APIGuildUser.js +2 -0
- package/dist/types/api/APIMessage.d.ts +12 -0
- package/dist/types/api/APIMessage.js +2 -0
- package/dist/types/api/APIPlayer.d.ts +10 -0
- package/dist/types/api/APIPlayer.js +2 -0
- package/dist/types/api/APIProduct.d.ts +19 -0
- package/dist/types/api/APIProduct.js +3 -0
- package/dist/types/api/index.d.ts +130 -0
- package/dist/types/api/index.js +35 -0
- package/{v1/types/index.ts → dist/types/index.d.ts} +21 -24
- package/dist/types/index.js +37 -0
- package/dist/utils/Assertion.d.ts +32 -0
- package/dist/utils/Assertion.js +60 -0
- package/package.json +15 -1
- package/.gitattributes +0 -2
- package/tests/index.ts +0 -86
- package/tsconfig.json +0 -15
- package/v1/managers/bet/GuildBetManager.ts +0 -117
- package/v1/managers/betuser/GuildBetUserManager.ts +0 -103
- package/v1/managers/channel/ChannelManager.ts +0 -168
- package/v1/managers/groupedchannel/GroupedChannelManager.ts +0 -117
- package/v1/managers/guild/GuildManager.ts +0 -84
- package/v1/managers/match/GuildMatchManager.ts +0 -115
- package/v1/managers/mediator/GuildMediatorManager.ts +0 -111
- package/v1/managers/messages/MessagesManager.ts +0 -95
- package/v1/managers/permission/GuildPermissionManager.ts +0 -88
- package/v1/managers/product/GuildProductManager.ts +0 -115
- package/v1/managers/ticket/GuildTicketManager.ts +0 -112
- package/v1/managers/user/GuildUserManager.ts +0 -116
- package/v1/rest/APIEndpoints.ts +0 -11
- package/v1/rest/REST.ts +0 -126
- package/v1/rest/Routes.ts +0 -143
- package/v1/structures/Collection.ts +0 -85
- package/v1/structures/bet/GuildBet.ts +0 -332
- package/v1/structures/betuser/GuildBetUser.ts +0 -247
- package/v1/structures/channel/Channel.ts +0 -78
- package/v1/structures/groupedchannel/GroupedChannel.ts +0 -165
- package/v1/structures/guild/Guild.ts +0 -302
- package/v1/structures/match/GuildMatch.ts +0 -385
- package/v1/structures/mediator/GuildMediator.ts +0 -175
- package/v1/structures/product/GuildProduct.ts +0 -217
- package/v1/structures/shop/GuildShop.ts +0 -98
- package/v1/structures/ticket/GuildTicket.ts +0 -227
- package/v1/structures/user/GuildUser.ts +0 -248
- package/v1/types/api/APIBaseChannel.ts +0 -13
- package/v1/types/api/APIBetChannel.ts +0 -13
- package/v1/types/api/APIBetMessage.ts +0 -13
- package/v1/types/api/APIGuild.ts +0 -123
- package/v1/types/api/APIGuildBet.ts +0 -69
- package/v1/types/api/APIGuildBetUser.ts +0 -46
- package/v1/types/api/APIGuildChannel.ts +0 -13
- package/v1/types/api/APIGuildEmoji.ts +0 -16
- package/v1/types/api/APIGuildGroupedChannel.ts +0 -13
- package/v1/types/api/APIGuildMatch.ts +0 -67
- package/v1/types/api/APIGuildMediator.ts +0 -18
- package/v1/types/api/APIGuildMessage.ts +0 -13
- package/v1/types/api/APIGuildPermissions.ts +0 -7
- package/v1/types/api/APIGuildRole.ts +0 -13
- package/v1/types/api/APIGuildShop.ts +0 -15
- package/v1/types/api/APIGuildTicket.ts +0 -36
- package/v1/types/api/APIGuildUser.ts +0 -45
- package/v1/types/api/APIMessage.ts +0 -16
- package/v1/types/api/APIPlayer.ts +0 -13
- package/v1/types/api/APIProduct.ts +0 -27
- package/v1/types/api/index.ts +0 -180
- package/v1/utils/Assertion.ts +0 -56
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupedChannelManager = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const GroupedChannel_1 = require("../../structures/groupedchannel/GroupedChannel");
|
|
6
|
+
const Collection_1 = require("../../structures/Collection");
|
|
7
|
+
const Assertion_1 = require("../../utils/Assertion");
|
|
8
|
+
class GroupedChannelManager {
|
|
9
|
+
/** A cache of channels */
|
|
10
|
+
cache;
|
|
11
|
+
/** Key */
|
|
12
|
+
key;
|
|
13
|
+
baseUrl;
|
|
14
|
+
/** The rest client */
|
|
15
|
+
rest;
|
|
16
|
+
/** GroupedChannel groupedChannel guild */
|
|
17
|
+
guild;
|
|
18
|
+
/**
|
|
19
|
+
* Manage channels with the given client
|
|
20
|
+
* @param channels An array of channels
|
|
21
|
+
* @param rest The rest client
|
|
22
|
+
*/
|
|
23
|
+
constructor(guild, key, rest) {
|
|
24
|
+
this.key = key;
|
|
25
|
+
this.baseUrl = Routes_1.Routes.fields(Routes_1.Routes.guilds.get(guild?.id), key);
|
|
26
|
+
this.cache = new Collection_1.Collection("groupedChannels");
|
|
27
|
+
this.guild = guild;
|
|
28
|
+
this.rest = rest;
|
|
29
|
+
}
|
|
30
|
+
async delete(type) {
|
|
31
|
+
const route = Routes_1.Routes.fields(this.baseUrl, type);
|
|
32
|
+
const response = await this.rest.request({
|
|
33
|
+
method: "delete",
|
|
34
|
+
url: route,
|
|
35
|
+
});
|
|
36
|
+
this.cache.delete(type);
|
|
37
|
+
return response;
|
|
38
|
+
}
|
|
39
|
+
async create(payload) {
|
|
40
|
+
Assertion_1.Assertion.assertObject(payload);
|
|
41
|
+
const route = this.baseUrl;
|
|
42
|
+
const response = await this.rest.request({
|
|
43
|
+
method: "POST",
|
|
44
|
+
url: route,
|
|
45
|
+
payload,
|
|
46
|
+
});
|
|
47
|
+
const groupedChannel = this.set(response);
|
|
48
|
+
return groupedChannel;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Fetch a groupedChannel
|
|
52
|
+
* @param id Id of the groupedChannel to fetch
|
|
53
|
+
* @returns APIgroupedChannelUser
|
|
54
|
+
*/
|
|
55
|
+
async fetch(type) {
|
|
56
|
+
const route = Routes_1.Routes.fields(this.baseUrl, type);
|
|
57
|
+
const response = await this.rest.request({
|
|
58
|
+
method: "get",
|
|
59
|
+
url: route,
|
|
60
|
+
});
|
|
61
|
+
const channel = this.set(response);
|
|
62
|
+
this.cache.set(channel.type, channel);
|
|
63
|
+
return channel;
|
|
64
|
+
}
|
|
65
|
+
async fetchAll() {
|
|
66
|
+
const route = this.baseUrl;
|
|
67
|
+
const response = await this.rest.request({
|
|
68
|
+
method: "get",
|
|
69
|
+
url: route,
|
|
70
|
+
});
|
|
71
|
+
for (let groupedChannelData of response) {
|
|
72
|
+
const groupedChannel = new GroupedChannel_1.GroupedChannel(groupedChannelData, this.guild, this, this.rest);
|
|
73
|
+
this.cache.set(groupedChannel.type, groupedChannel);
|
|
74
|
+
}
|
|
75
|
+
return this.cache;
|
|
76
|
+
}
|
|
77
|
+
setAll(data) {
|
|
78
|
+
if (!data)
|
|
79
|
+
return this.cache;
|
|
80
|
+
for (let groupedChannel of data)
|
|
81
|
+
this.set(groupedChannel);
|
|
82
|
+
return this.cache;
|
|
83
|
+
}
|
|
84
|
+
set(data) {
|
|
85
|
+
if (!data?.type)
|
|
86
|
+
return;
|
|
87
|
+
const groupedChannel = new GroupedChannel_1.GroupedChannel(data, this.guild, this, this.rest);
|
|
88
|
+
this.cache.set(data.type, groupedChannel);
|
|
89
|
+
return groupedChannel;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
exports.GroupedChannelManager = GroupedChannelManager;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { Collection } from "../../structures/Collection";
|
|
3
|
+
import { Guild } from "../../structures/guild/Guild";
|
|
4
|
+
export declare class GuildManager {
|
|
5
|
+
/** A cache of guilds */
|
|
6
|
+
cache: Collection<string, Guild>;
|
|
7
|
+
/** The rest client */
|
|
8
|
+
rest: REST;
|
|
9
|
+
/**
|
|
10
|
+
* Manage guilds with the given client
|
|
11
|
+
* @param guilds An array of guilds
|
|
12
|
+
* @param rest The rest client
|
|
13
|
+
*/
|
|
14
|
+
constructor(rest: REST);
|
|
15
|
+
/**
|
|
16
|
+
* Fetch a guild
|
|
17
|
+
* @param id Id of the guild to fetch
|
|
18
|
+
* @returns APIGuild
|
|
19
|
+
*/
|
|
20
|
+
fetch(id: string): Promise<Guild>;
|
|
21
|
+
fetchAll(): Promise<Collection<string, Guild>>;
|
|
22
|
+
delete(id: string): Promise<Collection<string, Guild>>;
|
|
23
|
+
deleteAll(): Promise<boolean>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildManager = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const Collection_1 = require("../../structures/Collection");
|
|
6
|
+
const Guild_1 = require("../../structures/guild/Guild");
|
|
7
|
+
const Assertion_1 = require("../../utils/Assertion");
|
|
8
|
+
class GuildManager {
|
|
9
|
+
/** A cache of guilds */
|
|
10
|
+
cache;
|
|
11
|
+
/** The rest client */
|
|
12
|
+
rest;
|
|
13
|
+
/**
|
|
14
|
+
* Manage guilds with the given client
|
|
15
|
+
* @param guilds An array of guilds
|
|
16
|
+
* @param rest The rest client
|
|
17
|
+
*/
|
|
18
|
+
constructor(rest) {
|
|
19
|
+
this.cache = new Collection_1.Collection("guilds");
|
|
20
|
+
this.rest = rest;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Fetch a guild
|
|
24
|
+
* @param id Id of the guild to fetch
|
|
25
|
+
* @returns APIGuild
|
|
26
|
+
*/
|
|
27
|
+
async fetch(id) {
|
|
28
|
+
const route = Routes_1.Routes.guilds.get(id);
|
|
29
|
+
const response = await this.rest.request({
|
|
30
|
+
method: "get",
|
|
31
|
+
url: route,
|
|
32
|
+
});
|
|
33
|
+
const guild = new Guild_1.Guild(response, this.rest);
|
|
34
|
+
this.cache.set(guild.id, guild);
|
|
35
|
+
return guild;
|
|
36
|
+
}
|
|
37
|
+
async fetchAll() {
|
|
38
|
+
const route = Routes_1.Routes.guilds.getAll();
|
|
39
|
+
const response = await this.rest.request({
|
|
40
|
+
method: "get",
|
|
41
|
+
url: route,
|
|
42
|
+
});
|
|
43
|
+
for (let guildData of response) {
|
|
44
|
+
if (!guildData.id)
|
|
45
|
+
continue;
|
|
46
|
+
const guild = new Guild_1.Guild(guildData, this.rest);
|
|
47
|
+
this.cache.set(guild.id, guild);
|
|
48
|
+
this.rest.guilds.cache.set(guild.id, guild);
|
|
49
|
+
}
|
|
50
|
+
return this.cache;
|
|
51
|
+
}
|
|
52
|
+
async delete(id) {
|
|
53
|
+
Assertion_1.Assertion.assertString(id);
|
|
54
|
+
const route = Routes_1.Routes.guilds.delete(id);
|
|
55
|
+
const guild = this.cache.get(id);
|
|
56
|
+
this.rest.emit("guildDelete", guild);
|
|
57
|
+
await this.rest.request({
|
|
58
|
+
method: "DELETE",
|
|
59
|
+
url: route,
|
|
60
|
+
});
|
|
61
|
+
this.cache.delete(id);
|
|
62
|
+
return this.cache;
|
|
63
|
+
}
|
|
64
|
+
async deleteAll() {
|
|
65
|
+
const route = Routes_1.Routes.guilds.deleteAll();
|
|
66
|
+
this.rest.emit("guildsDelete", this.cache);
|
|
67
|
+
const value = await this.rest.request({
|
|
68
|
+
method: "DELETE",
|
|
69
|
+
url: route,
|
|
70
|
+
});
|
|
71
|
+
this.cache.clear();
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.GuildManager = GuildManager;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { GuildMatch } from "../../structures/match/GuildMatch";
|
|
3
|
+
import { Collection } from "../../structures/Collection";
|
|
4
|
+
import { Guild } from "../../structures/guild/Guild";
|
|
5
|
+
import { APIGuildMatch } from "../../types/api/APIGuildMatch";
|
|
6
|
+
import { Optional } from "../../types/api";
|
|
7
|
+
export declare class GuildMatchManager {
|
|
8
|
+
/** A cache of users */
|
|
9
|
+
cache: Collection<string, GuildMatch>;
|
|
10
|
+
/** The rest client */
|
|
11
|
+
rest: REST;
|
|
12
|
+
/** GuildMatch match guild */
|
|
13
|
+
guild: Guild;
|
|
14
|
+
/**
|
|
15
|
+
* Manage users with the given client
|
|
16
|
+
* @param users An array of users
|
|
17
|
+
* @param rest The rest client
|
|
18
|
+
*/
|
|
19
|
+
constructor(guild: Guild, rest: REST);
|
|
20
|
+
/**
|
|
21
|
+
* Fetch a match
|
|
22
|
+
* @param id Id of the match to fetch
|
|
23
|
+
* @returns APIBetUser
|
|
24
|
+
*/
|
|
25
|
+
fetch(id: string): Promise<GuildMatch>;
|
|
26
|
+
fetchAll(): Promise<Collection<string, GuildMatch>>;
|
|
27
|
+
set(data: APIGuildMatch): GuildMatch;
|
|
28
|
+
setAll(data: APIGuildMatch[]): Collection<string, GuildMatch>;
|
|
29
|
+
create(payload: Optional<APIGuildMatch>): Promise<GuildMatch>;
|
|
30
|
+
delete(id: string): Promise<Collection<string, GuildMatch>>;
|
|
31
|
+
deleteAll(): Promise<boolean>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildMatchManager = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const GuildMatch_1 = require("../../structures/match/GuildMatch");
|
|
6
|
+
const Collection_1 = require("../../structures/Collection");
|
|
7
|
+
const Assertion_1 = require("../../utils/Assertion");
|
|
8
|
+
class GuildMatchManager {
|
|
9
|
+
/** A cache of users */
|
|
10
|
+
cache;
|
|
11
|
+
/** The rest client */
|
|
12
|
+
rest;
|
|
13
|
+
/** GuildMatch match guild */
|
|
14
|
+
guild;
|
|
15
|
+
/**
|
|
16
|
+
* Manage users with the given client
|
|
17
|
+
* @param users An array of users
|
|
18
|
+
* @param rest The rest client
|
|
19
|
+
*/
|
|
20
|
+
constructor(guild, rest) {
|
|
21
|
+
this.guild = guild;
|
|
22
|
+
this.cache = new Collection_1.Collection("matches");
|
|
23
|
+
this.rest = rest;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Fetch a match
|
|
27
|
+
* @param id Id of the match to fetch
|
|
28
|
+
* @returns APIBetUser
|
|
29
|
+
*/
|
|
30
|
+
async fetch(id) {
|
|
31
|
+
const route = Routes_1.Routes.guilds.matches.get(this.guild.id, id);
|
|
32
|
+
const response = await this.rest.request({
|
|
33
|
+
method: "get",
|
|
34
|
+
url: route,
|
|
35
|
+
});
|
|
36
|
+
const match = new GuildMatch_1.GuildMatch(response, this.guild, this, this.rest);
|
|
37
|
+
this.cache.set(match._id, match);
|
|
38
|
+
this.rest.matches.set(match._id, match);
|
|
39
|
+
return match;
|
|
40
|
+
}
|
|
41
|
+
async fetchAll() {
|
|
42
|
+
const route = Routes_1.Routes.guilds.matches.getAll(this.guild.id);
|
|
43
|
+
const response = await this.rest.request({
|
|
44
|
+
method: "get",
|
|
45
|
+
url: route,
|
|
46
|
+
});
|
|
47
|
+
if (Array.isArray(response) && response.length === 0) {
|
|
48
|
+
this.cache.clear();
|
|
49
|
+
return this.cache;
|
|
50
|
+
}
|
|
51
|
+
this.setAll(response);
|
|
52
|
+
return this.cache;
|
|
53
|
+
}
|
|
54
|
+
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
|
+
if (!data)
|
|
64
|
+
return this.cache;
|
|
65
|
+
for (let match of data || [])
|
|
66
|
+
this.set(match);
|
|
67
|
+
return this.cache;
|
|
68
|
+
}
|
|
69
|
+
async create(payload) {
|
|
70
|
+
Assertion_1.Assertion.assertObject(payload);
|
|
71
|
+
const route = Routes_1.Routes.guilds.matches.create(this.guild.id);
|
|
72
|
+
const response = await this.rest.request({
|
|
73
|
+
method: "POST",
|
|
74
|
+
url: route,
|
|
75
|
+
payload,
|
|
76
|
+
});
|
|
77
|
+
const match = this.set(response);
|
|
78
|
+
return match;
|
|
79
|
+
}
|
|
80
|
+
async delete(id) {
|
|
81
|
+
Assertion_1.Assertion.assertString(id);
|
|
82
|
+
const route = Routes_1.Routes.guilds.matches.delete(id, this.guild.id);
|
|
83
|
+
const match = this.cache.get(id);
|
|
84
|
+
this.rest.emit("matchDelete", match);
|
|
85
|
+
await this.rest.request({
|
|
86
|
+
method: "DELETE",
|
|
87
|
+
url: route,
|
|
88
|
+
});
|
|
89
|
+
this.cache.delete(id);
|
|
90
|
+
return this.cache;
|
|
91
|
+
}
|
|
92
|
+
async deleteAll() {
|
|
93
|
+
const route = Routes_1.Routes.guilds.matches.deleteAll(this.guild.id);
|
|
94
|
+
this.rest.emit("matchesDelete", this.cache);
|
|
95
|
+
const value = await this.rest.request({
|
|
96
|
+
method: "DELETE",
|
|
97
|
+
url: route,
|
|
98
|
+
});
|
|
99
|
+
this.cache.clear();
|
|
100
|
+
return value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.GuildMatchManager = GuildMatchManager;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { Collection } from "../../structures/Collection";
|
|
3
|
+
import { Guild } from "../../structures/guild/Guild";
|
|
4
|
+
import { GuildMediator } from "../../structures/mediator/GuildMediator";
|
|
5
|
+
import { Optional } from "../../types/api";
|
|
6
|
+
import { APIGuildMediator } from "../../types/api/APIGuildMediator";
|
|
7
|
+
export declare class GuildMediatorManager {
|
|
8
|
+
/** A cache of users */
|
|
9
|
+
cache: Collection<string, GuildMediator>;
|
|
10
|
+
/** The rest client */
|
|
11
|
+
rest: REST;
|
|
12
|
+
/** GuildMediator mediator guild */
|
|
13
|
+
guild: Guild;
|
|
14
|
+
/**
|
|
15
|
+
* Manage users with the given client
|
|
16
|
+
* @param users An array of users
|
|
17
|
+
* @param rest The rest client
|
|
18
|
+
*/
|
|
19
|
+
constructor(guild: Guild, rest: REST);
|
|
20
|
+
create(payload: Optional<APIGuildMediator>): Promise<GuildMediator>;
|
|
21
|
+
/**
|
|
22
|
+
* Fetch a mediator
|
|
23
|
+
* @param id Id of the mediator to fetch
|
|
24
|
+
* @returns APImediatorUser
|
|
25
|
+
*/
|
|
26
|
+
fetch(id: string): Promise<GuildMediator>;
|
|
27
|
+
fetchAll(): Promise<Collection<string, GuildMediator>>;
|
|
28
|
+
set(data: APIGuildMediator): GuildMediator;
|
|
29
|
+
setAll(data: APIGuildMediator[]): Collection<string, GuildMediator>;
|
|
30
|
+
delete(id: string): Promise<Collection<string, GuildMediator>>;
|
|
31
|
+
deleteAll(): Promise<boolean>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildMediatorManager = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const Collection_1 = require("../../structures/Collection");
|
|
6
|
+
const GuildMediator_1 = require("../../structures/mediator/GuildMediator");
|
|
7
|
+
const Assertion_1 = require("../../utils/Assertion");
|
|
8
|
+
class GuildMediatorManager {
|
|
9
|
+
/** A cache of users */
|
|
10
|
+
cache;
|
|
11
|
+
/** The rest client */
|
|
12
|
+
rest;
|
|
13
|
+
/** GuildMediator mediator guild */
|
|
14
|
+
guild;
|
|
15
|
+
/**
|
|
16
|
+
* Manage users with the given client
|
|
17
|
+
* @param users An array of users
|
|
18
|
+
* @param rest The rest client
|
|
19
|
+
*/
|
|
20
|
+
constructor(guild, rest) {
|
|
21
|
+
this.guild = guild;
|
|
22
|
+
this.rest = rest;
|
|
23
|
+
this.cache = new Collection_1.Collection("mediators");
|
|
24
|
+
}
|
|
25
|
+
async create(payload) {
|
|
26
|
+
Assertion_1.Assertion.assertObject(payload);
|
|
27
|
+
const route = Routes_1.Routes.guilds.mediators.create(this.guild.id);
|
|
28
|
+
const response = await this.rest.request({
|
|
29
|
+
method: "POST",
|
|
30
|
+
url: route,
|
|
31
|
+
});
|
|
32
|
+
const mediator = this.set(response);
|
|
33
|
+
return mediator;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Fetch a mediator
|
|
37
|
+
* @param id Id of the mediator to fetch
|
|
38
|
+
* @returns APImediatorUser
|
|
39
|
+
*/
|
|
40
|
+
async fetch(id) {
|
|
41
|
+
const route = Routes_1.Routes.guilds.mediators.get(this.guild.id, id);
|
|
42
|
+
const response = await this.rest.request({
|
|
43
|
+
method: "get",
|
|
44
|
+
url: route,
|
|
45
|
+
});
|
|
46
|
+
const mediator = new GuildMediator_1.GuildMediator(response, this.guild, this, this.rest);
|
|
47
|
+
this.cache.set(mediator.id, mediator);
|
|
48
|
+
return mediator;
|
|
49
|
+
}
|
|
50
|
+
async fetchAll() {
|
|
51
|
+
const route = Routes_1.Routes.guilds.mediators.getAll(this.guild.id);
|
|
52
|
+
const response = await this.rest.request({
|
|
53
|
+
method: "get",
|
|
54
|
+
url: route,
|
|
55
|
+
});
|
|
56
|
+
this.setAll(response);
|
|
57
|
+
return this.cache;
|
|
58
|
+
}
|
|
59
|
+
set(data) {
|
|
60
|
+
if (!data.id)
|
|
61
|
+
return;
|
|
62
|
+
const mediator = new GuildMediator_1.GuildMediator(data, this.guild, this, this.rest);
|
|
63
|
+
this.cache.set(data.id, mediator);
|
|
64
|
+
this.rest.mediators.set(mediator.id, mediator);
|
|
65
|
+
return mediator;
|
|
66
|
+
}
|
|
67
|
+
setAll(data) {
|
|
68
|
+
if (!data)
|
|
69
|
+
return this.cache;
|
|
70
|
+
for (let mediator of data)
|
|
71
|
+
this.set(mediator);
|
|
72
|
+
return this.cache;
|
|
73
|
+
}
|
|
74
|
+
async delete(id) {
|
|
75
|
+
Assertion_1.Assertion.assertString(id);
|
|
76
|
+
const route = Routes_1.Routes.guilds.mediators.delete(id, this.guild.id);
|
|
77
|
+
const mediator = this.cache.get(id);
|
|
78
|
+
this.rest.emit("mediatorDelete", mediator);
|
|
79
|
+
await this.rest.request({
|
|
80
|
+
method: "DELETE",
|
|
81
|
+
url: route,
|
|
82
|
+
});
|
|
83
|
+
this.cache.delete(id);
|
|
84
|
+
return this.cache;
|
|
85
|
+
}
|
|
86
|
+
async deleteAll() {
|
|
87
|
+
const route = Routes_1.Routes.guilds.mediators.deleteAll(this.guild.id);
|
|
88
|
+
this.rest.emit("mediatorsDelete", this.cache);
|
|
89
|
+
const value = await this.rest.request({
|
|
90
|
+
method: "DELETE",
|
|
91
|
+
url: route,
|
|
92
|
+
});
|
|
93
|
+
this.cache.clear();
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
exports.GuildMediatorManager = GuildMediatorManager;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { Collection } from "../../structures/Collection";
|
|
3
|
+
import { Guild } from "../../structures/guild/Guild";
|
|
4
|
+
import { Optional } from "../../types/api";
|
|
5
|
+
import { APIMessage } from "../../types/api/APIMessage";
|
|
6
|
+
export declare class MessagesManager {
|
|
7
|
+
/** A cache of messages */
|
|
8
|
+
cache: Collection<string, APIMessage>;
|
|
9
|
+
/** Key */
|
|
10
|
+
key: string;
|
|
11
|
+
baseUrl: string;
|
|
12
|
+
/** The rest client */
|
|
13
|
+
rest: REST;
|
|
14
|
+
/** APIMessage message guild */
|
|
15
|
+
guild: Guild;
|
|
16
|
+
/**
|
|
17
|
+
* Manage messages with the given client
|
|
18
|
+
* @param messages An array of messages
|
|
19
|
+
* @param rest The rest client
|
|
20
|
+
*/
|
|
21
|
+
constructor(guild: Guild, key: string, rest: REST);
|
|
22
|
+
create(payload: Optional<APIMessage>): Promise<APIMessage>;
|
|
23
|
+
/**
|
|
24
|
+
* Fetch a message
|
|
25
|
+
* @param id Id of the message to fetch
|
|
26
|
+
* @returns APIgroupedChannelUser
|
|
27
|
+
*/
|
|
28
|
+
fetch(type: string): Promise<APIMessage>;
|
|
29
|
+
fetchAll(): Promise<Collection<string, APIMessage>>;
|
|
30
|
+
set(data: APIMessage): APIMessage;
|
|
31
|
+
setAll(data: APIMessage[]): Collection<string, APIMessage>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessagesManager = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const Collection_1 = require("../../structures/Collection");
|
|
6
|
+
const Assertion_1 = require("../../utils/Assertion");
|
|
7
|
+
class MessagesManager {
|
|
8
|
+
/** A cache of messages */
|
|
9
|
+
cache;
|
|
10
|
+
/** Key */
|
|
11
|
+
key;
|
|
12
|
+
baseUrl;
|
|
13
|
+
/** The rest client */
|
|
14
|
+
rest;
|
|
15
|
+
/** APIMessage message guild */
|
|
16
|
+
guild;
|
|
17
|
+
/**
|
|
18
|
+
* Manage messages with the given client
|
|
19
|
+
* @param messages An array of messages
|
|
20
|
+
* @param rest The rest client
|
|
21
|
+
*/
|
|
22
|
+
constructor(guild, key, rest) {
|
|
23
|
+
this.guild = guild;
|
|
24
|
+
this.key = key;
|
|
25
|
+
this.baseUrl = Routes_1.Routes.fields(Routes_1.Routes.guilds.get(guild?.id), key, "messages");
|
|
26
|
+
this.cache = new Collection_1.Collection(`${key}-messages`);
|
|
27
|
+
this.rest = rest;
|
|
28
|
+
}
|
|
29
|
+
async create(payload) {
|
|
30
|
+
Assertion_1.Assertion.assertObject(payload);
|
|
31
|
+
const route = this.baseUrl;
|
|
32
|
+
const response = await this.rest.request({
|
|
33
|
+
method: "POST",
|
|
34
|
+
url: route,
|
|
35
|
+
payload,
|
|
36
|
+
});
|
|
37
|
+
const message = this.set(response);
|
|
38
|
+
return message;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Fetch a message
|
|
42
|
+
* @param id Id of the message to fetch
|
|
43
|
+
* @returns APIgroupedChannelUser
|
|
44
|
+
*/
|
|
45
|
+
async fetch(type) {
|
|
46
|
+
const route = Routes_1.Routes.fields(this.baseUrl, type);
|
|
47
|
+
const response = await this.rest.request({
|
|
48
|
+
method: "get",
|
|
49
|
+
url: route,
|
|
50
|
+
});
|
|
51
|
+
const channel = this.set(response);
|
|
52
|
+
this.cache.set(channel.type, channel);
|
|
53
|
+
return channel;
|
|
54
|
+
}
|
|
55
|
+
async fetchAll() {
|
|
56
|
+
const route = this.baseUrl;
|
|
57
|
+
const response = await this.rest.request({
|
|
58
|
+
method: "get",
|
|
59
|
+
url: route,
|
|
60
|
+
});
|
|
61
|
+
for (let data of response) {
|
|
62
|
+
if (!data.type)
|
|
63
|
+
continue;
|
|
64
|
+
this.cache.set(data?.type, data);
|
|
65
|
+
}
|
|
66
|
+
return this.cache;
|
|
67
|
+
}
|
|
68
|
+
set(data) {
|
|
69
|
+
if (!data?.type)
|
|
70
|
+
return;
|
|
71
|
+
this.cache.set(data?.type, data);
|
|
72
|
+
return data;
|
|
73
|
+
}
|
|
74
|
+
setAll(data) {
|
|
75
|
+
if (!data)
|
|
76
|
+
return this.cache;
|
|
77
|
+
for (let message of data)
|
|
78
|
+
this.set(message);
|
|
79
|
+
return this.cache;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.MessagesManager = MessagesManager;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { Guild } from "../../structures/guild/Guild";
|
|
3
|
+
import { APIGuildPermissions } from "../../types/api/APIGuildPermissions";
|
|
4
|
+
export declare class GuildPermissionManager {
|
|
5
|
+
/** The rest client */
|
|
6
|
+
rest: REST;
|
|
7
|
+
/** GuildBet bet guild */
|
|
8
|
+
guild: Guild;
|
|
9
|
+
permissions: APIGuildPermissions;
|
|
10
|
+
/**
|
|
11
|
+
* Manage users with the given client
|
|
12
|
+
* @param users An array of users
|
|
13
|
+
* @param rest The rest client
|
|
14
|
+
*/
|
|
15
|
+
constructor(guild: Guild, rest: REST);
|
|
16
|
+
/**
|
|
17
|
+
* Fetch a bet
|
|
18
|
+
* @param id Id of the bet to fetch
|
|
19
|
+
* @returns APIBetUser
|
|
20
|
+
*/
|
|
21
|
+
fetch(): Promise<void>;
|
|
22
|
+
addId(permissionId: keyof APIGuildPermissions, roleId: string): Promise<string[]>;
|
|
23
|
+
removeId(permissionId: keyof APIGuildPermissions, roleId: string): Promise<string[]>;
|
|
24
|
+
setAll(data: APIGuildPermissions): APIGuildPermissions;
|
|
25
|
+
toJSON(): Record<string, unknown>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildPermissionManager = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
class GuildPermissionManager {
|
|
6
|
+
/** The rest client */
|
|
7
|
+
rest;
|
|
8
|
+
/** GuildBet bet guild */
|
|
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) {
|
|
17
|
+
this.guild = guild;
|
|
18
|
+
this.rest = rest;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Fetch a bet
|
|
22
|
+
* @param id Id of the bet to fetch
|
|
23
|
+
* @returns APIBetUser
|
|
24
|
+
*/
|
|
25
|
+
async fetch() {
|
|
26
|
+
const route = Routes_1.Routes.guilds.resource(this.guild.id, "permissions");
|
|
27
|
+
const response = await this.rest.request({
|
|
28
|
+
method: "get",
|
|
29
|
+
url: route,
|
|
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,
|
|
39
|
+
payload,
|
|
40
|
+
});
|
|
41
|
+
this.permissions[permissionId] = response;
|
|
42
|
+
return response;
|
|
43
|
+
}
|
|
44
|
+
async removeId(permissionId, roleId) {
|
|
45
|
+
const route = Routes_1.Routes.guilds.resources(this.guild.id, "permissions", permissionId, "ids", roleId);
|
|
46
|
+
const payload = { id: roleId };
|
|
47
|
+
const response = await this.rest.request({
|
|
48
|
+
method: "delete",
|
|
49
|
+
url: route,
|
|
50
|
+
payload,
|
|
51
|
+
});
|
|
52
|
+
this.permissions[permissionId] = response;
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
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
|
+
}
|
|
70
|
+
exports.GuildPermissionManager = GuildPermissionManager;
|