@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,148 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChannelManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const Channel_1 = require("../../structures/channel/Channel");
6
- const Collection_1 = require("../../structures/Collection");
7
- const Assertion_1 = require("../../utils/Assertion");
8
- class ChannelManager {
9
- /** A cache of bet channels */
10
- cache;
11
- /** The rest client */
12
- rest;
13
- /** GuildBet user guild */
14
- guild;
15
- /** The bet */
16
- structure;
17
- /** Base Url */
18
- baseUrl;
19
- /**
20
- * Manage channels of a bet
21
- * @param guild The guild at hand
22
- * @param bet The bet at hand
23
- * @param rest The rest client
24
- */
25
- constructor(guild, structure, rest) {
26
- this.structure = structure;
27
- this.rest = rest;
28
- this.guild = guild;
29
- this.cache = new Collection_1.Collection("channels");
30
- this.baseUrl = Routes_1.Routes.guilds[structure.key].resource(guild.id, structure._id, "channels");
31
- }
32
- async create(data) {
33
- const { id, type } = data;
34
- Assertion_1.Assertion.assertString(id);
35
- Assertion_1.Assertion.assertString(type);
36
- const route = this.baseUrl;
37
- const payload = { id, type };
38
- const response = await this.rest.request({
39
- method: "POST",
40
- url: route,
41
- payload,
42
- });
43
- const channel = this.set(response);
44
- this.rest.emit("channelCreate", channel);
45
- return channel;
46
- }
47
- async createMany(...channels) {
48
- Assertion_1.Assertion.assertArray(channels);
49
- const route = Routes_1.Routes.fields(this.baseUrl, "bulk");
50
- const payload = { channels };
51
- const response = await this.rest.request({
52
- method: "POST",
53
- url: route,
54
- payload,
55
- });
56
- this.rest.emit("channelBulkCreate", response);
57
- return this.setAll(response);
58
- }
59
- async deleteMany(...channels) {
60
- Assertion_1.Assertion.assertArray(channels);
61
- const route = Routes_1.Routes.fields(this.baseUrl, "bulk");
62
- const payload = { channels };
63
- const response = await this.rest.request({
64
- method: "DELETE",
65
- url: route,
66
- payload,
67
- });
68
- const channel = this.setAll(response);
69
- this.rest.emit("channelBulkDelete", channel);
70
- return channel;
71
- }
72
- setAll(data) {
73
- if (!data)
74
- return this.cache;
75
- for (let channelData of data)
76
- this.set(channelData);
77
- return this.cache;
78
- }
79
- set(data) {
80
- if (!data?.type)
81
- return;
82
- const channel = new Channel_1.Channel({
83
- baseUrl: Routes_1.Routes.guilds[this.structure.key].resource(this.guild.id, this.structure._id, "channels"),
84
- data: data,
85
- guild: this.guild,
86
- manager: this,
87
- }, this.rest);
88
- this.cache.set(data.type, channel);
89
- return channel;
90
- }
91
- async update(type, payload) {
92
- Assertion_1.Assertion.assertString(type);
93
- Assertion_1.Assertion.assertObject(payload);
94
- const route = Routes_1.Routes.fields(this.baseUrl, type);
95
- const response = await this.rest.request({
96
- method: "PATCH",
97
- url: route,
98
- payload,
99
- });
100
- const channel = this.set(response);
101
- this.rest.emit("betUpdate", this.structure, this.structure);
102
- return channel;
103
- }
104
- async fetch(type) {
105
- Assertion_1.Assertion.assertString(type);
106
- const route = Routes_1.Routes.fields(this.baseUrl, type);
107
- const response = await this.rest.request({
108
- method: "GET",
109
- url: route,
110
- });
111
- const channel = this.set(response);
112
- this.cache.set(channel.type, channel);
113
- return channel;
114
- }
115
- async fetchAll() {
116
- const response = await this.rest.request({
117
- method: "GET",
118
- url: this.baseUrl,
119
- });
120
- if (Array.isArray(response) && response.length === 0) {
121
- this.cache.clear();
122
- return this.cache;
123
- }
124
- for (let channelData of response)
125
- this.set(channelData);
126
- return this.cache;
127
- }
128
- async delete(type) {
129
- Assertion_1.Assertion.assertString(type);
130
- const route = this.baseUrl;
131
- const response = await this.rest.request({
132
- method: "DELETE",
133
- url: Routes_1.Routes.fields(route, type),
134
- });
135
- this.cache.delete(type);
136
- return this.cache;
137
- }
138
- async deleteAll() {
139
- const route = this.baseUrl;
140
- const value = await this.rest.request({
141
- method: "DELETE",
142
- url: route,
143
- });
144
- this.cache.clear();
145
- return value;
146
- }
147
- }
148
- exports.ChannelManager = ChannelManager;
@@ -1,34 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { GroupedChannel } from "../../structures/groupedchannel/GroupedChannel";
3
- import { Collection } from "../../structures/Collection";
4
- import { Guild } from "../../structures/guild/Guild";
5
- import { Optional } from "../../types/api";
6
- import { APIGuildGroupedChannel } from "../../types/api/APIGuildGroupedChannel";
7
- export declare class GroupedChannelManager {
8
- /** A cache of channels */
9
- cache: Collection<string, GroupedChannel>;
10
- /** Key */
11
- key: string;
12
- baseUrl: string;
13
- /** The rest client */
14
- rest: REST;
15
- /** GroupedChannel groupedChannel guild */
16
- guild: Guild;
17
- /**
18
- * Manage channels with the given client
19
- * @param channels An array of channels
20
- * @param rest The rest client
21
- */
22
- constructor(guild: Guild, key: string, rest: REST);
23
- delete(type: string): Promise<boolean>;
24
- create(payload: Optional<APIGuildGroupedChannel>): Promise<GroupedChannel>;
25
- /**
26
- * Fetch a groupedChannel
27
- * @param id Id of the groupedChannel to fetch
28
- * @returns APIgroupedChannelUser
29
- */
30
- fetch(type: string): Promise<GroupedChannel>;
31
- fetchAll(): Promise<Collection<string, GroupedChannel>>;
32
- setAll(data: APIGuildGroupedChannel[]): Collection<string, GroupedChannel>;
33
- set(data: APIGuildGroupedChannel): GroupedChannel;
34
- }
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GroupedChannelManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const GroupedChannel_1 = require("../../structures/groupedchannel/GroupedChannel");
6
- const Collection_1 = require("../../structures/Collection");
7
- const Assertion_1 = require("../../utils/Assertion");
8
- class GroupedChannelManager {
9
- /** A cache of channels */
10
- cache;
11
- /** Key */
12
- key;
13
- baseUrl;
14
- /** The rest client */
15
- rest;
16
- /** GroupedChannel groupedChannel guild */
17
- guild;
18
- /**
19
- * Manage channels with the given client
20
- * @param channels An array of channels
21
- * @param rest The rest client
22
- */
23
- constructor(guild, key, rest) {
24
- this.key = key;
25
- this.baseUrl = Routes_1.Routes.fields(Routes_1.Routes.guilds.get(guild?.id), key);
26
- this.cache = new Collection_1.Collection("groupedChannels");
27
- this.guild = guild;
28
- this.rest = rest;
29
- }
30
- async delete(type) {
31
- const route = Routes_1.Routes.fields(this.baseUrl, type);
32
- const response = await this.rest.request({
33
- method: "delete",
34
- url: route,
35
- });
36
- this.cache.delete(type);
37
- return response;
38
- }
39
- async create(payload) {
40
- Assertion_1.Assertion.assertObject(payload);
41
- const route = this.baseUrl;
42
- const response = await this.rest.request({
43
- method: "POST",
44
- url: route,
45
- payload,
46
- });
47
- const groupedChannel = this.set(response);
48
- return groupedChannel;
49
- }
50
- /**
51
- * Fetch a groupedChannel
52
- * @param id Id of the groupedChannel to fetch
53
- * @returns APIgroupedChannelUser
54
- */
55
- async fetch(type) {
56
- const route = Routes_1.Routes.fields(this.baseUrl, type);
57
- const response = await this.rest.request({
58
- method: "get",
59
- url: route,
60
- });
61
- const channel = this.set(response);
62
- this.cache.set(channel.type, channel);
63
- return channel;
64
- }
65
- async fetchAll() {
66
- const route = this.baseUrl;
67
- const response = await this.rest.request({
68
- method: "get",
69
- url: route,
70
- });
71
- for (let groupedChannelData of response) {
72
- const groupedChannel = new GroupedChannel_1.GroupedChannel(groupedChannelData, this.guild, this, this.rest);
73
- this.cache.set(groupedChannel.type, groupedChannel);
74
- }
75
- return this.cache;
76
- }
77
- setAll(data) {
78
- if (!data)
79
- return this.cache;
80
- for (let groupedChannel of data)
81
- this.set(groupedChannel);
82
- return this.cache;
83
- }
84
- set(data) {
85
- if (!data?.type)
86
- return;
87
- const groupedChannel = new GroupedChannel_1.GroupedChannel(data, this.guild, this, this.rest);
88
- this.cache.set(data.type, groupedChannel);
89
- return groupedChannel;
90
- }
91
- }
92
- exports.GroupedChannelManager = GroupedChannelManager;
@@ -1,32 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Collection } from "../../structures/Collection";
3
- import { Guild } from "../../structures/guild/Guild";
4
- import { GuildMediator } from "../../structures/mediator/GuildMediator";
5
- import { Optional } from "../../types/api";
6
- import { APIGuildMediator } from "../../types/api/APIGuildMediator";
7
- export declare class GuildMediatorManager {
8
- /** A cache of users */
9
- cache: Collection<string, GuildMediator>;
10
- /** The rest client */
11
- rest: REST;
12
- /** GuildMediator mediator guild */
13
- guild: Guild;
14
- /**
15
- * Manage users with the given client
16
- * @param users An array of users
17
- * @param rest The rest client
18
- */
19
- constructor(guild: Guild, rest: REST);
20
- create(payload: Optional<APIGuildMediator>): Promise<GuildMediator>;
21
- /**
22
- * Fetch a mediator
23
- * @param id Id of the mediator to fetch
24
- * @returns APImediatorUser
25
- */
26
- fetch(id: string): Promise<GuildMediator>;
27
- fetchAll(): Promise<Collection<string, GuildMediator>>;
28
- set(data: APIGuildMediator): GuildMediator;
29
- setAll(data: APIGuildMediator[]): Collection<string, GuildMediator>;
30
- delete(id: string): Promise<Collection<string, GuildMediator>>;
31
- deleteAll(): Promise<boolean>;
32
- }
@@ -1,98 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildMediatorManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const Collection_1 = require("../../structures/Collection");
6
- const GuildMediator_1 = require("../../structures/mediator/GuildMediator");
7
- const Assertion_1 = require("../../utils/Assertion");
8
- class GuildMediatorManager {
9
- /** A cache of users */
10
- cache;
11
- /** The rest client */
12
- rest;
13
- /** GuildMediator mediator guild */
14
- guild;
15
- /**
16
- * Manage users with the given client
17
- * @param users An array of users
18
- * @param rest The rest client
19
- */
20
- constructor(guild, rest) {
21
- this.guild = guild;
22
- this.rest = rest;
23
- this.cache = new Collection_1.Collection("mediators");
24
- }
25
- async create(payload) {
26
- Assertion_1.Assertion.assertObject(payload);
27
- const route = Routes_1.Routes.guilds.mediators.create(this.guild.id);
28
- const response = await this.rest.request({
29
- method: "POST",
30
- url: route,
31
- payload,
32
- });
33
- const mediator = this.set(response);
34
- return mediator;
35
- }
36
- /**
37
- * Fetch a mediator
38
- * @param id Id of the mediator to fetch
39
- * @returns APImediatorUser
40
- */
41
- async fetch(id) {
42
- const route = Routes_1.Routes.guilds.mediators.get(this.guild.id, id);
43
- const response = await this.rest.request({
44
- method: "get",
45
- url: route,
46
- });
47
- const mediator = new GuildMediator_1.GuildMediator(response, this.guild, this, this.rest);
48
- this.cache.set(mediator.id, mediator);
49
- return mediator;
50
- }
51
- async fetchAll() {
52
- const route = Routes_1.Routes.guilds.mediators.getAll(this.guild.id);
53
- const response = await this.rest.request({
54
- method: "get",
55
- url: route,
56
- });
57
- this.setAll(response);
58
- return this.cache;
59
- }
60
- set(data) {
61
- if (!data.id)
62
- return;
63
- const mediator = new GuildMediator_1.GuildMediator(data, this.guild, this, this.rest);
64
- this.cache.set(data?.id, mediator);
65
- this.rest.mediators.set(mediator.id, mediator);
66
- return mediator;
67
- }
68
- setAll(data) {
69
- if (!data)
70
- return this.cache;
71
- for (let mediator of data)
72
- this.set(mediator);
73
- return this.cache;
74
- }
75
- async delete(id) {
76
- Assertion_1.Assertion.assertString(id);
77
- const route = Routes_1.Routes.guilds.mediators.delete(this.guild.id, id);
78
- const mediator = this.cache.get(id);
79
- this.rest.emit("mediatorDelete", mediator);
80
- await this.rest.request({
81
- method: "DELETE",
82
- url: route,
83
- });
84
- this.cache.delete(id);
85
- return this.cache;
86
- }
87
- async deleteAll() {
88
- const route = Routes_1.Routes.guilds.mediators.deleteAll(this.guild.id);
89
- this.rest.emit("mediatorsDelete", this.cache);
90
- const value = await this.rest.request({
91
- method: "DELETE",
92
- url: route,
93
- });
94
- this.cache.clear();
95
- return value;
96
- }
97
- }
98
- exports.GuildMediatorManager = GuildMediatorManager;
@@ -1,32 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Collection } from "../../structures/Collection";
3
- import { Guild } from "../../structures/guild/Guild";
4
- import { Optional } from "../../types/api";
5
- import { APIMessage } from "../../types/api/APIMessage";
6
- export declare class MessagesManager {
7
- /** A cache of messages */
8
- cache: Collection<string, APIMessage>;
9
- /** Key */
10
- key: string;
11
- baseUrl: string;
12
- /** The rest client */
13
- rest: REST;
14
- /** APIMessage message guild */
15
- guild: Guild;
16
- /**
17
- * Manage messages with the given client
18
- * @param messages An array of messages
19
- * @param rest The rest client
20
- */
21
- constructor(guild: Guild, key: string, rest: REST);
22
- create(payload: Optional<APIMessage>): Promise<boolean>;
23
- /**
24
- * Fetch a message
25
- * @param id Id of the message to fetch
26
- * @returns APIgroupedChannelUser
27
- */
28
- fetch(type: string): Promise<APIMessage>;
29
- fetchAll(): Promise<Collection<string, APIMessage>>;
30
- set(data: APIMessage | APIMessage[]): Collection<string, APIMessage>;
31
- setAll(data: APIMessage[]): Collection<string, APIMessage>;
32
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessagesManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const Collection_1 = require("../../structures/Collection");
6
- const Assertion_1 = require("../../utils/Assertion");
7
- class MessagesManager {
8
- /** A cache of messages */
9
- cache;
10
- /** Key */
11
- key;
12
- baseUrl;
13
- /** The rest client */
14
- rest;
15
- /** APIMessage message guild */
16
- guild;
17
- /**
18
- * Manage messages with the given client
19
- * @param messages An array of messages
20
- * @param rest The rest client
21
- */
22
- constructor(guild, key, rest) {
23
- this.guild = guild;
24
- this.key = key;
25
- this.baseUrl = Routes_1.Routes.fields(Routes_1.Routes.guilds.get(guild?.id), key, "messages");
26
- this.cache = new Collection_1.Collection(`${key}-messages`);
27
- this.rest = rest;
28
- }
29
- async create(payload) {
30
- Assertion_1.Assertion.assertObject(payload);
31
- const route = this.baseUrl;
32
- const response = await this.rest.request({
33
- method: "POST",
34
- url: route,
35
- payload,
36
- });
37
- this.set(response);
38
- return true;
39
- }
40
- /**
41
- * Fetch a message
42
- * @param id Id of the message to fetch
43
- * @returns APIgroupedChannelUser
44
- */
45
- async fetch(type) {
46
- const route = Routes_1.Routes.fields(this.baseUrl, type);
47
- const response = await this.rest.request({
48
- method: "get",
49
- url: route,
50
- });
51
- const message = this.set(response);
52
- this.set(response);
53
- return response;
54
- }
55
- async fetchAll() {
56
- const route = this.baseUrl;
57
- const response = await this.rest.request({
58
- method: "get",
59
- url: route,
60
- });
61
- for (let data of response) {
62
- if (!data.type)
63
- continue;
64
- this.cache.set(`${data?.userId}-${Date.now() * Math.random() + 100}`, data);
65
- }
66
- return this.cache;
67
- }
68
- set(data) {
69
- if (Array.isArray(data)) {
70
- for (let message of data) {
71
- if (!message?.type)
72
- return;
73
- this.cache.set(`${message?.userId}-${Date.now() * Math.random() + 50}`, message);
74
- }
75
- }
76
- else {
77
- this.cache.set(`${data?.userId}-${Date.now() * Math.random() + 5}`, data);
78
- }
79
- return this.cache;
80
- }
81
- setAll(data) {
82
- if (!data)
83
- return this.cache;
84
- for (let message of data)
85
- this.set(message);
86
- return this.cache;
87
- }
88
- }
89
- exports.MessagesManager = MessagesManager;
@@ -1,26 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Guild } from "../../structures/guild/Guild";
3
- import { APIGuildPermissions } from "../../types/api/APIGuildPermissions";
4
- export declare class GuildPermissionManager {
5
- /** The rest client */
6
- rest: REST;
7
- /** GuildBet bet guild */
8
- guild: Guild;
9
- permissions: APIGuildPermissions;
10
- /**
11
- * Manage users with the given client
12
- * @param users An array of users
13
- * @param rest The rest client
14
- */
15
- constructor(guild: Guild, rest: REST);
16
- /**
17
- * Fetch a bet
18
- * @param id Id of the bet to fetch
19
- * @returns APIBetUser
20
- */
21
- fetch(): Promise<void>;
22
- addId(permissionId: keyof APIGuildPermissions, roleId: string): Promise<string[]>;
23
- removeId(permissionId: keyof APIGuildPermissions, roleId: string): Promise<string[]>;
24
- setAll(data: APIGuildPermissions): APIGuildPermissions;
25
- toJSON(): Record<string, unknown>;
26
- }
@@ -1,32 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { Collection } from "../../structures/Collection";
3
- import { Guild } from "../../structures/guild/Guild";
4
- import { GuildProduct } from "../../structures/product/GuildProduct";
5
- import { Optional } from "../../types/api";
6
- import { APIProduct } from "../../types/api/APIProduct";
7
- export declare class GuildProductManager {
8
- /** A cache of users */
9
- cache: Collection<string, GuildProduct>;
10
- /** The rest client */
11
- rest: REST;
12
- /** GuildProduct product guild */
13
- guild: Guild;
14
- /**
15
- * Manage users with the given client
16
- * @param users An array of users
17
- * @param rest The rest client
18
- */
19
- constructor(guild: Guild, rest: REST);
20
- create(payload: Optional<APIProduct>): Promise<GuildProduct>;
21
- /**
22
- * Fetch a product
23
- * @param id Id of the product to fetch
24
- * @returns APIBetUser
25
- */
26
- fetch(id: string): Promise<GuildProduct>;
27
- fetchAll(): Promise<Collection<string, GuildProduct>>;
28
- set(data: APIProduct): GuildProduct;
29
- setAll(data: APIProduct[]): Collection<string, GuildProduct>;
30
- delete(id: string, type: string): Promise<Collection<string, GuildProduct>>;
31
- deleteAll(): Promise<boolean>;
32
- }
@@ -1,103 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildProductManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const Collection_1 = require("../../structures/Collection");
6
- const GuildProduct_1 = require("../../structures/product/GuildProduct");
7
- const Assertion_1 = require("../../utils/Assertion");
8
- class GuildProductManager {
9
- /** A cache of users */
10
- cache;
11
- /** The rest client */
12
- rest;
13
- /** GuildProduct product guild */
14
- guild;
15
- /**
16
- * Manage users with the given client
17
- * @param users An array of users
18
- * @param rest The rest client
19
- */
20
- constructor(guild, rest) {
21
- this.guild = guild;
22
- this.rest = rest;
23
- this.cache = new Collection_1.Collection("products");
24
- }
25
- async create(payload) {
26
- Assertion_1.Assertion.assertObject(payload);
27
- const route = Routes_1.Routes.guilds.shop.products.create(this.guild.id);
28
- const response = await this.rest.request({
29
- method: "POST",
30
- url: route,
31
- payload
32
- });
33
- const product = this.set(response);
34
- return product;
35
- }
36
- /**
37
- * Fetch a product
38
- * @param id Id of the product to fetch
39
- * @returns APIBetUser
40
- */
41
- async fetch(id) {
42
- const route = Routes_1.Routes.guilds.shop.products.get(this.guild.id, id);
43
- const response = await this.rest.request({
44
- method: "get",
45
- url: route,
46
- });
47
- const product = new GuildProduct_1.GuildProduct(response, this, this.rest);
48
- this.cache.set(product.id, product);
49
- return product;
50
- }
51
- async fetchAll() {
52
- const route = Routes_1.Routes.guilds.shop.products.getAll(this.guild.id);
53
- const response = await this.rest.request({
54
- method: "get",
55
- url: route,
56
- });
57
- for (let betData of response) {
58
- const product = new GuildProduct_1.GuildProduct(betData, this, this.rest);
59
- this.cache.set(product.id, product);
60
- }
61
- return this.cache;
62
- }
63
- set(data) {
64
- if (!data?.id)
65
- return;
66
- const product = new GuildProduct_1.GuildProduct(data, this, this.rest);
67
- this.cache.set(data.id, product);
68
- return product;
69
- }
70
- setAll(data) {
71
- if (!data)
72
- return this.cache;
73
- for (let product of data)
74
- this.set(product);
75
- return this.cache;
76
- }
77
- async delete(id, type) {
78
- Assertion_1.Assertion.assertString(id);
79
- Assertion_1.Assertion.assertString(type);
80
- const route = Routes_1.Routes.guilds.shop.products.delete(id, this.guild.id);
81
- const payload = { type };
82
- const product = this.cache.get(id);
83
- this.rest.emit("productsDelete", product);
84
- await this.rest.request({
85
- method: "DELETE",
86
- url: route,
87
- payload,
88
- });
89
- this.cache.delete(id);
90
- return this.cache;
91
- }
92
- async deleteAll() {
93
- const route = Routes_1.Routes.guilds.shop.products.deleteAll(this.guild.id);
94
- this.rest.emit("productsDelete", this.cache);
95
- const value = await this.rest.request({
96
- method: "DELETE",
97
- url: route,
98
- });
99
- this.cache.clear();
100
- return value;
101
- }
102
- }
103
- exports.GuildProductManager = GuildProductManager;