@duque.edits/sdk 0.1.4 → 0.1.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.
Files changed (119) hide show
  1. package/dist/index.js +4 -27
  2. package/dist/managers/base.js +26 -0
  3. package/dist/managers/buffer/BufferManager.js +8 -2
  4. package/dist/managers/guild/GuildManager.js +42 -25
  5. package/dist/managers/index.js +23 -0
  6. package/dist/managers/match/GuildMatchManager.js +42 -29
  7. package/dist/managers/message/MessagesManager.js +48 -0
  8. package/dist/managers/permission/GuildPermissionManager.js +29 -52
  9. package/dist/managers/ticket/TicketManager.js +77 -0
  10. package/dist/managers/user/GuildUserManager.js +73 -85
  11. package/dist/managers/vipmember/VipMemberManager.js +124 -0
  12. package/dist/rest/REST.js +40 -21
  13. package/dist/rest/Routes.js +31 -17
  14. package/dist/rest/index.js +19 -0
  15. package/dist/structures/Collection.js +1 -1
  16. package/dist/structures/guild/Guild.js +72 -90
  17. package/dist/structures/index.js +22 -0
  18. package/dist/structures/match/GuildMatch.js +64 -111
  19. package/dist/structures/ticket/Ticket.js +119 -0
  20. package/dist/structures/user/GuildUser.js +48 -40
  21. package/dist/structures/vipmember/VipMember.js +137 -0
  22. package/dist/types/api/APIGiveaway.js +2 -0
  23. package/dist/types/api/APILogMessage.js +2 -0
  24. package/dist/types/api/APIVipMember.js +2 -0
  25. package/dist/types/api/index.js +36 -0
  26. package/dist/types/index.js +1 -20
  27. package/dist/utils/getRandomNumber.js +6 -0
  28. package/package.json +11 -18
  29. package/types/index.d.ts +4 -0
  30. package/types/managers/base.d.ts +17 -0
  31. package/types/managers/buffer/BufferManager.d.ts +19 -0
  32. package/{dist → types}/managers/guild/GuildManager.d.ts +12 -4
  33. package/types/managers/index.d.ts +7 -0
  34. package/{dist → types}/managers/match/GuildMatchManager.d.ts +10 -12
  35. package/types/managers/message/MessagesManager.d.ts +17 -0
  36. package/types/managers/permission/GuildPermissionManager.d.ts +8 -0
  37. package/types/managers/ticket/TicketManager.d.ts +22 -0
  38. package/types/managers/user/GuildUserManager.d.ts +19 -0
  39. package/types/managers/vipmember/VipMemberManager.d.ts +33 -0
  40. package/types/rest/APIEndpoints.d.ts +11 -0
  41. package/{dist → types}/rest/REST.d.ts +9 -16
  42. package/{dist → types}/rest/Routes.d.ts +18 -2
  43. package/types/rest/index.d.ts +3 -0
  44. package/{dist → types}/structures/guild/Guild.d.ts +17 -29
  45. package/types/structures/index.d.ts +6 -0
  46. package/{dist → types}/structures/match/GuildMatch.d.ts +12 -22
  47. package/types/structures/ticket/Ticket.d.ts +30 -0
  48. package/{dist → types}/structures/user/GuildUser.d.ts +5 -3
  49. package/types/structures/vipmember/VipMember.d.ts +54 -0
  50. package/types/types/RestTypes.d.ts +34 -0
  51. package/types/types/api/APIGiveaway.d.ts +27 -0
  52. package/{dist → types}/types/api/APIGuild.d.ts +9 -2
  53. package/{dist → types}/types/api/APIGuildMatch.d.ts +9 -7
  54. package/types/types/api/APIGuildTicket.d.ts +16 -0
  55. package/{dist → types}/types/api/APIGuildUser.d.ts +3 -1
  56. package/types/types/api/APILogMessage.d.ts +7 -0
  57. package/types/types/api/APIMessage.d.ts +11 -0
  58. package/{dist → types}/types/api/APIPlayer.d.ts +1 -1
  59. package/types/types/api/APIVipMember.d.ts +20 -0
  60. package/{dist → types}/types/api/index.d.ts +23 -1
  61. package/types/types/index.d.ts +2 -0
  62. package/types/utils/getRandomNumber.d.ts +1 -0
  63. package/dist/index.d.ts +0 -27
  64. package/dist/managers/bet/GuildBetManager.d.ts +0 -35
  65. package/dist/managers/bet/GuildBetManager.js +0 -126
  66. package/dist/managers/betuser/GuildBetUserManager.d.ts +0 -36
  67. package/dist/managers/betuser/GuildBetUserManager.js +0 -151
  68. package/dist/managers/buffer/BufferManager.d.ts +0 -14
  69. package/dist/managers/channel/ChannelManager.d.ts +0 -39
  70. package/dist/managers/channel/ChannelManager.js +0 -148
  71. package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +0 -34
  72. package/dist/managers/groupedchannel/GroupedChannelManager.js +0 -92
  73. package/dist/managers/mediator/GuildMediatorManager.d.ts +0 -32
  74. package/dist/managers/mediator/GuildMediatorManager.js +0 -98
  75. package/dist/managers/messages/MessagesManager.d.ts +0 -32
  76. package/dist/managers/messages/MessagesManager.js +0 -89
  77. package/dist/managers/permission/GuildPermissionManager.d.ts +0 -26
  78. package/dist/managers/product/GuildProductManager.d.ts +0 -32
  79. package/dist/managers/product/GuildProductManager.js +0 -103
  80. package/dist/managers/ticket/GuildTicketManager.d.ts +0 -32
  81. package/dist/managers/ticket/GuildTicketManager.js +0 -100
  82. package/dist/managers/user/GuildUserManager.d.ts +0 -33
  83. package/dist/rest/APIEndpoints.d.ts +0 -11
  84. package/dist/structures/bet/GuildBet.d.ts +0 -87
  85. package/dist/structures/bet/GuildBet.js +0 -284
  86. package/dist/structures/betuser/GuildBetUser.d.ts +0 -85
  87. package/dist/structures/betuser/GuildBetUser.js +0 -211
  88. package/dist/structures/channel/Channel.d.ts +0 -31
  89. package/dist/structures/channel/Channel.js +0 -57
  90. package/dist/structures/groupedchannel/GroupedChannel.d.ts +0 -34
  91. package/dist/structures/groupedchannel/GroupedChannel.js +0 -121
  92. package/dist/structures/mediator/GuildMediator.d.ts +0 -41
  93. package/dist/structures/mediator/GuildMediator.js +0 -131
  94. package/dist/structures/product/GuildProduct.d.ts +0 -52
  95. package/dist/structures/product/GuildProduct.js +0 -175
  96. package/dist/structures/shop/GuildShop.d.ts +0 -34
  97. package/dist/structures/shop/GuildShop.js +0 -80
  98. package/dist/structures/ticket/GuildTicket.d.ts +0 -52
  99. package/dist/structures/ticket/GuildTicket.js +0 -172
  100. package/dist/types/api/APIGuildTicket.d.ts +0 -26
  101. package/dist/types/api/APIMessage.d.ts +0 -12
  102. package/dist/types/index.d.ts +0 -21
  103. /package/dist/types/{api/APIGuildMessage.js → RestTypes.js} +0 -0
  104. /package/{dist → types}/structures/Collection.d.ts +0 -0
  105. /package/{dist → types}/types/api/APIBaseChannel.d.ts +0 -0
  106. /package/{dist → types}/types/api/APIBetChannel.d.ts +0 -0
  107. /package/{dist → types}/types/api/APIBetMessage.d.ts +0 -0
  108. /package/{dist → types}/types/api/APIGuildBet.d.ts +0 -0
  109. /package/{dist → types}/types/api/APIGuildBetUser.d.ts +0 -0
  110. /package/{dist → types}/types/api/APIGuildChannel.d.ts +0 -0
  111. /package/{dist → types}/types/api/APIGuildEmoji.d.ts +0 -0
  112. /package/{dist → types}/types/api/APIGuildGroupedChannel.d.ts +0 -0
  113. /package/{dist → types}/types/api/APIGuildMediator.d.ts +0 -0
  114. /package/{dist → types}/types/api/APIGuildMessage.d.ts +0 -0
  115. /package/{dist → types}/types/api/APIGuildPermissions.d.ts +0 -0
  116. /package/{dist → types}/types/api/APIGuildRole.d.ts +0 -0
  117. /package/{dist → types}/types/api/APIGuildShop.d.ts +0 -0
  118. /package/{dist → types}/types/api/APIProduct.d.ts +0 -0
  119. /package/{dist → types}/utils/Assertion.d.ts +0 -0
