@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,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildBetUser = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
class GuildBetUser {
|
|
6
|
+
/** User daily */
|
|
7
|
+
daily;
|
|
8
|
+
/** User's name */
|
|
9
|
+
name;
|
|
10
|
+
/** User's name */
|
|
11
|
+
id;
|
|
12
|
+
/** User's credit */
|
|
13
|
+
credit;
|
|
14
|
+
/** User's wins */
|
|
15
|
+
wins;
|
|
16
|
+
/** User's mvps */
|
|
17
|
+
mvps;
|
|
18
|
+
/** User's losses */
|
|
19
|
+
losses;
|
|
20
|
+
/** User's bets played */
|
|
21
|
+
betsPlayed;
|
|
22
|
+
/** User's blacklist */
|
|
23
|
+
blacklist;
|
|
24
|
+
/** User's coins */
|
|
25
|
+
coins;
|
|
26
|
+
/** User's items */
|
|
27
|
+
items;
|
|
28
|
+
/** User's profile card */
|
|
29
|
+
profileCard;
|
|
30
|
+
/** Creation Date */
|
|
31
|
+
createdAt;
|
|
32
|
+
/** Updated Date */
|
|
33
|
+
updatedAt;
|
|
34
|
+
/** The given manager */
|
|
35
|
+
manager;
|
|
36
|
+
/** The rest client */
|
|
37
|
+
rest;
|
|
38
|
+
/**
|
|
39
|
+
* Bet user
|
|
40
|
+
* @param data The user's data
|
|
41
|
+
* @param manager The manager
|
|
42
|
+
* @param rest The rest client
|
|
43
|
+
*/
|
|
44
|
+
constructor(data, manager, rest) {
|
|
45
|
+
this.name = data.name;
|
|
46
|
+
this.id = data.id;
|
|
47
|
+
this.credit = data.credit;
|
|
48
|
+
this.wins = data.wins;
|
|
49
|
+
this.mvps = data.mvps;
|
|
50
|
+
this.losses = data.losses;
|
|
51
|
+
this.coins = data.coins;
|
|
52
|
+
this.blacklist = data.blacklist;
|
|
53
|
+
this.items = data.items;
|
|
54
|
+
this.betsPlayed = data.betsPlayed;
|
|
55
|
+
this.profileCard = data.profileCard;
|
|
56
|
+
this.daily = data?.daily;
|
|
57
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
58
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
59
|
+
this.manager = manager;
|
|
60
|
+
this.rest = rest;
|
|
61
|
+
}
|
|
62
|
+
/** String representation of this user */
|
|
63
|
+
toString() {
|
|
64
|
+
return `<@${this.id}>`;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Fetches the user
|
|
68
|
+
* @returns New Instance of the user
|
|
69
|
+
*/
|
|
70
|
+
async fetch() {
|
|
71
|
+
const route = Routes_1.Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
|
|
72
|
+
const response = await this.rest.request({
|
|
73
|
+
method: "get",
|
|
74
|
+
url: route,
|
|
75
|
+
});
|
|
76
|
+
const user = new GuildBetUser(response, this.manager, this.rest);
|
|
77
|
+
this.manager.cache.set(user.id, user);
|
|
78
|
+
this.rest.betUsers.set(user.id, user);
|
|
79
|
+
return user;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Add a propery
|
|
83
|
+
* @param key The desired key
|
|
84
|
+
* @param value The desired value
|
|
85
|
+
* @returns GuildBetUser
|
|
86
|
+
*/
|
|
87
|
+
async add(key, value) {
|
|
88
|
+
const route = Routes_1.Routes.guilds.betUsers.resource(this.manager.guild.id, this.id, key);
|
|
89
|
+
const payload = { [key]: value, name: this.name };
|
|
90
|
+
const resp = await this.rest.request({
|
|
91
|
+
method: "patch",
|
|
92
|
+
url: route,
|
|
93
|
+
payload,
|
|
94
|
+
});
|
|
95
|
+
this[key] = resp[key];
|
|
96
|
+
this.manager.cache.set(this.id, this);
|
|
97
|
+
this.rest.betUsers.set(this.id, this);
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Set the user blacklist
|
|
102
|
+
* @param value Value to set to
|
|
103
|
+
* @returns GuildBetUser
|
|
104
|
+
*/
|
|
105
|
+
async setBlacklist(value) {
|
|
106
|
+
const route = Routes_1.Routes.guilds.betUsers.resource(this.manager.guild.id, this.id, "blacklist");
|
|
107
|
+
const payload = { value, name: this.name };
|
|
108
|
+
await this.rest.request({
|
|
109
|
+
method: "patch",
|
|
110
|
+
url: route,
|
|
111
|
+
payload,
|
|
112
|
+
});
|
|
113
|
+
this.blacklist = value;
|
|
114
|
+
this.manager.cache.set(this.id, this);
|
|
115
|
+
this.rest.betUsers.set(this.id, this);
|
|
116
|
+
return this;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Update certain property
|
|
120
|
+
* @param data The new data to update with
|
|
121
|
+
* @returns
|
|
122
|
+
*/
|
|
123
|
+
async update(data) {
|
|
124
|
+
const route = Routes_1.Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
|
|
125
|
+
const payload = {};
|
|
126
|
+
const numericFields = [
|
|
127
|
+
"coins",
|
|
128
|
+
"wins",
|
|
129
|
+
"credit",
|
|
130
|
+
"losses",
|
|
131
|
+
"mvps",
|
|
132
|
+
];
|
|
133
|
+
const arrayFields = ["items", "betsPlayed"];
|
|
134
|
+
if (data.type === "add" || data.type === "remove") {
|
|
135
|
+
for (const key in data) {
|
|
136
|
+
if (key === "type")
|
|
137
|
+
continue;
|
|
138
|
+
const value = data[key];
|
|
139
|
+
if (numericFields.includes(key)) {
|
|
140
|
+
const current = this[key];
|
|
141
|
+
const num = value;
|
|
142
|
+
payload[key] = Math.max(0, data.type === "add" ? current + num : num - current);
|
|
143
|
+
}
|
|
144
|
+
else if (key === "blacklist") {
|
|
145
|
+
payload["blacklist"] = value;
|
|
146
|
+
}
|
|
147
|
+
else if (arrayFields.includes(key)) {
|
|
148
|
+
const current = this[key];
|
|
149
|
+
const incoming = value;
|
|
150
|
+
payload[key] =
|
|
151
|
+
data.type === "add"
|
|
152
|
+
? [...new Set([...current, ...incoming])]
|
|
153
|
+
: current.filter((x) => !incoming.includes(x));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const response = await this.rest.request({
|
|
158
|
+
method: "patch",
|
|
159
|
+
url: route,
|
|
160
|
+
payload,
|
|
161
|
+
});
|
|
162
|
+
for (const k in response) {
|
|
163
|
+
if (k === "id")
|
|
164
|
+
continue;
|
|
165
|
+
if (Object.hasOwn(this, k)) {
|
|
166
|
+
this[k] = response[k];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
this.rest.betUsers.set(this.id, this);
|
|
170
|
+
this.manager.cache.set(this.id, this);
|
|
171
|
+
return this;
|
|
172
|
+
}
|
|
173
|
+
async delete() {
|
|
174
|
+
const route = Routes_1.Routes.guilds.betUsers.delete(this.manager.guild.id, this.id);
|
|
175
|
+
const response = await this.rest.request({
|
|
176
|
+
method: "DELETE",
|
|
177
|
+
url: route,
|
|
178
|
+
});
|
|
179
|
+
this.rest.emit("betUserDelete", this);
|
|
180
|
+
this.manager.cache.delete(this.id);
|
|
181
|
+
this.rest.betUsers.set(this.id, this);
|
|
182
|
+
return response;
|
|
183
|
+
}
|
|
184
|
+
toJSON() {
|
|
185
|
+
const json = {};
|
|
186
|
+
for (const [key, value] of Object.entries(this)) {
|
|
187
|
+
if (typeof value !== "function") {
|
|
188
|
+
json[key] = value;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return json;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
exports.GuildBetUser = GuildBetUser;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChannelManager } from "../../managers/channel/ChannelManager";
|
|
2
|
+
import { REST } from "../../rest/REST";
|
|
3
|
+
import { APIBaseChannel } from "../../types/api/APIBaseChannel";
|
|
4
|
+
import { GuildBet } from "../bet/GuildBet";
|
|
5
|
+
import { Guild } from "../guild/Guild";
|
|
6
|
+
import { GuildMatch } from "../match/GuildMatch";
|
|
7
|
+
export interface ChannelData<S extends GuildBet | GuildMatch> {
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
data: APIBaseChannel;
|
|
10
|
+
guild: Guild;
|
|
11
|
+
manager: ChannelManager<S>;
|
|
12
|
+
}
|
|
13
|
+
export declare class Channel<S extends GuildBet | GuildMatch> {
|
|
14
|
+
/** Channel's type */
|
|
15
|
+
type: string;
|
|
16
|
+
/** Channel's id */
|
|
17
|
+
id: string;
|
|
18
|
+
/** Creation Date */
|
|
19
|
+
createdAt: Date;
|
|
20
|
+
/** Updated Date */
|
|
21
|
+
updatedAt: Date;
|
|
22
|
+
data: ChannelData<S>;
|
|
23
|
+
rest: REST;
|
|
24
|
+
baseUrl: string;
|
|
25
|
+
guild: Guild;
|
|
26
|
+
manager: ChannelManager<S>;
|
|
27
|
+
constructor(data: ChannelData<S>, rest: REST);
|
|
28
|
+
toString(): string;
|
|
29
|
+
setId(id: string): Promise<this>;
|
|
30
|
+
delete(): Promise<this>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Channel = void 0;
|
|
4
|
+
const Assertion_1 = require("../../utils/Assertion");
|
|
5
|
+
class Channel {
|
|
6
|
+
/** Channel's type */
|
|
7
|
+
type;
|
|
8
|
+
/** Channel's id */
|
|
9
|
+
id;
|
|
10
|
+
/** Creation Date */
|
|
11
|
+
createdAt;
|
|
12
|
+
/** Updated Date */
|
|
13
|
+
updatedAt;
|
|
14
|
+
data;
|
|
15
|
+
rest;
|
|
16
|
+
baseUrl;
|
|
17
|
+
guild;
|
|
18
|
+
manager;
|
|
19
|
+
constructor(data, rest) {
|
|
20
|
+
this.type = data?.data?.type;
|
|
21
|
+
this.id = data?.data?.id;
|
|
22
|
+
this.createdAt = data?.data?.createdAt
|
|
23
|
+
? new Date(data?.data?.createdAt)
|
|
24
|
+
: new Date();
|
|
25
|
+
this.updatedAt = data?.data?.updatedAt
|
|
26
|
+
? new Date(data?.data?.updatedAt)
|
|
27
|
+
: new Date();
|
|
28
|
+
this.guild = data?.guild;
|
|
29
|
+
this.manager = data?.manager;
|
|
30
|
+
this.baseUrl = data.baseUrl;
|
|
31
|
+
this.data = data;
|
|
32
|
+
this.rest = rest;
|
|
33
|
+
}
|
|
34
|
+
toString() {
|
|
35
|
+
return `<#${this.id}>`;
|
|
36
|
+
}
|
|
37
|
+
async setId(id) {
|
|
38
|
+
Assertion_1.Assertion.assertString(id);
|
|
39
|
+
const payload = { id };
|
|
40
|
+
const response = await this.rest.request({
|
|
41
|
+
method: "PATCH",
|
|
42
|
+
url: this.baseUrl,
|
|
43
|
+
payload,
|
|
44
|
+
});
|
|
45
|
+
this.id = response.id;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
async delete() {
|
|
49
|
+
await this.rest.request({
|
|
50
|
+
method: "delete",
|
|
51
|
+
url: this.baseUrl,
|
|
52
|
+
});
|
|
53
|
+
this.manager.cache.delete(this.type);
|
|
54
|
+
return this;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.Channel = Channel;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { Guild } from "../guild/Guild";
|
|
3
|
+
import { APIGuildGroupedChannel } from "../../types/api/APIGuildGroupedChannel";
|
|
4
|
+
import { Optional } from "../../types/api";
|
|
5
|
+
import { GroupedChannelManager } from "../../managers/groupedchannel/GroupedChannelManager";
|
|
6
|
+
export declare class GroupedChannel {
|
|
7
|
+
type: string;
|
|
8
|
+
ids: string[];
|
|
9
|
+
createdAt: Date;
|
|
10
|
+
updatedAt: Date;
|
|
11
|
+
manager: GroupedChannelManager;
|
|
12
|
+
/** The given guild */
|
|
13
|
+
readonly guild: Guild;
|
|
14
|
+
/** The rest client */
|
|
15
|
+
readonly rest: REST;
|
|
16
|
+
/**
|
|
17
|
+
* GroupedChannel channel
|
|
18
|
+
* @param data The channel's data
|
|
19
|
+
* @param guild The guild
|
|
20
|
+
* @param rest The rest client
|
|
21
|
+
*/
|
|
22
|
+
constructor(data: APIGuildGroupedChannel, guild: Guild, manager: GroupedChannelManager, rest: REST);
|
|
23
|
+
/**
|
|
24
|
+
* Fetches the channel
|
|
25
|
+
* @returns New Instance of the channel
|
|
26
|
+
*/
|
|
27
|
+
fetch(): Promise<GroupedChannel>;
|
|
28
|
+
setIds(ids: string[]): Promise<this>;
|
|
29
|
+
addId(id: string): Promise<this>;
|
|
30
|
+
removeId(id: string): Promise<this>;
|
|
31
|
+
update(data: Optional<APIGuildGroupedChannel>): Promise<GroupedChannel>;
|
|
32
|
+
toJSON(): Record<string, unknown>;
|
|
33
|
+
toString(): string;
|
|
34
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupedChannel = void 0;
|
|
4
|
+
const Routes_1 = require("../../rest/Routes");
|
|
5
|
+
const Assertion_1 = require("../../utils/Assertion");
|
|
6
|
+
class GroupedChannel {
|
|
7
|
+
type;
|
|
8
|
+
ids;
|
|
9
|
+
createdAt;
|
|
10
|
+
updatedAt;
|
|
11
|
+
manager;
|
|
12
|
+
/** The given guild */
|
|
13
|
+
guild;
|
|
14
|
+
/** The rest client */
|
|
15
|
+
rest;
|
|
16
|
+
/**
|
|
17
|
+
* GroupedChannel channel
|
|
18
|
+
* @param data The channel's data
|
|
19
|
+
* @param guild The guild
|
|
20
|
+
* @param rest The rest client
|
|
21
|
+
*/
|
|
22
|
+
constructor(data, guild, manager, rest) {
|
|
23
|
+
this.ids = data?.ids;
|
|
24
|
+
this.type = data?.type;
|
|
25
|
+
this.manager = manager;
|
|
26
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
27
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
28
|
+
this.guild = guild;
|
|
29
|
+
this.rest = rest;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Fetches the channel
|
|
33
|
+
* @returns New Instance of the channel
|
|
34
|
+
*/
|
|
35
|
+
async fetch() {
|
|
36
|
+
const route = Routes_1.Routes.fields(this.manager.baseUrl, this.type);
|
|
37
|
+
const response = await this.rest.request({
|
|
38
|
+
method: "get",
|
|
39
|
+
url: route,
|
|
40
|
+
});
|
|
41
|
+
const channel = new GroupedChannel(response, this.guild, this.manager, this.rest);
|
|
42
|
+
this.manager.cache.set(channel.type, channel);
|
|
43
|
+
return channel;
|
|
44
|
+
}
|
|
45
|
+
async setIds(ids) {
|
|
46
|
+
Assertion_1.Assertion.assertArray(ids);
|
|
47
|
+
const payload = { ids };
|
|
48
|
+
const route = Routes_1.Routes.fields(this.manager.baseUrl, this.type, "ids");
|
|
49
|
+
const response = await this.rest.request({
|
|
50
|
+
method: "PUT",
|
|
51
|
+
url: route,
|
|
52
|
+
payload,
|
|
53
|
+
});
|
|
54
|
+
this.ids = ids;
|
|
55
|
+
this.updatedAt = new Date();
|
|
56
|
+
this.rest.emit("groupedChannelUpdate", this, new GroupedChannel(response, this.guild, this.manager, this.rest));
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
async addId(id) {
|
|
60
|
+
Assertion_1.Assertion.assertString(id);
|
|
61
|
+
const payload = { id };
|
|
62
|
+
const route = Routes_1.Routes.fields(this.manager.baseUrl, this.type, "ids");
|
|
63
|
+
const response = await this.rest.request({
|
|
64
|
+
method: "POST",
|
|
65
|
+
url: route,
|
|
66
|
+
payload,
|
|
67
|
+
});
|
|
68
|
+
this.ids = response.ids;
|
|
69
|
+
this.updatedAt = new Date();
|
|
70
|
+
this.manager.set(response);
|
|
71
|
+
this.rest.emit("groupedChannelUpdate", this, new GroupedChannel(response, this.guild, this.manager, this.rest));
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
async removeId(id) {
|
|
75
|
+
Assertion_1.Assertion.assertString(id);
|
|
76
|
+
const payload = { id };
|
|
77
|
+
const route = Routes_1.Routes.fields(this.manager.baseUrl, this.type, "ids", id);
|
|
78
|
+
const response = await this.rest.request({
|
|
79
|
+
method: "DELETE",
|
|
80
|
+
url: route,
|
|
81
|
+
payload,
|
|
82
|
+
});
|
|
83
|
+
this.ids = response.ids;
|
|
84
|
+
this.updatedAt = new Date();
|
|
85
|
+
this.manager.set(response);
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
async update(data) {
|
|
89
|
+
const route = Routes_1.Routes.fields(this.manager.baseUrl, this.type);
|
|
90
|
+
const payload = data;
|
|
91
|
+
const response = await this.rest.request({
|
|
92
|
+
method: "patch",
|
|
93
|
+
url: route,
|
|
94
|
+
payload,
|
|
95
|
+
});
|
|
96
|
+
this.rest.emit("groupedChannelUpdate", this, new GroupedChannel(response, this.guild, this.manager, this.rest));
|
|
97
|
+
for (const k in response) {
|
|
98
|
+
if (k === "id" || k == "createdAt")
|
|
99
|
+
continue;
|
|
100
|
+
if (Object.hasOwn(this, k)) {
|
|
101
|
+
this[k] = response[k];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
this.updatedAt = new Date();
|
|
105
|
+
this.manager.cache.set(this.type, this);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
toJSON() {
|
|
109
|
+
const json = {};
|
|
110
|
+
for (const [key, value] of Object.entries(this)) {
|
|
111
|
+
if (typeof value !== "function") {
|
|
112
|
+
json[key] = value;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return json;
|
|
116
|
+
}
|
|
117
|
+
toString() {
|
|
118
|
+
return `${this.ids.length}`;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.GroupedChannel = GroupedChannel;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { GuildBetManager } from "../../managers/bet/GuildBetManager";
|
|
2
|
+
import { GuildBetUserManager } from "../../managers/betuser/GuildBetUserManager";
|
|
3
|
+
import { GroupedChannelManager } from "../../managers/groupedchannel/GroupedChannelManager";
|
|
4
|
+
import { GuildMatchManager } from "../../managers/match/GuildMatchManager";
|
|
5
|
+
import { GuildMediatorManager } from "../../managers/mediator/GuildMediatorManager";
|
|
6
|
+
import { MessagesManager } from "../../managers/messages/MessagesManager";
|
|
7
|
+
import { GuildPermissionManager } from "../../managers/permission/GuildPermissionManager";
|
|
8
|
+
import { GuildTicketManager } from "../../managers/ticket/GuildTicketManager";
|
|
9
|
+
import { GuildUserManager } from "../../managers/user/GuildUserManager";
|
|
10
|
+
import { REST } from "../../rest/REST";
|
|
11
|
+
import { Daily, GuildBlacklist } from "../../types/api";
|
|
12
|
+
import { APIGuild, DailyCategories, GuildScores, GuildStatus, GuildTicketConfiguration } from "../../types/api/APIGuild";
|
|
13
|
+
import { APIGuildEmoji } from "../../types/api/APIGuildEmoji";
|
|
14
|
+
import { APIGuildPermissions } from "../../types/api/APIGuildPermissions";
|
|
15
|
+
import { APIGuildRole } from "../../types/api/APIGuildRole";
|
|
16
|
+
import { GuildBetUser } from "../betuser/GuildBetUser";
|
|
17
|
+
import { GuildShop } from "../shop/GuildShop";
|
|
18
|
+
import { GuildUser } from "../user/GuildUser";
|
|
19
|
+
/** The Guild */
|
|
20
|
+
export declare class Guild {
|
|
21
|
+
/** The data of this guild */
|
|
22
|
+
data: APIGuild;
|
|
23
|
+
/** The rest client */
|
|
24
|
+
rest: REST;
|
|
25
|
+
/** The guild's id */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Guild's client key */
|
|
28
|
+
clientKey: string;
|
|
29
|
+
/** Guild Permissions */
|
|
30
|
+
permissions: APIGuildPermissions;
|
|
31
|
+
/** Guild Ticket */
|
|
32
|
+
tickets: GuildTicketManager;
|
|
33
|
+
/** Guild Ticket Configuration */
|
|
34
|
+
ticketsConfiguration: GuildTicketConfiguration;
|
|
35
|
+
/** Guild Daily Categories */
|
|
36
|
+
dailyCategories: DailyCategories[];
|
|
37
|
+
/** Guild Scores */
|
|
38
|
+
scores: GuildScores;
|
|
39
|
+
/** Guild Status */
|
|
40
|
+
status: GuildStatus;
|
|
41
|
+
/** Guild Channel */
|
|
42
|
+
channels: GroupedChannelManager;
|
|
43
|
+
/** Guild Categories */
|
|
44
|
+
categories: GroupedChannelManager;
|
|
45
|
+
/** Guild Blacklist */
|
|
46
|
+
blacklist: GuildBlacklist;
|
|
47
|
+
/** Guild Prefix */
|
|
48
|
+
prefix: string;
|
|
49
|
+
/** Guild Prices */
|
|
50
|
+
pricesAvailable: number[];
|
|
51
|
+
/** Guild Prices Used */
|
|
52
|
+
pricesOn: number[];
|
|
53
|
+
/** Guild Creation Date */
|
|
54
|
+
createdAt: Date;
|
|
55
|
+
/** Guild Updated Date */
|
|
56
|
+
updatedAt: Date;
|
|
57
|
+
/** Guild Bets */
|
|
58
|
+
bets: GuildBetManager;
|
|
59
|
+
/** Guild Users */
|
|
60
|
+
users: GuildUserManager;
|
|
61
|
+
/** Guild Bet Users */
|
|
62
|
+
betUsers: GuildBetUserManager;
|
|
63
|
+
/** Guild Matches */
|
|
64
|
+
matches: GuildMatchManager;
|
|
65
|
+
/** Guild Mediators */
|
|
66
|
+
mediators: GuildMediatorManager;
|
|
67
|
+
/** Guild Messages */
|
|
68
|
+
messages: MessagesManager;
|
|
69
|
+
/** Guild Emojis */
|
|
70
|
+
emojis: APIGuildEmoji[];
|
|
71
|
+
/** Guild Roles */
|
|
72
|
+
roles: APIGuildRole[];
|
|
73
|
+
/** Guild Shop */
|
|
74
|
+
shop: GuildShop;
|
|
75
|
+
permissionsManager: GuildPermissionManager;
|
|
76
|
+
/**
|
|
77
|
+
* The guild structure
|
|
78
|
+
* @param data The guild's data
|
|
79
|
+
* @param rest The rest client
|
|
80
|
+
*/
|
|
81
|
+
constructor(data: APIGuild, rest: REST);
|
|
82
|
+
fetch(): Promise<Guild>;
|
|
83
|
+
setBlacklist(value: boolean, user: GuildBetUser | GuildUser, adminId: string): Promise<this>;
|
|
84
|
+
setStatus(key: keyof GuildStatus, status: string): Promise<this>;
|
|
85
|
+
addPrice(price: number): Promise<this>;
|
|
86
|
+
removePrice(price: number): Promise<this>;
|
|
87
|
+
setPrefix(prefix: string): Promise<this>;
|
|
88
|
+
addDailyCategory(category: keyof Daily): Promise<this>;
|
|
89
|
+
removeDailyCategory(category: keyof Daily): Promise<this>;
|
|
90
|
+
}
|