@duque.edits/sdk 0.0.3 → 0.0.5

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.
Files changed (157) hide show
  1. package/{src/index.ts → dist/index.d.ts} +27 -30
  2. package/dist/index.js +43 -0
  3. package/dist/managers/bet/GuildBetManager.d.ts +32 -0
  4. package/dist/managers/bet/GuildBetManager.js +107 -0
  5. package/dist/managers/betuser/GuildBetUserManager.d.ts +30 -0
  6. package/dist/managers/betuser/GuildBetUserManager.js +94 -0
  7. package/dist/managers/channel/ChannelManager.d.ts +39 -0
  8. package/dist/managers/channel/ChannelManager.js +147 -0
  9. package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +34 -0
  10. package/dist/managers/groupedchannel/GroupedChannelManager.js +92 -0
  11. package/dist/managers/guild/GuildManager.d.ts +24 -0
  12. package/dist/managers/guild/GuildManager.js +75 -0
  13. package/dist/managers/match/GuildMatchManager.d.ts +32 -0
  14. package/dist/managers/match/GuildMatchManager.js +103 -0
  15. package/dist/managers/mediator/GuildMediatorManager.d.ts +32 -0
  16. package/dist/managers/mediator/GuildMediatorManager.js +97 -0
  17. package/dist/managers/messages/MessagesManager.d.ts +32 -0
  18. package/dist/managers/messages/MessagesManager.js +82 -0
  19. package/dist/managers/permission/GuildPermissionManager.d.ts +26 -0
  20. package/dist/managers/permission/GuildPermissionManager.js +70 -0
  21. package/dist/managers/product/GuildProductManager.d.ts +32 -0
  22. package/dist/managers/product/GuildProductManager.js +102 -0
  23. package/dist/managers/ticket/GuildTicketManager.d.ts +32 -0
  24. package/dist/managers/ticket/GuildTicketManager.js +99 -0
  25. package/dist/managers/user/GuildUserManager.d.ts +32 -0
  26. package/dist/managers/user/GuildUserManager.js +106 -0
  27. package/dist/rest/APIEndpoints.d.ts +11 -0
  28. package/dist/rest/APIEndpoints.js +12 -0
  29. package/dist/rest/REST.d.ts +51 -0
  30. package/dist/rest/REST.js +96 -0
  31. package/dist/rest/Routes.d.ts +84 -0
  32. package/dist/rest/Routes.js +89 -0
  33. package/dist/structures/Collection.d.ts +17 -0
  34. package/dist/structures/Collection.js +87 -0
  35. package/dist/structures/bet/GuildBet.d.ts +86 -0
  36. package/dist/structures/bet/GuildBet.js +276 -0
  37. package/dist/structures/betuser/GuildBetUser.d.ts +82 -0
  38. package/dist/structures/betuser/GuildBetUser.js +194 -0
  39. package/dist/structures/channel/Channel.d.ts +31 -0
  40. package/dist/structures/channel/Channel.js +57 -0
  41. package/dist/structures/groupedchannel/GroupedChannel.d.ts +34 -0
  42. package/dist/structures/groupedchannel/GroupedChannel.js +121 -0
  43. package/dist/structures/guild/Guild.d.ts +89 -0
  44. package/dist/structures/guild/Guild.js +223 -0
  45. package/dist/structures/match/GuildMatch.d.ts +84 -0
  46. package/dist/structures/match/GuildMatch.js +327 -0
  47. package/dist/structures/mediator/GuildMediator.d.ts +41 -0
  48. package/dist/structures/mediator/GuildMediator.js +131 -0
  49. package/dist/structures/product/GuildProduct.d.ts +52 -0
  50. package/dist/structures/product/GuildProduct.js +175 -0
  51. package/dist/structures/shop/GuildShop.d.ts +34 -0
  52. package/dist/structures/shop/GuildShop.js +80 -0
  53. package/dist/structures/ticket/GuildTicket.d.ts +51 -0
  54. package/dist/structures/ticket/GuildTicket.js +170 -0
  55. package/dist/structures/user/GuildUser.d.ts +82 -0
  56. package/dist/structures/user/GuildUser.js +209 -0
  57. package/dist/types/api/APIBaseChannel.d.ts +10 -0
  58. package/dist/types/api/APIBaseChannel.js +2 -0
  59. package/dist/types/api/APIBetChannel.d.ts +10 -0
  60. package/dist/types/api/APIBetChannel.js +2 -0
  61. package/dist/types/api/APIBetMessage.d.ts +10 -0
  62. package/dist/types/api/APIBetMessage.js +2 -0
  63. package/dist/types/api/APIGuild.d.ts +92 -0
  64. package/dist/types/api/APIGuild.js +2 -0
  65. package/dist/types/api/APIGuildBet.d.ts +48 -0
  66. package/dist/types/api/APIGuildBet.js +2 -0
  67. package/dist/types/api/APIGuildBetUser.d.ts +32 -0
  68. package/dist/types/api/APIGuildBetUser.js +2 -0
  69. package/dist/types/api/APIGuildChannel.d.ts +10 -0
  70. package/dist/types/api/APIGuildChannel.js +2 -0
  71. package/dist/types/api/APIGuildEmoji.d.ts +12 -0
  72. package/dist/types/api/APIGuildEmoji.js +2 -0
  73. package/dist/types/api/APIGuildGroupedChannel.d.ts +10 -0
  74. package/dist/types/api/APIGuildGroupedChannel.js +2 -0
  75. package/dist/types/api/APIGuildMatch.d.ts +46 -0
  76. package/dist/types/api/APIGuildMatch.js +2 -0
  77. package/dist/types/api/APIGuildMediator.d.ts +13 -0
  78. package/dist/types/api/APIGuildMediator.js +3 -0
  79. package/dist/types/api/APIGuildMessage.d.ts +10 -0
  80. package/dist/types/api/APIGuildMessage.js +2 -0
  81. package/dist/types/api/APIGuildPermissions.d.ts +6 -0
  82. package/dist/types/api/APIGuildPermissions.js +2 -0
  83. package/dist/types/api/APIGuildRole.d.ts +10 -0
  84. package/dist/types/api/APIGuildRole.js +2 -0
  85. package/dist/types/api/APIGuildShop.d.ts +11 -0
  86. package/dist/types/api/APIGuildShop.js +2 -0
  87. package/dist/types/api/APIGuildTicket.d.ts +25 -0
  88. package/dist/types/api/APIGuildTicket.js +3 -0
  89. package/dist/types/api/APIGuildUser.d.ts +31 -0
  90. package/dist/types/api/APIGuildUser.js +2 -0
  91. package/dist/types/api/APIMessage.d.ts +12 -0
  92. package/dist/types/api/APIMessage.js +2 -0
  93. package/dist/types/api/APIPlayer.d.ts +10 -0
  94. package/dist/types/api/APIPlayer.js +2 -0
  95. package/dist/types/api/APIProduct.d.ts +19 -0
  96. package/dist/types/api/APIProduct.js +3 -0
  97. package/dist/types/api/index.d.ts +130 -0
  98. package/dist/types/api/index.js +35 -0
  99. package/{src/types/index.ts → dist/types/index.d.ts} +21 -24
  100. package/dist/types/index.js +37 -0
  101. package/dist/utils/Assertion.d.ts +32 -0
  102. package/dist/utils/Assertion.js +60 -0
  103. package/package.json +5 -1
  104. package/.gitattributes +0 -2
  105. package/src/managers/bet/GuildBetManager.ts +0 -117
  106. package/src/managers/betuser/GuildBetUserManager.ts +0 -103
  107. package/src/managers/channel/ChannelManager.ts +0 -168
  108. package/src/managers/groupedchannel/GroupedChannelManager.ts +0 -117
  109. package/src/managers/guild/GuildManager.ts +0 -84
  110. package/src/managers/match/GuildMatchManager.ts +0 -115
  111. package/src/managers/mediator/GuildMediatorManager.ts +0 -111
  112. package/src/managers/messages/MessagesManager.ts +0 -95
  113. package/src/managers/permission/GuildPermissionManager.ts +0 -88
  114. package/src/managers/product/GuildProductManager.ts +0 -115
  115. package/src/managers/ticket/GuildTicketManager.ts +0 -112
  116. package/src/managers/user/GuildUserManager.ts +0 -116
  117. package/src/rest/APIEndpoints.ts +0 -11
  118. package/src/rest/REST.ts +0 -126
  119. package/src/rest/Routes.ts +0 -143
  120. package/src/structures/Collection.ts +0 -85
  121. package/src/structures/bet/GuildBet.ts +0 -332
  122. package/src/structures/betuser/GuildBetUser.ts +0 -247
  123. package/src/structures/channel/Channel.ts +0 -78
  124. package/src/structures/groupedchannel/GroupedChannel.ts +0 -165
  125. package/src/structures/guild/Guild.ts +0 -302
  126. package/src/structures/match/GuildMatch.ts +0 -385
  127. package/src/structures/mediator/GuildMediator.ts +0 -175
  128. package/src/structures/product/GuildProduct.ts +0 -217
  129. package/src/structures/shop/GuildShop.ts +0 -98
  130. package/src/structures/ticket/GuildTicket.ts +0 -227
  131. package/src/structures/user/GuildUser.ts +0 -248
  132. package/src/types/api/APIBaseChannel.ts +0 -13
  133. package/src/types/api/APIBetChannel.ts +0 -13
  134. package/src/types/api/APIBetMessage.ts +0 -13
  135. package/src/types/api/APIGuild.ts +0 -123
  136. package/src/types/api/APIGuildBet.ts +0 -69
  137. package/src/types/api/APIGuildBetUser.ts +0 -46
  138. package/src/types/api/APIGuildChannel.ts +0 -13
  139. package/src/types/api/APIGuildEmoji.ts +0 -16
  140. package/src/types/api/APIGuildGroupedChannel.ts +0 -13
  141. package/src/types/api/APIGuildMatch.ts +0 -67
  142. package/src/types/api/APIGuildMediator.ts +0 -18
  143. package/src/types/api/APIGuildMessage.ts +0 -13
  144. package/src/types/api/APIGuildPermissions.ts +0 -7
  145. package/src/types/api/APIGuildRole.ts +0 -13
  146. package/src/types/api/APIGuildShop.ts +0 -15
  147. package/src/types/api/APIGuildTicket.ts +0 -36
  148. package/src/types/api/APIGuildUser.ts +0 -45
  149. package/src/types/api/APIMessage.ts +0 -16
  150. package/src/types/api/APIPlayer.ts +0 -13
  151. package/src/types/api/APIProduct.ts +0 -27
  152. package/src/types/api/index.ts +0 -180
  153. package/src/utils/Assertion.ts +0 -56
  154. package/src/v1/managers/channel/ChannelManager.ts +0 -167
  155. package/src/v1/managers/match/GuildMatchManager.ts +0 -114
  156. package/tests/index.ts +0 -86
  157. package/tsconfig.json +0 -15
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuildMediator = void 0;
4
+ const Routes_1 = require("../../rest/Routes");
5
+ const Assertion_1 = require("../../utils/Assertion");
6
+ class GuildMediator {
7
+ /** Mediator's id */
8
+ id;
9
+ /** Mediator's name */
10
+ name;
11
+ /** Mediator's links */
12
+ paymentLinks;
13
+ /** Creation Date */
14
+ createdAt;
15
+ /** Updated Date */
16
+ updatedAt;
17
+ /** The given guild */
18
+ guild;
19
+ /** The rest client */
20
+ rest;
21
+ manager;
22
+ /**
23
+ * GuildMediator mediator
24
+ * @param data The mediator's data
25
+ * @param guild The guild
26
+ * @param rest The rest client
27
+ */
28
+ constructor(data, guild, manager, rest) {
29
+ this.id = data.id;
30
+ this.name = data.name;
31
+ this.paymentLinks = data.paymentLinks;
32
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
33
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
34
+ this.guild = guild;
35
+ this.rest = rest;
36
+ this.manager = manager;
37
+ }
38
+ /** String representation of this mediator */
39
+ toString() {
40
+ return `<@${this.id}>`;
41
+ }
42
+ /**
43
+ * Fetches the mediator
44
+ * @returns New Instance of the mediator
45
+ */
46
+ async fetch() {
47
+ const route = Routes_1.Routes.guilds.mediators.get(this.guild.id, this.id);
48
+ const response = await this.rest.request({
49
+ method: "get",
50
+ url: route,
51
+ });
52
+ const med = new GuildMediator(response, this.guild, this.manager, this.rest);
53
+ this.manager.cache.set(med.id, med);
54
+ this.rest.mediators.set(med.id, med);
55
+ return med;
56
+ }
57
+ async update(data) {
58
+ const route = Routes_1.Routes.guilds.mediators.get(this.guild.id, this.id);
59
+ const payload = data;
60
+ const response = await this.rest.request({
61
+ method: "patch",
62
+ url: route,
63
+ payload,
64
+ });
65
+ const med = new GuildMediator(response, this.guild, this.manager, this.rest);
66
+ this.rest.emit("mediatorUpdate", this);
67
+ for (const k in response) {
68
+ if (k === "id")
69
+ continue;
70
+ if (Object.hasOwn(this, k)) {
71
+ this[k] = response[k];
72
+ }
73
+ }
74
+ this.manager.cache.set(med.id, med);
75
+ this.rest.emit("mediatorUpdate", this, med);
76
+ return this;
77
+ }
78
+ async delete() {
79
+ const route = Routes_1.Routes.guilds.mediators.delete(this.guild.id, this.id);
80
+ const response = await this.rest.request({
81
+ method: "DELETE",
82
+ url: route,
83
+ });
84
+ this.manager.cache.delete(this.id);
85
+ this.rest.mediators.delete(this.id);
86
+ this.rest.emit("mediatorUpdate", this);
87
+ return response;
88
+ }
89
+ async setLinks(link) {
90
+ Assertion_1.Assertion.assertString(link);
91
+ const route = Routes_1.Routes.guilds.mediators.resource(this.guild.id, this.id, "links");
92
+ const payload = { paymentLinks: [link], set: true };
93
+ const response = await this.rest.request({
94
+ method: "PATCH",
95
+ url: route,
96
+ payload,
97
+ });
98
+ this.paymentLinks = response.paymentLinks;
99
+ this.manager.cache.set(this.id, this);
100
+ this.rest.mediators.set(this.id, this);
101
+ this.rest.emit("mediatorUpdate", this);
102
+ return this.paymentLinks;
103
+ }
104
+ async removeLink(link) {
105
+ Assertion_1.Assertion.assertString(link);
106
+ const route = Routes_1.Routes.guilds.mediators.resource(this.guild.id, this.id, "links");
107
+ const payload = {
108
+ paymentLinks: this.paymentLinks.filter((lm) => lm !== link),
109
+ };
110
+ const response = await this.rest.request({
111
+ method: "PATCH",
112
+ url: route,
113
+ payload,
114
+ });
115
+ this.paymentLinks = response.paymentLinks;
116
+ this.manager.cache.set(this.id, this);
117
+ this.rest.mediators.set(this.id, this);
118
+ this.rest.emit("mediatorUpdate", this);
119
+ return this.paymentLinks;
120
+ }
121
+ toJSON() {
122
+ const json = {};
123
+ for (const [key, value] of Object.entries(this)) {
124
+ if (typeof value !== "function") {
125
+ json[key] = value;
126
+ }
127
+ }
128
+ return json;
129
+ }
130
+ }
131
+ exports.GuildMediator = GuildMediator;
@@ -0,0 +1,52 @@
1
+ import { REST } from "../../rest/REST";
2
+ import { Optional } from "../../types/api";
3
+ import { APIProduct } from "../../types/api/APIProduct";
4
+ import { APIPlayer } from "../../types/api/APIPlayer";
5
+ import { GuildProductManager } from "../../managers/product/GuildProductManager";
6
+ export declare class GuildProduct implements APIProduct {
7
+ /** Product's name */
8
+ name: string;
9
+ /** Product's description */
10
+ description: string;
11
+ /** Product's id */
12
+ id: string;
13
+ /** Product's price */
14
+ price: number;
15
+ /** Product's buyers */
16
+ buyers: APIPlayer[];
17
+ /** Product's emoji */
18
+ emoji: string;
19
+ /** Creation Date */
20
+ createdAt: Date;
21
+ /** Updated Date */
22
+ updatedAt: Date;
23
+ /** The given manager */
24
+ readonly manager: GuildProductManager;
25
+ /** The rest client */
26
+ readonly rest: REST;
27
+ /**
28
+ * Bet product
29
+ * @param data The product's data
30
+ * @param manager The manager
31
+ * @param rest The rest client
32
+ */
33
+ constructor(data: APIProduct, manager: GuildProductManager, rest: REST);
34
+ /** String representation of this product */
35
+ toString(): string;
36
+ /**
37
+ * Fetches the product
38
+ * @returns New Instance of the product
39
+ */
40
+ fetch(): Promise<GuildProduct>;
41
+ setPrice(price: number): Promise<this>;
42
+ addBuyer(id: string, name: string, type: string): Promise<this>;
43
+ removeBuyer(id: string, name: string, type: string): Promise<this>;
44
+ /**
45
+ * Update certain property
46
+ * @param data The new data to update with
47
+ * @returns
48
+ */
49
+ update(payload: Optional<APIProduct>): Promise<this>;
50
+ delete(): Promise<boolean>;
51
+ toJSON(): Record<string, unknown>;
52
+ }
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuildProduct = void 0;
4
+ const Routes_1 = require("../../rest/Routes");
5
+ const Assertion_1 = require("../../utils/Assertion");
6
+ class GuildProduct {
7
+ /** Product's name */
8
+ name;
9
+ /** Product's description */
10
+ description;
11
+ /** Product's id */
12
+ id;
13
+ /** Product's price */
14
+ price;
15
+ /** Product's buyers */
16
+ buyers;
17
+ /** Product's emoji */
18
+ emoji;
19
+ /** Creation Date */
20
+ createdAt;
21
+ /** Updated Date */
22
+ updatedAt;
23
+ /** The given manager */
24
+ manager;
25
+ /** The rest client */
26
+ rest;
27
+ /**
28
+ * Bet product
29
+ * @param data The product's data
30
+ * @param manager The manager
31
+ * @param rest The rest client
32
+ */
33
+ constructor(data, manager, rest) {
34
+ this.name = data?.name;
35
+ this.id = data?.id;
36
+ this.price = data?.price;
37
+ this.buyers = data?.buyers;
38
+ this.emoji = data?.emoji;
39
+ this.description = data?.description;
40
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
41
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
42
+ this.manager = manager;
43
+ this.rest = rest;
44
+ }
45
+ /** String representation of this product */
46
+ toString() {
47
+ return `<@${this.id}>`;
48
+ }
49
+ /**
50
+ * Fetches the product
51
+ * @returns New Instance of the product
52
+ */
53
+ async fetch() {
54
+ const route = Routes_1.Routes.guilds.shop.products.get(this.manager.guild.id, this.id);
55
+ const response = await this.rest.request({
56
+ method: "get",
57
+ url: route,
58
+ });
59
+ const product = new GuildProduct(response, this.manager, this.rest);
60
+ this.manager.cache.set(product.id, product);
61
+ return product;
62
+ }
63
+ async setPrice(price) {
64
+ Assertion_1.Assertion.assertNumber(price);
65
+ const route = Routes_1.Routes.guilds.shop.products.resource(this.id, this.manager.guild.id, "price");
66
+ const payload = { price };
67
+ const response = await this.rest.request({
68
+ method: "PATCH",
69
+ url: route,
70
+ });
71
+ this.price = response.price;
72
+ this.manager.cache.set(this.id, this);
73
+ return this;
74
+ }
75
+ async addBuyer(id, name, type) {
76
+ Assertion_1.Assertion.assertString(id);
77
+ Assertion_1.Assertion.assertString(name);
78
+ Assertion_1.Assertion.assertString(type);
79
+ const payload = { id, name, type };
80
+ const route = Routes_1.Routes.guilds.shop.products.resource(this.id, this.manager.guild.id, "buyers");
81
+ const response = await this.rest.request({
82
+ method: "POST",
83
+ url: route,
84
+ payload,
85
+ });
86
+ let user;
87
+ if (type == "bet") {
88
+ user = this.manager.guild.betUsers.cache.get(id);
89
+ user.items = [...new Set([...user.items, this.id])];
90
+ this.manager.guild.betUsers.cache.set(user.id, user);
91
+ this.rest.betUsers.set(user.id, user);
92
+ }
93
+ else if (type == "match") {
94
+ user = this.manager.guild.users.cache.get(id);
95
+ user.items = [...new Set([...user.items, this.id])];
96
+ this.manager.guild.users.cache.set(user.id, user);
97
+ this.rest.users.set(user.id, user);
98
+ }
99
+ this.buyers = response.buyers;
100
+ this.manager.cache.set(this.id, this);
101
+ return this;
102
+ }
103
+ async removeBuyer(id, name, type) {
104
+ Assertion_1.Assertion.assertString(id);
105
+ Assertion_1.Assertion.assertString(name);
106
+ Assertion_1.Assertion.assertString(type);
107
+ const payload = { id, name, type };
108
+ const route = Routes_1.Routes.guilds.shop.products.resource(this.id, this.manager.guild.id, "buyers", id);
109
+ const response = await this.rest.request({
110
+ method: "DELETE",
111
+ url: route,
112
+ payload,
113
+ });
114
+ let user;
115
+ if (type == "bet") {
116
+ user = this.manager.guild.betUsers.cache.get(id);
117
+ user.items = [
118
+ ...new Set(user.items.filter((item) => item != this.id)),
119
+ ];
120
+ this.manager.guild.betUsers.cache.set(user.id, user);
121
+ }
122
+ else if (type == "match") {
123
+ user = this.manager.guild.users.cache.get(id);
124
+ user.items = [
125
+ ...new Set(user.items.filter((item) => item != this.id)),
126
+ ];
127
+ this.manager.guild.users.cache.set(user.id, user);
128
+ }
129
+ this.buyers = response.buyers;
130
+ this.manager.cache.set(this.id, this);
131
+ return this;
132
+ }
133
+ /**
134
+ * Update certain property
135
+ * @param data The new data to update with
136
+ * @returns
137
+ */
138
+ async update(payload) {
139
+ const route = Routes_1.Routes.guilds.shop.products.get(this.manager.guild.id, this.id);
140
+ const response = await this.rest.request({
141
+ method: "patch",
142
+ url: route,
143
+ payload,
144
+ });
145
+ for (const k in response) {
146
+ if (k === "id")
147
+ continue;
148
+ if (Object.hasOwn(this, k)) {
149
+ this[k] = response[k];
150
+ }
151
+ }
152
+ this.manager.cache.set(this.id, this);
153
+ return this;
154
+ }
155
+ async delete() {
156
+ const route = Routes_1.Routes.guilds.shop.products.delete(this.manager.guild.id, this.id);
157
+ const response = await this.rest.request({
158
+ method: "DELETE",
159
+ url: route,
160
+ });
161
+ this.rest.emit("betproductDelete", this);
162
+ this.manager.cache.delete(this.id);
163
+ return response;
164
+ }
165
+ toJSON() {
166
+ const json = {};
167
+ for (const [key, value] of Object.entries(this)) {
168
+ if (typeof value !== "function") {
169
+ json[key] = value;
170
+ }
171
+ }
172
+ return json;
173
+ }
174
+ }
175
+ exports.GuildProduct = GuildProduct;
@@ -0,0 +1,34 @@
1
+ import { REST } from "../../rest/REST";
2
+ import { Guild } from "../guild/Guild";
3
+ import { Optional } from "../../types/api";
4
+ import { APIGuildShop } from "../../types/api/APIGuildShop";
5
+ import { GuildProductManager } from "../../managers/product/GuildProductManager";
6
+ export declare class GuildShop {
7
+ /**shop's product */
8
+ products: GuildProductManager;
9
+ /** Bought count */
10
+ boughtCount: number;
11
+ /** Creation Date */
12
+ createdAt: Date;
13
+ /** Updated Date */
14
+ updatedAt: Date;
15
+ /** The given guild */
16
+ readonly guild: Guild;
17
+ /** The rest client */
18
+ readonly rest: REST;
19
+ /**
20
+ * GuildShopshop
21
+ * @param data Theshop's data
22
+ * @param guild The guild
23
+ * @param rest The rest client
24
+ */
25
+ constructor(data: APIGuildShop, guild: Guild, rest: REST);
26
+ toString(): string;
27
+ /**
28
+ * Fetches theshop
29
+ * @returns New Instance of theshop
30
+ */
31
+ fetch(): Promise<GuildShop>;
32
+ update(data: Optional<APIGuildShop>): Promise<this>;
33
+ toJSON(): Record<string, unknown>;
34
+ }
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuildShop = void 0;
4
+ const Routes_1 = require("../../rest/Routes");
5
+ const GuildProductManager_1 = require("../../managers/product/GuildProductManager");
6
+ class GuildShop {
7
+ /**shop's product */
8
+ products;
9
+ /** Bought count */
10
+ boughtCount;
11
+ /** Creation Date */
12
+ createdAt;
13
+ /** Updated Date */
14
+ updatedAt;
15
+ /** The given guild */
16
+ guild;
17
+ /** The rest client */
18
+ rest;
19
+ /**
20
+ * GuildShopshop
21
+ * @param data Theshop's data
22
+ * @param guild The guild
23
+ * @param rest The rest client
24
+ */
25
+ constructor(data, guild, rest) {
26
+ this.boughtCount = data?.boughtCount;
27
+ this.products = new GuildProductManager_1.GuildProductManager(guild, rest);
28
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
29
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
30
+ this.guild = guild;
31
+ this.rest = rest;
32
+ this.products.setAll(data?.products);
33
+ }
34
+ toString() {
35
+ return this.boughtCount.toString();
36
+ }
37
+ /**
38
+ * Fetches theshop
39
+ * @returns New Instance of theshop
40
+ */
41
+ async fetch() {
42
+ const route = Routes_1.Routes.guilds.shop.get(this.guild.id);
43
+ const response = await this.rest.request({
44
+ method: "get",
45
+ url: route,
46
+ });
47
+ const shp = new GuildShop(response, this.guild, this.rest);
48
+ this.guild.shop = shp;
49
+ return shp;
50
+ }
51
+ async update(data) {
52
+ const route = Routes_1.Routes.guilds.shop.get(this.guild.id);
53
+ const payload = data;
54
+ const response = await this.rest.request({
55
+ method: "patch",
56
+ url: route,
57
+ payload,
58
+ });
59
+ this.rest.emit("shopUpdate", this, new GuildShop(response, this.guild, this.rest));
60
+ for (const k in response) {
61
+ if (k === "id")
62
+ continue;
63
+ if (Object.hasOwn(this, k)) {
64
+ this[k] = response[k];
65
+ }
66
+ }
67
+ this.guild.shop = this;
68
+ return this;
69
+ }
70
+ toJSON() {
71
+ const json = {};
72
+ for (const [key, value] of Object.entries(this)) {
73
+ if (typeof value !== "function") {
74
+ json[key] = value;
75
+ }
76
+ }
77
+ return json;
78
+ }
79
+ }
80
+ exports.GuildShop = GuildShop;
@@ -0,0 +1,51 @@
1
+ import { REST } from "../../rest/REST";
2
+ import { Guild } from "../guild/Guild";
3
+ import { APIGuildTicket } from "../../types/api/APIGuildTicket";
4
+ import { GuildTicketManager } from "../../managers/ticket/GuildTicketManager";
5
+ import { MessagesManager } from "../../managers/messages/MessagesManager";
6
+ export declare class GuildTicket {
7
+ /** Ticket's id */
8
+ id: string;
9
+ /** Ticket's creator id */
10
+ creatorId: string;
11
+ /** Ticket's admin id */
12
+ adminId: string;
13
+ /** Ticket's rating that customer gave */
14
+ customerRating: number;
15
+ /** Ticket's channel id */
16
+ channelId: string;
17
+ /** Ticket's closed by who */
18
+ closedById: string;
19
+ /** Ticket's type */
20
+ type: string;
21
+ /** Ticket's status */
22
+ status: "on" | "off";
23
+ /** Ticket's messages */
24
+ messages: MessagesManager;
25
+ /** Creation Date */
26
+ createdAt: Date;
27
+ /** Updated Date */
28
+ updatedAt: Date;
29
+ /** The given guild */
30
+ readonly guild: Guild;
31
+ /** The rest client */
32
+ readonly rest: REST;
33
+ readonly manager: GuildTicketManager;
34
+ /**
35
+ * GuildMediator mediator
36
+ * @param data The mediator's data
37
+ * @param guild The guild
38
+ * @param rest The rest client
39
+ */
40
+ constructor(data: APIGuildTicket, guild: Guild, manager: GuildTicketManager, rest: REST);
41
+ fetch(): Promise<GuildTicket>;
42
+ setChannelId(id: string): Promise<this>;
43
+ setAdminId(id: string): Promise<this>;
44
+ setClosedById(id: string): Promise<this>;
45
+ setCustomerRating(rating: string): Promise<this>;
46
+ setType(type: string): Promise<this>;
47
+ setStatus(status: string): Promise<this>;
48
+ delete(): Promise<boolean>;
49
+ toJSON(): Record<string, unknown>;
50
+ toString(): string;
51
+ }
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GuildTicket = void 0;
4
+ const Routes_1 = require("../../rest/Routes");
5
+ const Assertion_1 = require("../../utils/Assertion");
6
+ const MessagesManager_1 = require("../../managers/messages/MessagesManager");
7
+ class GuildTicket {
8
+ /** Ticket's id */
9
+ id;
10
+ /** Ticket's creator id */
11
+ creatorId;
12
+ /** Ticket's admin id */
13
+ adminId;
14
+ /** Ticket's rating that customer gave */
15
+ customerRating;
16
+ /** Ticket's channel id */
17
+ channelId;
18
+ /** Ticket's closed by who */
19
+ closedById;
20
+ /** Ticket's type */
21
+ type;
22
+ /** Ticket's status */
23
+ status;
24
+ /** Ticket's messages */
25
+ messages;
26
+ /** Creation Date */
27
+ createdAt;
28
+ /** Updated Date */
29
+ updatedAt;
30
+ /** The given guild */
31
+ guild;
32
+ /** The rest client */
33
+ rest;
34
+ manager;
35
+ /**
36
+ * GuildMediator mediator
37
+ * @param data The mediator's data
38
+ * @param guild The guild
39
+ * @param rest The rest client
40
+ */
41
+ constructor(data, guild, manager, rest) {
42
+ this.id = data?.id.toString();
43
+ this.creatorId = data?.creatorId;
44
+ this.adminId = data?.adminId;
45
+ this.customerRating = data.customerRating;
46
+ this.closedById = data?.closedById;
47
+ this.type = data?.type;
48
+ this.status = data?.status;
49
+ this.channelId = data?.channelId;
50
+ this.messages = new MessagesManager_1.MessagesManager(this.guild, this.id, rest);
51
+ this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
52
+ this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
53
+ this.guild = guild;
54
+ this.rest = rest;
55
+ this.manager = manager;
56
+ this.messages.setAll(data?.messages);
57
+ }
58
+ async fetch() {
59
+ const route = Routes_1.Routes.guilds.tickets.get(this.id, this.guild.id);
60
+ const response = await this.rest.request({
61
+ method: "DELETE",
62
+ url: route,
63
+ });
64
+ const ticket = new GuildTicket(response, this.guild, this.manager, this.rest);
65
+ this.manager.cache.set(response.id, ticket);
66
+ return ticket;
67
+ }
68
+ async setChannelId(id) {
69
+ Assertion_1.Assertion.assertString(id);
70
+ const route = Routes_1.Routes.guilds.tickets.resource(this.guild.id, this.id, "channelId");
71
+ const payload = { channelId: id };
72
+ const response = await this.rest.request({
73
+ method: "PATCH",
74
+ url: route,
75
+ payload,
76
+ });
77
+ this.channelId = response.channelId;
78
+ this.manager.cache.set(this.id, this);
79
+ return this;
80
+ }
81
+ async setAdminId(id) {
82
+ Assertion_1.Assertion.assertString(id);
83
+ const route = Routes_1.Routes.guilds.tickets.resource(this.guild.id, this.id, "adminId");
84
+ const payload = { adminId: id };
85
+ const response = await this.rest.request({
86
+ method: "PATCH",
87
+ url: route,
88
+ payload,
89
+ });
90
+ this.adminId = response.adminId;
91
+ this.manager.cache.set(this.id, this);
92
+ return this;
93
+ }
94
+ async setClosedById(id) {
95
+ Assertion_1.Assertion.assertString(id);
96
+ const route = Routes_1.Routes.guilds.tickets.resource(this.guild.id, this.id, "closedById");
97
+ const payload = { closedById: id };
98
+ const response = await this.rest.request({
99
+ method: "PATCH",
100
+ url: route,
101
+ payload,
102
+ });
103
+ this.closedById = response.closedById;
104
+ this.manager.cache.set(this.id, this);
105
+ return this;
106
+ }
107
+ async setCustomerRating(rating) {
108
+ Assertion_1.Assertion.assertString(rating);
109
+ const route = Routes_1.Routes.guilds.tickets.resource(this.guild.id, this.id, "customerRating");
110
+ const payload = {
111
+ customerRating: rating,
112
+ };
113
+ const response = await this.rest.request({
114
+ method: "PATCH",
115
+ url: route,
116
+ });
117
+ this.customerRating = response.customerRating;
118
+ this.manager.cache.set(this.id, this);
119
+ return this;
120
+ }
121
+ async setType(type) {
122
+ Assertion_1.Assertion.assertString(type);
123
+ const route = Routes_1.Routes.guilds.tickets.resource(this.guild.id, this.id, "type");
124
+ const payload = { type };
125
+ const response = await this.rest.request({
126
+ method: "PATCH",
127
+ url: route,
128
+ payload,
129
+ });
130
+ this.type = response.type;
131
+ this.manager.cache.set(this.id, this);
132
+ return this;
133
+ }
134
+ async setStatus(status) {
135
+ Assertion_1.Assertion.assertString(status);
136
+ const route = Routes_1.Routes.guilds.tickets.resource(this.guild.id, this.id, "status");
137
+ const payload = { status };
138
+ const response = await this.rest.request({
139
+ method: "PATCH",
140
+ url: route,
141
+ payload,
142
+ });
143
+ this.status = response.status;
144
+ this.manager.cache.set(this.id, this);
145
+ return this;
146
+ }
147
+ async delete() {
148
+ const route = Routes_1.Routes.guilds.tickets.delete(this.id, this.guild.id);
149
+ const response = await this.rest.request({
150
+ method: "DELETE",
151
+ url: route,
152
+ });
153
+ this.manager.cache.set(this.id, this);
154
+ this.manager.cache.delete(this.id);
155
+ return response;
156
+ }
157
+ toJSON() {
158
+ const json = {};
159
+ for (const [key, value] of Object.entries(this)) {
160
+ if (typeof value !== "function") {
161
+ json[key] = value;
162
+ }
163
+ }
164
+ return json;
165
+ }
166
+ toString() {
167
+ return this.id || "1";
168
+ }
169
+ }
170
+ exports.GuildTicket = GuildTicket;