@@ -1,211 +0,0 @@
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
- games;
27
- /** User's items */
28
- items;
29
- /** User's profile card */
30
- profileCard;
31
- /** Creation Date */
32
- createdAt;
33
- /** Updated Date */
34
- updatedAt;
35
- /** The given manager */
36
- manager;
37
- /** The rest client */
38
- rest;
39
- /**
40
- * Bet user
41
- * @param data The user's data
42
- * @param manager The manager
43
- * @param rest The rest client
44
- */
45
- constructor(data, manager, rest) {
46
- this.name = data?.name;
47
- this.id = data?.id;
48
- this.credit = data?.credit;
49
- this.wins = data?.wins;
50
- this.mvps = data?.mvps;
51
- this.losses = data?.losses;
52
- this.games = data?.games;
53
- this.coins = data?.coins;
54
- this.blacklist = data?.blacklist;
55
- this.items = data?.items;
56
- this.betsPlayed = data?.betsPlayed;
57
- this.profileCard = data?.profileCard;
58
- this.daily = data?.daily;
59
- this.createdAt = data?.createdAt ? new Date(data?.createdAt) : new Date();
60
- this.updatedAt = data?.updatedAt ? new Date(data?.updatedAt) : new Date();
61
- this.manager = manager;
62
- this.rest = rest;
63
- }
64
- /** String representation of this user */
65
- toString() {
66
- return `<@${this.id}>`;
67
- }
68
- /**
69
- * Fetches the user
70
- * @returns New Instance of the user
71
- */
72
- async fetch() {
73
- const route = Routes_1.Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
74
- const response = await this.rest.request({
75
- method: "get",
76
- url: route,
77
- });
78
- const user = new GuildBetUser(response, this.manager, this.rest);
79
- this.manager.cache.set(user.id, user);
80
- this.rest.betUsers.set(user.id, user);
81
- return user;
82
- }
83
- /**
84
- * Add a propery
85
- * @param key The desired key
86
- * @param value The desired value
87
- * @returns GuildBetUser
88
- */
89
- async add(key, value) {
90
- const route = Routes_1.Routes.guilds.betUsers.resource(this.manager.guild.id, this.id, key);
91
- const payload = { [key]: value, name: this.name };
92
- const resp = await this.rest.request({
93
- method: "patch",
94
- url: route,
95
- payload,
96
- });
97
- this[key] = resp[key];
98
- this.manager.cache.set(this.id, this);
99
- this.rest.betUsers.set(this.id, this);
100
- return this;
101
- }
102
- async reset() {
103
- const route = Routes_1.Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
104
- const payload = { reset: true };
105
- const response = await this.rest.request({
106
- method: "DELETE",
107
- url: route,
108
- payload,
109
- });
110
- this.#updateData(response);
111
- return this;
112
- }
113
- #updateData(data) {
114
- for (const k in data) {
115
- if (k === "id")
116
- continue;
117
- if (Object.hasOwn(this, k)) {
118
- this[k] = data[k];
119
- this.data[k] = data[k];
120
- }
121
- }
122
- }
123
- /**
124
- * Set the user blacklist
125
- * @param value Value to set to
126
- * @returns GuildBetUser
127
- */
128
- async setBlacklist(value) {
129
- const route = Routes_1.Routes.guilds.betUsers.resource(this.manager.guild.id, this.id, "blacklist");
130
- const payload = { value, name: this.name };
131
- await this.rest.request({
132
- method: "patch",
133
- url: route,
134
- payload,
135
- });
136
- this.blacklist = value;
137
- this.manager.cache.set(this.id, this);
138
- this.rest.betUsers.set(this.id, this);
139
- return this;
140
- }
141
- /**
142
- * Update certain property
143
- * @param data The new data to update with
144
- * @returns
145
- */
146
- async update(data) {
147
- const route = Routes_1.Routes.guilds.betUsers.get(this.manager.guild.id, this.id);
148
- const payload = {};
149
- const numericFields = ["coins", "wins", "credit", "losses", "mvps", "games"];
150
- const arrayFields = ["items", "betsPlayed"];
151
- if (data?.type === "add" || data?.type === "remove") {
152
- for (const key in data) {
153
- if (key === "type")
154
- continue;
155
- const value = data[key];
156
- if (numericFields.includes(key)) {
157
- const current = this[key];
158
- const num = value;
159
- payload[key] = Math.max(0, data?.type === "add" ? current + num : num - current);
160
- }
161
- else if (key === "blacklist") {
162
- payload["blacklist"] = value;
163
- }
164
- else if (arrayFields.includes(key)) {
165
- const current = this[key];
166
- const incoming = value;
167
- payload[key] =
168
- data?.type === "add"
169
- ? [...new Set([...current, ...incoming])]
170
- : current.filter((x) => !incoming.includes(x));
171
- }
172
- }
173
- }
174
- const response = await this.rest.request({
175
- method: "patch",
176
- url: route,
177
- payload,
178
- });
179
- for (const k in response) {
180
- if (k === "id")
181
- continue;
182
- if (Object.hasOwn(this, k)) {
183
- this[k] = response[k];
184
- }
185
- }
186
- this.updatedAt = new Date();
187
- this.rest.betUsers.set(this.id, this);
188
- this.manager.cache.set(this.id, this);
189
- return this;
190
- }
191
- async delete() {
192
- const route = Routes_1.Routes.guilds.betUsers.delete(this.manager.guild.id, this.id);
193
- const response = await this.rest.request({
194
- method: "DELETE",
195
- url: route,
196
- });
197
- this.rest.emit("betUserDelete", this);
198
- this.manager.cache.delete(this.id);
199
- return response;
200
- }
201
- toJSON() {
202
- const json = {};
203
- for (const [key, value] of Object.entries(this)) {
204
- if (typeof value !== "function") {
205
- json[key] = value;
206
- }
207
- }
208
- return json;
209
- }
210
- }
211
- exports.GuildBetUser = GuildBetUser;
@@ -1,31 +0,0 @@
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
- }
@@ -1,57 +0,0 @@
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;
@@ -1,34 +0,0 @@
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
- }
@@ -1,121 +0,0 @@
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;
@@ -1,41 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Guild } from "../guild/Guild";
3
- import { APIGuildMediator } from "../../types/api/APIGuildMediator";
4
- import { Optional } from "../../types/api";
5
- import { GuildMediatorManager } from "../../managers/mediator/GuildMediatorManager";
6
- export declare class GuildMediator {
7
- /** Mediator's id */
8
- id: string;
9
- /** Mediator's name */
10
- name: string;
11
- /** Mediator's links */
12
- paymentLinks: string[];
13
- /** Creation Date */
14
- createdAt: Date;
15
- /** Updated Date */
16
- updatedAt: Date;
17
- /** The given guild */
18
- readonly guild: Guild;
19
- /** The rest client */
20
- readonly rest: REST;
21
- readonly manager: GuildMediatorManager;
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: APIGuildMediator, guild: Guild, manager: GuildMediatorManager, rest: REST);
29
- /** String representation of this mediator */
30
- toString(): string;
31
- /**
32
- * Fetches the mediator
33
- * @returns New Instance of the mediator
34
- */
35
- fetch(): Promise<GuildMediator>;
36
- update(data: Optional<APIGuildMediator>): Promise<this>;
37
- delete(): Promise<boolean>;
38
- setLinks(link: string): Promise<string[]>;
39
- removeLink(link: string): Promise<string[]>;
40
- toJSON(): Record<string, unknown>;
41
- }
@@ -1,131 +0,0 @@
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;
@@ -1,52 +0,0 @@
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
- }