@duque.edits/sdk 0.0.5 → 0.0.7

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.
@@ -28,6 +28,7 @@ class GuildBetManager {
28
28
  const response = await this.rest.request({
29
29
  method: "POST",
30
30
  url: route,
31
+ payload
31
32
  });
32
33
  const bet = this.set(response);
33
34
  return bet;
@@ -65,7 +66,7 @@ class GuildBetManager {
65
66
  return this.cache;
66
67
  }
67
68
  set(data) {
68
- if (!data._id)
69
+ if (!data?._id)
69
70
  return;
70
71
  const bet = new GuildBet_1.GuildBet(data, this.guild, this, this.rest);
71
72
  this.cache.set(bet._id, bet);
@@ -23,7 +23,7 @@ class GuildBetUserManager {
23
23
  this.cache = new Collection_1.Collection("betUsers");
24
24
  }
25
25
  set(data) {
26
- if (!data.id)
26
+ if (!data?.id)
27
27
  return;
28
28
  const user = new GuildBetUser_1.GuildBetUser(data, this, this.rest);
29
29
  this.rest.betUsers.set(user.id, user);
@@ -76,7 +76,7 @@ class ChannelManager {
76
76
  return this.cache;
77
77
  }
78
78
  set(data) {
79
- if (!data.type)
79
+ if (!data?.type)
80
80
  return;
81
81
  const channel = new Channel_1.Channel({
82
82
  baseUrl: Routes_1.Routes.guilds[this.structure.key].resource(this.guild.id, this.structure._id, "channels"),
@@ -28,6 +28,7 @@ class GuildMediatorManager {
28
28
  const response = await this.rest.request({
29
29
  method: "POST",
30
30
  url: route,
31
+ payload
31
32
  });
32
33
  const mediator = this.set(response);
33
34
  return mediator;
@@ -60,7 +61,7 @@ class GuildMediatorManager {
60
61
  if (!data.id)
61
62
  return;
62
63
  const mediator = new GuildMediator_1.GuildMediator(data, this.guild, this, this.rest);
63
- this.cache.set(data.id, mediator);
64
+ this.cache.set(data?.id, mediator);
64
65
  this.rest.mediators.set(mediator.id, mediator);
65
66
  return mediator;
66
67
  }
@@ -28,6 +28,7 @@ class GuildProductManager {
28
28
  const response = await this.rest.request({
29
29
  method: "POST",
30
30
  url: route,
31
+ payload
31
32
  });
32
33
  const product = this.set(response);
33
34
  return product;
@@ -60,7 +61,7 @@ class GuildProductManager {
60
61
  return this.cache;
61
62
  }
62
63
  set(data) {
63
- if (!data.id)
64
+ if (!data?.id)
64
65
  return;
65
66
  const product = new GuildProduct_1.GuildProduct(data, this, this.rest);
66
67
  this.cache.set(data.id, product);
@@ -28,6 +28,7 @@ class GuildTicketManager {
28
28
  const response = await this.rest.request({
29
29
  method: "POST",
30
30
  url: route,
31
+ payload,
31
32
  });
32
33
  const ticket = this.set(response);
33
34
  return ticket;
@@ -60,10 +61,10 @@ class GuildTicketManager {
60
61
  return this.cache;
61
62
  }
62
63
  set(data) {
63
- if (!data.id)
64
+ if (!data?.id)
64
65
  return;
65
66
  const ticket = new GuildTicket_1.GuildTicket(data, this.guild, this, this.rest);
66
- this.cache.set(data.id.toString(), ticket);
67
+ this.cache.set(data?.id?.toString(), ticket);
67
68
  return ticket;
68
69
  }
69
70
  setAll(data) {
@@ -66,7 +66,7 @@ class GuildUserManager {
66
66
  return user;
67
67
  }
68
68
  set(data) {
69
- if (!data.id)
69
+ if (!data?.id)
70
70
  return;
71
71
  const user = new GuildUser_1.GuildUser(data, this, this.rest);
72
72
  this.cache.set(user?.id, user);
@@ -83,7 +83,7 @@ class GuildBet {
83
83
  this.manager = manager;
84
84
  this.key = "bets";
85
85
  this.channels = new ChannelManager_1.ChannelManager(guild, this, rest);
86
- this.messages = new MessagesManager_1.MessagesManager(this?.guild, this?._id, rest);
86
+ this.messages = new MessagesManager_1.MessagesManager(this?.guild, `bets/${data?._id}`, rest);
87
87
  this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
88
88
  this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
89
89
  this.guild = guild;
@@ -82,7 +82,7 @@ class GroupedChannel {
82
82
  });
83
83
  this.ids = response.ids;
84
84
  this.updatedAt = new Date();
85
- this.rest.emit("groupedChannelUpdate", this, new GroupedChannel(response, this.guild, this.manager, this.rest));
85
+ this.manager.set(response);
86
86
  return this;
87
87
  }
88
88
  async update(data) {
@@ -8,8 +8,8 @@ import { GuildPermissionManager } from "../../managers/permission/GuildPermissio
8
8
  import { GuildTicketManager } from "../../managers/ticket/GuildTicketManager";
9
9
  import { GuildUserManager } from "../../managers/user/GuildUserManager";
10
10
  import { REST } from "../../rest/REST";
11
- import { GuildBlacklist } from "../../types/api";
12
- import { APIGuild, GuildScores, GuildStatus, GuildTicketConfiguration } from "../../types/api/APIGuild";
11
+ import { Daily, GuildBlacklist } from "../../types/api";
12
+ import { APIGuild, DailyCategories, GuildScores, GuildStatus, GuildTicketConfiguration } from "../../types/api/APIGuild";
13
13
  import { APIGuildEmoji } from "../../types/api/APIGuildEmoji";
14
14
  import { APIGuildPermissions } from "../../types/api/APIGuildPermissions";
15
15
  import { APIGuildRole } from "../../types/api/APIGuildRole";
@@ -33,7 +33,7 @@ export declare class Guild {
33
33
  /** Guild Ticket Configuration */
34
34
  ticketsConfiguration: GuildTicketConfiguration;
35
35
  /** Guild Daily Categories */
36
- dailyCategories: ["coins", "credit"];
36
+ dailyCategories: DailyCategories[];
37
37
  /** Guild Scores */
38
38
  scores: GuildScores;
39
39
  /** Guild Status */
@@ -85,5 +85,6 @@ export declare class Guild {
85
85
  addPrice(price: number): Promise<this>;
86
86
  removePrice(price: number): Promise<this>;
87
87
  setPrefix(prefix: string): Promise<this>;
88
- addDailyCategory(category: string): Promise<this>;
88
+ addDailyCategory(category: keyof Daily): Promise<this>;
89
+ removeDailyCategory(category: keyof Daily): Promise<this>;
89
90
  }
@@ -83,12 +83,12 @@ class Guild {
83
83
  this.prefix = data?.prefix;
84
84
  this.status = data?.status;
85
85
  this.ticketsConfiguration = data?.ticketsConfiguration;
86
+ this.permissions = data?.permissions;
86
87
  this.dailyCategories = data?.dailyCategories;
87
88
  this.scores = data?.scores;
88
89
  this.messages = new MessagesManager_1.MessagesManager(this, this.id, rest);
89
90
  this.roles = data?.roles;
90
91
  this.emojis = data?.emojis;
91
- this.blacklist = data?.blacklist;
92
92
  this.pricesAvailable = data?.pricesAvailable;
93
93
  this.pricesOn = data?.pricesOn;
94
94
  this.shop = new GuildShop_1.GuildShop(data?.shop, this, rest);
@@ -113,6 +113,15 @@ class Guild {
113
113
  this.messages.setAll(data?.messages);
114
114
  this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
115
115
  this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
116
+ this.blacklist = [];
117
+ for (let blacklisted of data?.blacklist) {
118
+ this.blacklist.push({
119
+ addedBy: blacklisted.addedBy,
120
+ id: blacklisted.id,
121
+ createdAt: blacklisted?.createdAt ? new Date(blacklisted?.createdAt) : new Date(),
122
+ updatedAt: blacklisted?.createdAt ? new Date(blacklisted?.createdAt) : new Date(),
123
+ });
124
+ }
116
125
  }
117
126
  async fetch() {
118
127
  const route = Routes_1.Routes.guilds.get(this.id);
@@ -128,7 +137,7 @@ class Guild {
128
137
  Assertion_1.Assertion.assertBoolean(value);
129
138
  Assertion_1.Assertion.assertString(adminId);
130
139
  const is_in_blacklist = this.blacklist.find((u) => u.id == user.id);
131
- if (is_in_blacklist && value == true)
140
+ if (is_in_blacklist && value === true)
132
141
  return this;
133
142
  const route = Routes_1.Routes.guilds.resource(this.id, "blacklist");
134
143
  const payload = { id: user.id, name: user.name, adminId, value };
@@ -140,9 +149,17 @@ class Guild {
140
149
  }),
141
150
  user.setBlacklist(value),
142
151
  ]);
143
- this.blacklist = response.blacklist;
152
+ for (let blacklisted of response?.blacklist) {
153
+ this.blacklist.push({
154
+ addedBy: blacklisted.addedBy,
155
+ id: blacklisted.id,
156
+ createdAt: blacklisted?.createdAt ? new Date(blacklisted?.createdAt) : new Date(),
157
+ updatedAt: blacklisted?.createdAt ? new Date(blacklisted?.createdAt) : new Date(),
158
+ });
159
+ }
144
160
  this.rest.guilds.cache.set(this.id, this);
145
161
  this.rest.emit("guildUpdate", this);
162
+ console.log({ bl: response?.blacklist });
146
163
  return this;
147
164
  }
148
165
  async setStatus(key, status) {
@@ -207,10 +224,24 @@ class Guild {
207
224
  async addDailyCategory(category) {
208
225
  Assertion_1.Assertion.assertString(category);
209
226
  const route = Routes_1.Routes.fields(Routes_1.Routes.guilds.resource(this.id, "dailyCategories"));
227
+ const payload = { category };
228
+ const response = await this.rest.request({
229
+ method: "POST",
230
+ url: route,
231
+ payload,
232
+ });
233
+ this.dailyCategories = response.dailyCategories;
234
+ this.rest.guilds.cache.set(this.id, this);
235
+ this.rest.emit("guildUpdate", this);
236
+ return this;
237
+ }
238
+ async removeDailyCategory(category) {
239
+ Assertion_1.Assertion.assertString(category);
240
+ const route = Routes_1.Routes.fields(Routes_1.Routes.guilds.resources(this.id, "dailyCategories", category));
210
241
  const categories = [...new Set([...this.dailyCategories, category])];
211
242
  const payload = { categories };
212
243
  const response = await this.rest.request({
213
- method: "PATCH",
244
+ method: "DELETE",
214
245
  url: route,
215
246
  payload,
216
247
  });
@@ -78,7 +78,7 @@ class GuildMatch {
78
78
  this.mvpId = data?.mvpId;
79
79
  this.key = "matches";
80
80
  this.channels = new ChannelManager_1.ChannelManager(guild, this, rest);
81
- this.messages = new MessagesManager_1.MessagesManager(guild, this?._id, rest);
81
+ this.messages = new MessagesManager_1.MessagesManager(guild, `matches/${data?._id}`, rest);
82
82
  this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
83
83
  this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
84
84
  this.guild = guild;
@@ -262,7 +262,7 @@ class GuildMatch {
262
262
  url: route,
263
263
  payload,
264
264
  });
265
- console.log({ response });
265
+ ({ response });
266
266
  this.players = response.players;
267
267
  this.rest.matches.set(this._id, this);
268
268
  this.manager.cache.set(this._id, this);
@@ -297,9 +297,9 @@ class GuildMatch {
297
297
  continue;
298
298
  if (Object.hasOwn(this, k)) {
299
299
  if (k === "channels") {
300
- console.log({ chs: response["channels"] });
300
+ ({ chs: response["channels"] });
301
301
  this.channels.setAll(response["channels"]);
302
- console.log({ chs2: this.channels.cache });
302
+ ({ chs2: this.channels.cache });
303
303
  continue;
304
304
  }
305
305
  if (k === "messages") {
@@ -6,6 +6,7 @@ import { MessagesManager } from "../../managers/messages/MessagesManager";
6
6
  export declare class GuildTicket {
7
7
  /** Ticket's id */
8
8
  id: string;
9
+ _id: string;
9
10
  /** Ticket's creator id */
10
11
  creatorId: string;
11
12
  /** Ticket's admin id */
@@ -7,6 +7,7 @@ const MessagesManager_1 = require("../../managers/messages/MessagesManager");
7
7
  class GuildTicket {
8
8
  /** Ticket's id */
9
9
  id;
10
+ _id;
10
11
  /** Ticket's creator id */
11
12
  creatorId;
12
13
  /** Ticket's admin id */
@@ -39,7 +40,8 @@ class GuildTicket {
39
40
  * @param rest The rest client
40
41
  */
41
42
  constructor(data, guild, manager, rest) {
42
- this.id = data?.id.toString();
43
+ this.id = data?.id?.toString();
44
+ this._id = data?._id?.toString();
43
45
  this.creatorId = data?.creatorId;
44
46
  this.adminId = data?.adminId;
45
47
  this.customerRating = data.customerRating;
@@ -47,7 +49,7 @@ class GuildTicket {
47
49
  this.type = data?.type;
48
50
  this.status = data?.status;
49
51
  this.channelId = data?.channelId;
50
- this.messages = new MessagesManager_1.MessagesManager(this.guild, this.id, rest);
52
+ this.messages = new MessagesManager_1.MessagesManager(guild, `tickets/${data?.id}`, rest);
51
53
  this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
52
54
  this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
53
55
  this.guild = guild;
@@ -113,6 +115,7 @@ class GuildTicket {
113
115
  const response = await this.rest.request({
114
116
  method: "PATCH",
115
117
  url: route,
118
+ payload
116
119
  });
117
120
  this.customerRating = response.customerRating;
118
121
  this.manager.cache.set(this.id, this);
@@ -125,7 +125,7 @@ class GuildUser {
125
125
  */
126
126
  async update(data) {
127
127
  if (!data.type)
128
- data.type = 'add';
128
+ data.type = "add";
129
129
  const route = Routes_1.Routes.guilds.users.get(this.manager.guild.id, this.id);
130
130
  const payload = {};
131
131
  const numericFields = ["coins", "wins", "points", "losses", "mvps", "games"];
@@ -134,7 +134,6 @@ class GuildUser {
134
134
  for (const key in data) {
135
135
  if (key === "type")
136
136
  continue;
137
- console.log({ wdwdqwdqwdwqdwd: false });
138
137
  const value = data[key];
139
138
  if (numericFields.includes(key)) {
140
139
  const current = this[key];
@@ -14,7 +14,7 @@ import { APIMessage } from "./APIMessage";
14
14
  /** Ticket's configuration */
15
15
  export interface GuildTicketConfiguration {
16
16
  /** Guild's categories */
17
- categories: APITicketCategory;
17
+ categories: APITicketCategory[];
18
18
  }
19
19
  export interface GuildStatus {
20
20
  /** Matches status */
@@ -26,6 +26,7 @@ export interface GuildStatus {
26
26
  /** Voice Channels for a bet */
27
27
  createVoiceChannels: "on" | "off";
28
28
  }
29
+ export type DailyCategories = "coins" | "credit" | "wins" | "points" | "losses" | "mvps";
29
30
  export interface GuildScores {
30
31
  /** Win */
31
32
  win: number;
@@ -50,7 +51,7 @@ export interface APIGuild {
50
51
  /** Guild Ticket Configuration */
51
52
  ticketsConfiguration: GuildTicketConfiguration;
52
53
  /** Guild Daily Categories */
53
- dailyCategories: ["coins", "credit"];
54
+ dailyCategories: DailyCategories[];
54
55
  /** Guild Scores */
55
56
  scores: GuildScores;
56
57
  /** Guild Status */
@@ -2,5 +2,5 @@ export interface APIGuildPermissions {
2
2
  manage_bot: string[];
3
3
  manage_rooms: string[];
4
4
  manage_scores: string[];
5
- manage_bets: string[];
5
+ manage_matches: string[];
6
6
  }
@@ -2,6 +2,7 @@ import { APIMessage } from "./APIMessage";
2
2
  export interface APIGuildTicket {
3
3
  /** Ticket's id */
4
4
  id: string;
5
+ _id: string;
5
6
  /** Ticket's creator id */
6
7
  creatorId: string;
7
8
  /** Ticket's admin id */
@@ -1,3 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duque.edits/sdk",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "typings": "./dist/index.d.ts",
@@ -42,6 +42,16 @@
42
42
  "ts-node": "^10.9.2",
43
43
  "typescript": "^5.8.3"
44
44
  },
45
+ "exports": {
46
+ ".": {
47
+ "require": "./dist/index.js",
48
+ "types": "./dist/index.d.ts"
49
+ },
50
+ "./v1": {
51
+ "require": "./dist/v1",
52
+ "types": "./dist/index.d.ts"
53
+ }
54
+ },
45
55
  "publishConfig": {
46
56
  "access": "public"
47
57
  },