@duque.edits/sdk 0.1.5 → 0.1.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.
Files changed (118) hide show
  1. package/dist/index.js +4 -31
  2. package/dist/managers/base.js +26 -0
  3. package/dist/managers/buffer/BufferManager.js +2 -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 -31
  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 +23 -23
  12. package/dist/rest/REST.js +40 -24
  13. package/dist/rest/Routes.js +15 -17
  14. package/dist/rest/index.js +19 -0
  15. package/dist/structures/Collection.js +1 -1
  16. package/dist/structures/guild/Guild.js +59 -94
  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 +46 -40
  21. package/dist/structures/vipmember/VipMember.js +5 -5
  22. package/dist/types/api/APILogMessage.js +2 -0
  23. package/dist/types/api/index.js +36 -0
  24. package/dist/types/index.js +1 -22
  25. package/package.json +11 -18
  26. package/types/index.d.ts +4 -0
  27. package/types/managers/base.d.ts +17 -0
  28. package/{dist → types}/managers/buffer/BufferManager.d.ts +2 -1
  29. package/{dist → types}/managers/guild/GuildManager.d.ts +12 -4
  30. package/types/managers/index.d.ts +7 -0
  31. package/{dist → types}/managers/match/GuildMatchManager.d.ts +10 -12
  32. package/types/managers/message/MessagesManager.d.ts +17 -0
  33. package/types/managers/permission/GuildPermissionManager.d.ts +8 -0
  34. package/types/managers/ticket/TicketManager.d.ts +22 -0
  35. package/types/managers/user/GuildUserManager.d.ts +19 -0
  36. package/{dist → types}/managers/vipmember/VipMemberManager.d.ts +8 -8
  37. package/types/rest/APIEndpoints.d.ts +11 -0
  38. package/{dist → types}/rest/REST.d.ts +9 -18
  39. package/{dist → types}/rest/Routes.d.ts +2 -2
  40. package/types/rest/index.d.ts +3 -0
  41. package/{dist → types}/structures/guild/Guild.d.ts +12 -29
  42. package/types/structures/index.d.ts +6 -0
  43. package/{dist → types}/structures/match/GuildMatch.d.ts +12 -22
  44. package/types/structures/ticket/Ticket.d.ts +30 -0
  45. package/{dist → types}/structures/user/GuildUser.d.ts +5 -3
  46. package/{dist → types}/structures/vipmember/VipMember.d.ts +1 -1
  47. package/types/types/RestTypes.d.ts +34 -0
  48. package/{dist → types}/types/api/APIGuild.d.ts +9 -2
  49. package/{dist → types}/types/api/APIGuildMatch.d.ts +9 -7
  50. package/types/types/api/APIGuildTicket.d.ts +16 -0
  51. package/{dist → types}/types/api/APIGuildUser.d.ts +3 -1
  52. package/types/types/api/APILogMessage.d.ts +7 -0
  53. package/{dist → types}/types/api/APIMessage.d.ts +3 -4
  54. package/{dist → types}/types/api/APIPlayer.d.ts +1 -1
  55. package/{dist → types}/types/api/index.d.ts +23 -1
  56. package/types/types/index.d.ts +2 -0
  57. package/dist/index.d.ts +0 -31
  58. package/dist/managers/bet/GuildBetManager.d.ts +0 -35
  59. package/dist/managers/bet/GuildBetManager.js +0 -126
  60. package/dist/managers/betuser/GuildBetUserManager.d.ts +0 -36
  61. package/dist/managers/betuser/GuildBetUserManager.js +0 -151
  62. package/dist/managers/channel/ChannelManager.d.ts +0 -39
  63. package/dist/managers/channel/ChannelManager.js +0 -148
  64. package/dist/managers/giveaway/GiveawayManager.d.ts +0 -16
  65. package/dist/managers/giveaway/GiveawayManager.js +0 -57
  66. package/dist/managers/groupedchannel/GroupedChannelManager.d.ts +0 -34
  67. package/dist/managers/groupedchannel/GroupedChannelManager.js +0 -92
  68. package/dist/managers/mediator/GuildMediatorManager.d.ts +0 -32
  69. package/dist/managers/mediator/GuildMediatorManager.js +0 -98
  70. package/dist/managers/messages/MessagesManager.d.ts +0 -32
  71. package/dist/managers/messages/MessagesManager.js +0 -89
  72. package/dist/managers/permission/GuildPermissionManager.d.ts +0 -26
  73. package/dist/managers/product/GuildProductManager.d.ts +0 -32
  74. package/dist/managers/product/GuildProductManager.js +0 -103
  75. package/dist/managers/ticket/GuildTicketManager.d.ts +0 -32
  76. package/dist/managers/ticket/GuildTicketManager.js +0 -100
  77. package/dist/managers/user/GuildUserManager.d.ts +0 -33
  78. package/dist/rest/APIEndpoints.d.ts +0 -11
  79. package/dist/structures/bet/GuildBet.d.ts +0 -87
  80. package/dist/structures/bet/GuildBet.js +0 -286
  81. package/dist/structures/betuser/GuildBetUser.d.ts +0 -85
  82. package/dist/structures/betuser/GuildBetUser.js +0 -211
  83. package/dist/structures/channel/Channel.d.ts +0 -31
  84. package/dist/structures/channel/Channel.js +0 -57
  85. package/dist/structures/giveaway/Giveaway.d.ts +0 -37
  86. package/dist/structures/giveaway/Giveaway.js +0 -208
  87. package/dist/structures/groupedchannel/GroupedChannel.d.ts +0 -34
  88. package/dist/structures/groupedchannel/GroupedChannel.js +0 -121
  89. package/dist/structures/mediator/GuildMediator.d.ts +0 -41
  90. package/dist/structures/mediator/GuildMediator.js +0 -131
  91. package/dist/structures/product/GuildProduct.d.ts +0 -52
  92. package/dist/structures/product/GuildProduct.js +0 -175
  93. package/dist/structures/shop/GuildShop.d.ts +0 -34
  94. package/dist/structures/shop/GuildShop.js +0 -80
  95. package/dist/structures/ticket/GuildTicket.d.ts +0 -52
  96. package/dist/structures/ticket/GuildTicket.js +0 -172
  97. package/dist/types/api/APIGuildTicket.d.ts +0 -26
  98. package/dist/types/index.d.ts +0 -23
  99. /package/dist/types/{api/APIGuildMessage.js → RestTypes.js} +0 -0
  100. /package/{dist → types}/structures/Collection.d.ts +0 -0
  101. /package/{dist → types}/types/api/APIBaseChannel.d.ts +0 -0
  102. /package/{dist → types}/types/api/APIBetChannel.d.ts +0 -0
  103. /package/{dist → types}/types/api/APIBetMessage.d.ts +0 -0
  104. /package/{dist → types}/types/api/APIGiveaway.d.ts +0 -0
  105. /package/{dist → types}/types/api/APIGuildBet.d.ts +0 -0
  106. /package/{dist → types}/types/api/APIGuildBetUser.d.ts +0 -0
  107. /package/{dist → types}/types/api/APIGuildChannel.d.ts +0 -0
  108. /package/{dist → types}/types/api/APIGuildEmoji.d.ts +0 -0
  109. /package/{dist → types}/types/api/APIGuildGroupedChannel.d.ts +0 -0
  110. /package/{dist → types}/types/api/APIGuildMediator.d.ts +0 -0
  111. /package/{dist → types}/types/api/APIGuildMessage.d.ts +0 -0
  112. /package/{dist → types}/types/api/APIGuildPermissions.d.ts +0 -0
  113. /package/{dist → types}/types/api/APIGuildRole.d.ts +0 -0
  114. /package/{dist → types}/types/api/APIGuildShop.d.ts +0 -0
  115. /package/{dist → types}/types/api/APIProduct.d.ts +0 -0
  116. /package/{dist → types}/types/api/APIVipMember.d.ts +0 -0
  117. /package/{dist → types}/utils/Assertion.d.ts +0 -0
  118. /package/{dist → types}/utils/getRandomNumber.d.ts +0 -0
