@duque.edits/sdk 0.0.1
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/.gitattributes +2 -0
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/package.json +46 -0
- package/src/index.ts +30 -0
- package/src/managers/bet/GuildBetManager.ts +117 -0
- package/src/managers/betuser/GuildBetUserManager.ts +103 -0
- package/src/managers/channel/ChannelManager.ts +168 -0
- package/src/managers/groupedchannel/GroupedChannelManager.ts +117 -0
- package/src/managers/guild/GuildManager.ts +84 -0
- package/src/managers/match/GuildMatchManager.ts +115 -0
- package/src/managers/mediator/GuildMediatorManager.ts +111 -0
- package/src/managers/messages/MessagesManager.ts +95 -0
- package/src/managers/permission/GuildPermissionManager.ts +88 -0
- package/src/managers/product/GuildProductManager.ts +115 -0
- package/src/managers/ticket/GuildTicketManager.ts +112 -0
- package/src/managers/user/GuildUserManager.ts +116 -0
- package/src/rest/APIEndpoints.ts +11 -0
- package/src/rest/REST.ts +126 -0
- package/src/rest/Routes.ts +143 -0
- package/src/structures/Collection.ts +85 -0
- package/src/structures/bet/GuildBet.ts +332 -0
- package/src/structures/betuser/GuildBetUser.ts +247 -0
- package/src/structures/channel/Channel.ts +78 -0
- package/src/structures/groupedchannel/GroupedChannel.ts +165 -0
- package/src/structures/guild/Guild.ts +302 -0
- package/src/structures/match/GuildMatch.ts +385 -0
- package/src/structures/mediator/GuildMediator.ts +175 -0
- package/src/structures/product/GuildProduct.ts +217 -0
- package/src/structures/shop/GuildShop.ts +98 -0
- package/src/structures/ticket/GuildTicket.ts +227 -0
- package/src/structures/user/GuildUser.ts +248 -0
- package/src/types/api/APIBaseChannel.ts +13 -0
- package/src/types/api/APIBetChannel.ts +13 -0
- package/src/types/api/APIBetMessage.ts +13 -0
- package/src/types/api/APIGuild.ts +123 -0
- package/src/types/api/APIGuildBet.ts +69 -0
- package/src/types/api/APIGuildBetUser.ts +46 -0
- package/src/types/api/APIGuildChannel.ts +13 -0
- package/src/types/api/APIGuildEmoji.ts +16 -0
- package/src/types/api/APIGuildGroupedChannel.ts +13 -0
- package/src/types/api/APIGuildMatch.ts +67 -0
- package/src/types/api/APIGuildMediator.ts +18 -0
- package/src/types/api/APIGuildMessage.ts +13 -0
- package/src/types/api/APIGuildPermissions.ts +7 -0
- package/src/types/api/APIGuildRole.ts +13 -0
- package/src/types/api/APIGuildShop.ts +15 -0
- package/src/types/api/APIGuildTicket.ts +36 -0
- package/src/types/api/APIGuildUser.ts +45 -0
- package/src/types/api/APIMessage.ts +16 -0
- package/src/types/api/APIPlayer.ts +13 -0
- package/src/types/api/APIProduct.ts +27 -0
- package/src/types/api/index.ts +180 -0
- package/src/types/index.ts +24 -0
- package/src/utils/Assertion.ts +56 -0
- package/tests/index.ts +86 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { REST } from "../../rest/REST";
|
|
2
|
+
import { Routes } from "../../rest/Routes";
|
|
3
|
+
import { Guild } from "../guild/Guild";
|
|
4
|
+
import { APIGuildGroupedChannel } from "../../types/api/APIGuildGroupedChannel";
|
|
5
|
+
import { Confirm, Optional } from "../../types/api";
|
|
6
|
+
import { Assertion } from "../../utils/Assertion";
|
|
7
|
+
import { GroupedChannelManager } from "../../managers/groupedchannel/GroupedChannelManager";
|
|
8
|
+
|
|
9
|
+
export class GroupedChannel {
|
|
10
|
+
type: string;
|
|
11
|
+
ids: string[];
|
|
12
|
+
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
updatedAt: Date;
|
|
15
|
+
manager: GroupedChannelManager;
|
|
16
|
+
|
|
17
|
+
/** The given guild */
|
|
18
|
+
readonly guild: Guild;
|
|
19
|
+
|
|
20
|
+
/** The rest client */
|
|
21
|
+
readonly rest: REST;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* GroupedChannel channel
|
|
25
|
+
* @param data The channel's data
|
|
26
|
+
* @param guild The guild
|
|
27
|
+
* @param rest The rest client
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
data: APIGuildGroupedChannel,
|
|
32
|
+
guild: Guild,
|
|
33
|
+
manager: GroupedChannelManager,
|
|
34
|
+
rest: REST
|
|
35
|
+
) {
|
|
36
|
+
this.ids = data?.ids;
|
|
37
|
+
this.type = data?.type;
|
|
38
|
+
|
|
39
|
+
this.manager = manager;
|
|
40
|
+
|
|
41
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
42
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
43
|
+
|
|
44
|
+
this.guild = guild;
|
|
45
|
+
this.rest = rest;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Fetches the channel
|
|
50
|
+
* @returns New Instance of the channel
|
|
51
|
+
*/
|
|
52
|
+
async fetch(): Promise<GroupedChannel> {
|
|
53
|
+
const route = Routes.fields(this.manager.baseUrl, this.type);
|
|
54
|
+
const response = await this.rest.request<APIGuildGroupedChannel, {}>({
|
|
55
|
+
method: "get",
|
|
56
|
+
url: route,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const channel = new GroupedChannel(
|
|
60
|
+
response,
|
|
61
|
+
this.guild,
|
|
62
|
+
this.manager,
|
|
63
|
+
this.rest
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
this.manager.cache.set(channel.type, channel);
|
|
67
|
+
return channel;
|
|
68
|
+
}
|
|
69
|
+
async setIds(ids: string[]) {
|
|
70
|
+
Assertion.assertArray(ids);
|
|
71
|
+
|
|
72
|
+
const payload = { ids };
|
|
73
|
+
const route = Routes.fields(this.manager.baseUrl, this.type, "ids");
|
|
74
|
+
const response = await this.rest.request<APIGuildGroupedChannel, {}>({
|
|
75
|
+
method: "PUT",
|
|
76
|
+
url: route,
|
|
77
|
+
payload,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
this.ids = ids;
|
|
81
|
+
this.updatedAt = new Date();
|
|
82
|
+
this.rest.emit("groupedChannelUpdate", this,
|
|
83
|
+
new GroupedChannel(response, this.guild, this.manager, this.rest));
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
async addId(id: string) {
|
|
87
|
+
Assertion.assertString(id);
|
|
88
|
+
|
|
89
|
+
const payload = { id };
|
|
90
|
+
const route = Routes.fields(this.manager.baseUrl, this.type, "ids");
|
|
91
|
+
const response = await this.rest.request<APIGuildGroupedChannel, {}>({
|
|
92
|
+
method: "POST",
|
|
93
|
+
url: route,
|
|
94
|
+
payload,
|
|
95
|
+
});
|
|
96
|
+
this.ids = response.ids;
|
|
97
|
+
|
|
98
|
+
this.updatedAt = new Date();
|
|
99
|
+
|
|
100
|
+
this.manager.set(response);
|
|
101
|
+
this.rest.emit("groupedChannelUpdate", this,
|
|
102
|
+
new GroupedChannel(response, this.guild, this.manager, this.rest));
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async removeId(id: string) {
|
|
107
|
+
Assertion.assertString(id);
|
|
108
|
+
|
|
109
|
+
const payload = { id };
|
|
110
|
+
const route = Routes.fields(this.manager.baseUrl, this.type, "ids", id);
|
|
111
|
+
const response = await this.rest.request<APIGuildGroupedChannel, {}>({
|
|
112
|
+
method: "DELETE",
|
|
113
|
+
url: route,
|
|
114
|
+
payload,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this.ids = response.ids;
|
|
118
|
+
this.updatedAt = new Date();
|
|
119
|
+
this.rest.emit("groupedChannelUpdate", this,
|
|
120
|
+
new GroupedChannel(response, this.guild, this.manager, this.rest));
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
async update(
|
|
124
|
+
data: Optional<APIGuildGroupedChannel>
|
|
125
|
+
): Promise<GroupedChannel> {
|
|
126
|
+
const route = Routes.fields(this.manager.baseUrl, this.type);
|
|
127
|
+
const payload = data;
|
|
128
|
+
|
|
129
|
+
const response = await this.rest.request<
|
|
130
|
+
APIGuildGroupedChannel,
|
|
131
|
+
typeof payload
|
|
132
|
+
>({
|
|
133
|
+
method: "patch",
|
|
134
|
+
url: route,
|
|
135
|
+
payload,
|
|
136
|
+
});
|
|
137
|
+
this.rest.emit(
|
|
138
|
+
"groupedChannelUpdate",
|
|
139
|
+
this,
|
|
140
|
+
new GroupedChannel(response, this.guild, this.manager, this.rest)
|
|
141
|
+
);
|
|
142
|
+
for (const k in response) {
|
|
143
|
+
if (k === "id" || k == "createdAt") continue;
|
|
144
|
+
if (Object.hasOwn(this, k)) {
|
|
145
|
+
(this as any)[k] = response[k as keyof APIGuildGroupedChannel];
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this.updatedAt = new Date();
|
|
150
|
+
this.manager.cache.set(this.type, this);
|
|
151
|
+
return this;
|
|
152
|
+
}
|
|
153
|
+
toJSON() {
|
|
154
|
+
const json: Record<string, unknown> = {};
|
|
155
|
+
for (const [key, value] of Object.entries(this)) {
|
|
156
|
+
if (typeof value !== "function") {
|
|
157
|
+
json[key] = value;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return json;
|
|
161
|
+
}
|
|
162
|
+
toString() {
|
|
163
|
+
return `${this.ids.length}`;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
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 { Routes } from "../../rest/Routes";
|
|
12
|
+
import { GuildBlacklist } from "../../types/api";
|
|
13
|
+
import { APIBetMessage } from "../../types/api/APIBetMessage";
|
|
14
|
+
import {
|
|
15
|
+
APIGuild,
|
|
16
|
+
GuildScores,
|
|
17
|
+
GuildStatus,
|
|
18
|
+
GuildTicketConfiguration,
|
|
19
|
+
} from "../../types/api/APIGuild";
|
|
20
|
+
import { APIGuildEmoji } from "../../types/api/APIGuildEmoji";
|
|
21
|
+
import { APIGuildMediator } from "../../types/api/APIGuildMediator";
|
|
22
|
+
import { APIGuildPermissions } from "../../types/api/APIGuildPermissions";
|
|
23
|
+
import { APIGuildRole } from "../../types/api/APIGuildRole";
|
|
24
|
+
import { APIGuildShop } from "../../types/api/APIGuildShop";
|
|
25
|
+
import { APIGuildTicket } from "../../types/api/APIGuildTicket";
|
|
26
|
+
import { APIGuildUser } from "../../types/api/APIGuildUser";
|
|
27
|
+
import { Assertion } from "../../utils/Assertion";
|
|
28
|
+
import { GuildBetUser } from "../betuser/GuildBetUser";
|
|
29
|
+
import { GuildShop } from "../shop/GuildShop";
|
|
30
|
+
import { GuildUser } from "../user/GuildUser";
|
|
31
|
+
|
|
32
|
+
/** The Guild */
|
|
33
|
+
export class Guild {
|
|
34
|
+
/** The data of this guild */
|
|
35
|
+
data: APIGuild;
|
|
36
|
+
|
|
37
|
+
/** The rest client */
|
|
38
|
+
rest: REST;
|
|
39
|
+
|
|
40
|
+
/** The guild's id */
|
|
41
|
+
id: string;
|
|
42
|
+
|
|
43
|
+
/** Guild's client key */
|
|
44
|
+
clientKey: string;
|
|
45
|
+
|
|
46
|
+
/** Guild Permissions */
|
|
47
|
+
permissions: APIGuildPermissions;
|
|
48
|
+
|
|
49
|
+
/** Guild Ticket */
|
|
50
|
+
tickets: GuildTicketManager;
|
|
51
|
+
|
|
52
|
+
/** Guild Ticket Configuration */
|
|
53
|
+
ticketsConfiguration: GuildTicketConfiguration;
|
|
54
|
+
|
|
55
|
+
/** Guild Daily Categories */
|
|
56
|
+
dailyCategories: ["coins", "credit"];
|
|
57
|
+
|
|
58
|
+
/** Guild Scores */
|
|
59
|
+
scores: GuildScores;
|
|
60
|
+
|
|
61
|
+
/** Guild Status */
|
|
62
|
+
status: GuildStatus;
|
|
63
|
+
|
|
64
|
+
/** Guild Channel */
|
|
65
|
+
channels: GroupedChannelManager;
|
|
66
|
+
|
|
67
|
+
/** Guild Categories */
|
|
68
|
+
categories: GroupedChannelManager;
|
|
69
|
+
|
|
70
|
+
/** Guild Blacklist */
|
|
71
|
+
blacklist: GuildBlacklist;
|
|
72
|
+
|
|
73
|
+
/** Guild Prefix */
|
|
74
|
+
prefix: string;
|
|
75
|
+
|
|
76
|
+
/** Guild Prices */
|
|
77
|
+
pricesAvailable: number[];
|
|
78
|
+
|
|
79
|
+
/** Guild Prices Used */
|
|
80
|
+
pricesOn: number[];
|
|
81
|
+
|
|
82
|
+
/** Guild Creation Date */
|
|
83
|
+
createdAt: Date;
|
|
84
|
+
|
|
85
|
+
/** Guild Updated Date */
|
|
86
|
+
updatedAt: Date;
|
|
87
|
+
|
|
88
|
+
/** Guild Bets */
|
|
89
|
+
bets: GuildBetManager;
|
|
90
|
+
|
|
91
|
+
/** Guild Users */
|
|
92
|
+
users: GuildUserManager;
|
|
93
|
+
|
|
94
|
+
/** Guild Bet Users */
|
|
95
|
+
betUsers: GuildBetUserManager;
|
|
96
|
+
|
|
97
|
+
/** Guild Matches */
|
|
98
|
+
matches: GuildMatchManager;
|
|
99
|
+
|
|
100
|
+
/** Guild Mediators */
|
|
101
|
+
mediators: GuildMediatorManager;
|
|
102
|
+
|
|
103
|
+
/** Guild Messages */
|
|
104
|
+
messages: MessagesManager;
|
|
105
|
+
|
|
106
|
+
/** Guild Emojis */
|
|
107
|
+
emojis: APIGuildEmoji[];
|
|
108
|
+
|
|
109
|
+
/** Guild Roles */
|
|
110
|
+
roles: APIGuildRole[];
|
|
111
|
+
|
|
112
|
+
/** Guild Shop */
|
|
113
|
+
shop: GuildShop;
|
|
114
|
+
|
|
115
|
+
permissionsManager: GuildPermissionManager;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* The guild structure
|
|
119
|
+
* @param data The guild's data
|
|
120
|
+
* @param rest The rest client
|
|
121
|
+
*/
|
|
122
|
+
constructor(data: APIGuild, rest: REST) {
|
|
123
|
+
this.data = data;
|
|
124
|
+
this.rest = rest;
|
|
125
|
+
|
|
126
|
+
this.id = data?.id;
|
|
127
|
+
this.clientKey = data?.clientKey;
|
|
128
|
+
this.prefix = data?.prefix;
|
|
129
|
+
this.status = data?.status;
|
|
130
|
+
|
|
131
|
+
this.ticketsConfiguration = data?.ticketsConfiguration;
|
|
132
|
+
this.dailyCategories = data?.dailyCategories;
|
|
133
|
+
this.scores = data?.scores;
|
|
134
|
+
|
|
135
|
+
this.messages = new MessagesManager(this, this.id, rest);
|
|
136
|
+
this.roles = data?.roles;
|
|
137
|
+
this.emojis = data?.emojis;
|
|
138
|
+
|
|
139
|
+
this.blacklist = data?.blacklist;
|
|
140
|
+
this.pricesAvailable = data?.pricesAvailable;
|
|
141
|
+
this.pricesOn = data?.pricesOn;
|
|
142
|
+
|
|
143
|
+
this.shop = new GuildShop(data?.shop, this, rest);
|
|
144
|
+
|
|
145
|
+
this.mediators = new GuildMediatorManager(this, rest);
|
|
146
|
+
this.bets = new GuildBetManager(this, rest);
|
|
147
|
+
this.users = new GuildUserManager(this, rest);
|
|
148
|
+
this.betUsers = new GuildBetUserManager(this, rest);
|
|
149
|
+
this.matches = new GuildMatchManager(this, rest);
|
|
150
|
+
this.channels = new GroupedChannelManager(this, "channels", rest);
|
|
151
|
+
this.categories = new GroupedChannelManager(this, "categories", rest);
|
|
152
|
+
this.tickets = new GuildTicketManager(this, rest);
|
|
153
|
+
this.permissionsManager = new GuildPermissionManager(this, rest);
|
|
154
|
+
|
|
155
|
+
this.bets.setAll(data?.bets);
|
|
156
|
+
this.users.setAll(data?.users);
|
|
157
|
+
this.betUsers.setAll(data?.betUsers);
|
|
158
|
+
this.channels.setAll(data?.channels);
|
|
159
|
+
this.categories.setAll(data?.categories);
|
|
160
|
+
this.matches.setAll(data?.matches);
|
|
161
|
+
this.mediators.setAll(data?.mediators);
|
|
162
|
+
this.tickets.setAll(data?.tickets);
|
|
163
|
+
this.permissionsManager.setAll(data?.permissions);
|
|
164
|
+
this.messages.setAll(data?.messages);
|
|
165
|
+
|
|
166
|
+
this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
|
|
167
|
+
this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async fetch(): Promise<Guild> {
|
|
171
|
+
const route = Routes.guilds.get(this.id);
|
|
172
|
+
const response = await this.rest.request<APIGuild, {}>({
|
|
173
|
+
method: "get",
|
|
174
|
+
url: route,
|
|
175
|
+
});
|
|
176
|
+
const guild = new Guild(response, this.rest);
|
|
177
|
+
this.rest.guilds.cache.set(guild.id, guild);
|
|
178
|
+
|
|
179
|
+
return guild;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async setBlacklist(
|
|
183
|
+
value: boolean,
|
|
184
|
+
user: GuildBetUser | GuildUser,
|
|
185
|
+
adminId: string
|
|
186
|
+
) {
|
|
187
|
+
Assertion.assertBoolean(value);
|
|
188
|
+
Assertion.assertString(adminId);
|
|
189
|
+
const is_in_blacklist = this.blacklist.find((u) => u.id == user.id);
|
|
190
|
+
if (is_in_blacklist && value == true) return this;
|
|
191
|
+
|
|
192
|
+
const route = Routes.guilds.resource(this.id, "blacklist");
|
|
193
|
+
const payload = { id: user.id, name: user.name, adminId, value };
|
|
194
|
+
|
|
195
|
+
const [response] = await Promise.all([
|
|
196
|
+
this.rest.request<APIGuild, typeof payload>({
|
|
197
|
+
method: "PATCH",
|
|
198
|
+
url: route,
|
|
199
|
+
payload,
|
|
200
|
+
}),
|
|
201
|
+
user.setBlacklist(value),
|
|
202
|
+
]);
|
|
203
|
+
this.blacklist = response.blacklist;
|
|
204
|
+
this.rest.guilds.cache.set(this.id, this);
|
|
205
|
+
this.rest.emit("guildUpdate", this);
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
async setStatus(key: keyof GuildStatus, status: string) {
|
|
209
|
+
Assertion.assertString(status);
|
|
210
|
+
|
|
211
|
+
status = status.toLowerCase();
|
|
212
|
+
|
|
213
|
+
const route = Routes.fields(Routes.guilds.resource(this.id, "status"), key);
|
|
214
|
+
const payload = { status };
|
|
215
|
+
const response = await this.rest.request<APIGuild, typeof payload>({
|
|
216
|
+
method: "PATCH",
|
|
217
|
+
url: route,
|
|
218
|
+
payload,
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
this.status = response.status;
|
|
222
|
+
this.rest.guilds.cache.set(this.id, this);
|
|
223
|
+
this.rest.emit("guildUpdate", this);
|
|
224
|
+
return this;
|
|
225
|
+
}
|
|
226
|
+
async addPrice(price: number) {
|
|
227
|
+
Assertion.assertNumber(price);
|
|
228
|
+
|
|
229
|
+
const route = Routes.fields(
|
|
230
|
+
Routes.guilds.resource(this.id, "price"),
|
|
231
|
+
"pricesOn"
|
|
232
|
+
);
|
|
233
|
+
const payload = { price };
|
|
234
|
+
const response = await this.rest.request<APIGuild, typeof payload>({
|
|
235
|
+
method: "PATCH",
|
|
236
|
+
url: route,
|
|
237
|
+
payload,
|
|
238
|
+
});
|
|
239
|
+
this.pricesAvailable = response.pricesAvailable;
|
|
240
|
+
this.pricesOn = response.pricesOn;
|
|
241
|
+
this.rest.guilds.cache.set(this.id, this);
|
|
242
|
+
this.rest.emit("guildUpdate", this);
|
|
243
|
+
return this;
|
|
244
|
+
}
|
|
245
|
+
async removePrice(price: number) {
|
|
246
|
+
Assertion.assertNumber(price);
|
|
247
|
+
|
|
248
|
+
const route = Routes.fields(
|
|
249
|
+
Routes.guilds.resource(this.id, "price"),
|
|
250
|
+
"pricesOn"
|
|
251
|
+
);
|
|
252
|
+
const payload = { price };
|
|
253
|
+
const response = await this.rest.request<APIGuild, typeof payload>({
|
|
254
|
+
method: "DELETE",
|
|
255
|
+
url: route,
|
|
256
|
+
payload,
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
this.pricesAvailable = response.pricesAvailable;
|
|
260
|
+
this.pricesOn = response.pricesOn;
|
|
261
|
+
this.rest.guilds.cache.set(this.id, this);
|
|
262
|
+
this.rest.emit("guildUpdate", this);
|
|
263
|
+
return this;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
async setPrefix(prefix: string) {
|
|
267
|
+
Assertion.assertString(prefix);
|
|
268
|
+
|
|
269
|
+
const route = Routes.fields(Routes.guilds.resource(this.id, "prefix"));
|
|
270
|
+
const payload = { prefix };
|
|
271
|
+
const response = await this.rest.request<APIGuild, typeof payload>({
|
|
272
|
+
method: "PATCH",
|
|
273
|
+
url: route,
|
|
274
|
+
payload,
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
this.prefix = response.prefix;
|
|
278
|
+
this.rest.guilds.cache.set(this.id, this);
|
|
279
|
+
this.rest.emit("guildUpdate", this);
|
|
280
|
+
return this;
|
|
281
|
+
}
|
|
282
|
+
async addDailyCategory(category: string) {
|
|
283
|
+
Assertion.assertString(category);
|
|
284
|
+
|
|
285
|
+
const route = Routes.fields(
|
|
286
|
+
Routes.guilds.resource(this.id, "dailyCategories")
|
|
287
|
+
);
|
|
288
|
+
const categories = [...new Set([...this.dailyCategories, category])];
|
|
289
|
+
|
|
290
|
+
const payload = { categories };
|
|
291
|
+
const response = await this.rest.request<APIGuild, typeof payload>({
|
|
292
|
+
method: "PATCH",
|
|
293
|
+
url: route,
|
|
294
|
+
payload,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
this.dailyCategories = response.dailyCategories;
|
|
298
|
+
this.rest.guilds.cache.set(this.id, this);
|
|
299
|
+
this.rest.emit("guildUpdate", this);
|
|
300
|
+
return this;
|
|
301
|
+
}
|
|
302
|
+
}
|