@@ -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,37 +0,0 @@
1
- import { GiveawayManager } from "../../managers/giveaway/GiveawayManager";
2
- import { REST } from "../../rest/REST";
3
- import { Optional } from "../../types";
4
- import { APIGiveaway, GiveawayMessage, GiveawayWinners } from "../../types/api/APIGiveaway";
5
- type AllowedTypes = Optional<APIGiveaway> | Giveaway;
6
- export declare class Giveaway {
7
- host_id: string;
8
- channel_id: string;
9
- guild_id: string;
10
- _id: string;
11
- /** Duration of giveaway in sec */
12
- duration: number;
13
- prizes: string[];
14
- participants: string[];
15
- allowed_roles: string[];
16
- blacklisted_roles: string[];
17
- message: GiveawayMessage;
18
- winners: GiveawayWinners;
19
- rerolls: string[];
20
- status: "created" | "off" | "on";
21
- createdAt: Date;
22
- updatedAt: Date;
23
- readonly rest: REST;
24
- readonly manager: GiveawayManager;
25
- constructor(data: AllowedTypes, manager: GiveawayManager);
26
- end(): Promise<boolean>;
27
- start(): Promise<boolean>;
28
- addAllowedRole(roleId: string): Promise<boolean>;
29
- addBlacklistedRole(roleId: string): Promise<boolean>;
30
- getWinners(): Promise<this>;
31
- addParticipant(userId: string): Promise<this>;
32
- removeParticipant(userId: string): Promise<this>;
33
- reroll(winners?: string[]): Promise<this>;
34
- delete(): Promise<boolean>;
35
- update(data: AllowedTypes): Promise<this>;
36
- }
37
- export {};
@@ -1,208 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Giveaway = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const getRandomNumber_1 = require("../../utils/getRandomNumber");
6
- class Giveaway {
7
- host_id;
8
- channel_id;
9
- guild_id;
10
- _id;
11
- /** Duration of giveaway in sec */
12
- duration;
13
- prizes;
14
- participants;
15
- allowed_roles;
16
- blacklisted_roles;
17
- message;
18
- winners;
19
- rerolls;
20
- status;
21
- createdAt;
22
- updatedAt;
23
- rest;
24
- manager;
25
- constructor(data, manager) {
26
- this._id = data?._id;
27
- this.host_id = data?.host_id;
28
- this.channel_id = data?.channel_id;
29
- this.guild_id = data?.guild_id;
30
- this.status = data?.status;
31
- /** Duration of giveaway in sec */
32
- this.duration = data?.duration;
33
- this.prizes = data?.prizes;
34
- this.participants = data?.participants;
35
- this.allowed_roles = data?.allowed_roles;
36
- this.blacklisted_roles = data?.blacklisted_roles;
37
- this.message = data?.message;
38
- this.winners = data?.winners;
39
- this.rerolls = data?.rerolls;
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 = manager.rest;
44
- }
45
- async end() {
46
- const route = Routes_1.Routes.giveaways.get(this._id);
47
- const payload = { status: "off" };
48
- const response = await this.rest.request({
49
- method: "patch",
50
- url: route,
51
- payload,
52
- });
53
- for (const k in response) {
54
- if (k === "id")
55
- continue;
56
- if (Object.hasOwn(this, k)) {
57
- this[k] = response[k];
58
- }
59
- }
60
- this.manager.set(this);
61
- return true;
62
- }
63
- async start() {
64
- const route = Routes_1.Routes.giveaways.get(this._id);
65
- const payload = { status: "on" };
66
- const response = await this.rest.request({
67
- method: "patch",
68
- url: route,
69
- payload,
70
- });
71
- for (const k in response) {
72
- if (k === "id")
73
- continue;
74
- if (Object.hasOwn(this, k)) {
75
- this[k] = response[k];
76
- }
77
- }
78
- this.manager.set(this);
79
- return true;
80
- }
81
- async addAllowedRole(roleId) {
82
- const route = Routes_1.Routes.giveaways.get(this._id);
83
- const payload = { allowed_roles: [...new Set([...this.allowed_roles, roleId])] };
84
- const response = await this.rest.request({
85
- method: "patch",
86
- url: route,
87
- payload,
88
- });
89
- for (const k in response) {
90
- if (k === "id")
91
- continue;
92
- if (Object.hasOwn(this, k)) {
93
- this[k] = response[k];
94
- }
95
- }
96
- this.manager.set(this);
97
- return true;
98
- }
99
- async addBlacklistedRole(roleId) {
100
- const route = Routes_1.Routes.giveaways.get(this._id);
101
- const payload = { blacklisted_roles: [...new Set([...this.blacklisted_roles, roleId])] };
102
- const response = await this.rest.request({
103
- method: "patch",
104
- url: route,
105
- payload,
106
- });
107
- for (const k in response) {
108
- if (k === "id")
109
- continue;
110
- if (Object.hasOwn(this, k)) {
111
- this[k] = response[k];
112
- }
113
- }
114
- this.manager.set(this);
115
- return true;
116
- }
117
- async getWinners() {
118
- let winners;
119
- if (this.participants.length !== 0) {
120
- for (let index = 0; index < this.participants.length; index++) {
121
- const winnerIndex = (0, getRandomNumber_1.getRandomNumber)(1, this.participants.length ?? 1);
122
- winners.push(this.participants[winnerIndex]);
123
- }
124
- }
125
- else
126
- winners = [];
127
- const newWinners = { count: winners.length, selected: winners };
128
- this.winners = newWinners;
129
- const route = Routes_1.Routes.giveaways.get(this._id);
130
- const payload = { winners: newWinners };
131
- const response = await this.rest.request({
132
- method: "patch",
133
- url: route,
134
- payload,
135
- });
136
- this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
137
- this.manager.set(this);
138
- return this;
139
- }
140
- async addParticipant(userId) {
141
- const route = Routes_1.Routes.fields(Routes_1.Routes.giveaways.get(this._id), "participants");
142
- const payload = { userId };
143
- const response = await this.rest.request({
144
- method: "post",
145
- url: route,
146
- payload,
147
- });
148
- this.participants = response.participants;
149
- this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
150
- this.manager.set(this);
151
- return this;
152
- }
153
- async removeParticipant(userId) {
154
- const route = Routes_1.Routes.fields(Routes_1.Routes.giveaways.get(this._id), "participants");
155
- const payload = { userId };
156
- const response = await this.rest.request({
157
- method: "delete",
158
- url: route,
159
- payload,
160
- });
161
- this.participants = response.participants;
162
- this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
163
- this.manager.set(this);
164
- return this;
165
- }
166
- async reroll(winners) {
167
- const route = Routes_1.Routes.fields(Routes_1.Routes.giveaways.get(this._id), "rerolls");
168
- const payload = { winners };
169
- const response = await this.rest.request({
170
- method: "post",
171
- url: route,
172
- payload,
173
- });
174
- this.rerolls = response.rerolls;
175
- this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
176
- this.manager.set(this);
177
- return this;
178
- }
179
- async delete() {
180
- const route = Routes_1.Routes.giveaways.delete(this._id);
181
- const response = await this.rest.request({
182
- method: "delete",
183
- url: route,
184
- });
185
- this.manager.cache.delete(this._id);
186
- return true;
187
- }
188
- async update(data) {
189
- const route = Routes_1.Routes.giveaways.update(this._id);
190
- const payload = data;
191
- const response = await this.rest.request({
192
- method: "patch",
193
- url: route,
194
- payload,
195
- });
196
- for (const k in response) {
197
- if (k === "id")
198
- continue;
199
- if (Object.hasOwn(this, k)) {
200
- this[k] = response[k];
201
- }
202
- }
203
- this.updatedAt = response?.updatedAt ? new Date(response?.updatedAt) : new Date();
204
- this.manager.set(this);
205
- return this;
206
- }
207
- }
208
- exports.Giveaway = Giveaway;
@@ -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
- }