@duque.edits/sdk 0.1.5 → 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 (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,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;
@@ -1,32 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { GuildTicket } from "../../structures/ticket/GuildTicket";
3
- import { Collection } from "../../structures/Collection";
4
- import { Guild } from "../../structures/guild/Guild";
5
- import { Optional } from "../../types/api";
6
- import { APIGuildTicket } from "../../types/api/APIGuildTicket";
7
- export declare class GuildTicketManager {
8
- /** A cache of users */
9
- cache: Collection<string, GuildTicket>;
10
- /** The rest client */
11
- rest: REST;
12
- /** GuildTicket ticket 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<APIGuildTicket>): Promise<GuildTicket>;
21
- /**
22
- * Fetch a ticket
23
- * @param id Id of the ticket to fetch
24
- * @returns APIticketUser
25
- */
26
- fetch(id: string): Promise<GuildTicket>;
27
- fetchAll(): Promise<Collection<string, GuildTicket>>;
28
- set(data: APIGuildTicket): GuildTicket;
29
- setAll(data: APIGuildTicket[]): Collection<string, GuildTicket>;
30
- delete(id: string): Promise<Collection<string, GuildTicket>>;
31
- deleteAll(): Promise<boolean>;
32
- }
@@ -1,100 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GuildTicketManager = void 0;
4
- const Routes_1 = require("../../rest/Routes");
5
- const GuildTicket_1 = require("../../structures/ticket/GuildTicket");
6
- const Collection_1 = require("../../structures/Collection");
7
- const Assertion_1 = require("../../utils/Assertion");
8
- class GuildTicketManager {
9
- /** A cache of users */
10
- cache;
11
- /** The rest client */
12
- rest;
13
- /** GuildTicket ticket 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("tickets");
24
- }
25
- async create(payload) {
26
- Assertion_1.Assertion.assertObject(payload);
27
- const route = Routes_1.Routes.guilds.tickets.create(this.guild.id);
28
- const response = await this.rest.request({
29
- method: "POST",
30
- url: route,
31
- payload,
32
- });
33
- const ticket = this.set(response);
34
- return ticket;
35
- }
36
- /**
37
- * Fetch a ticket
38
- * @param id Id of the ticket to fetch
39
- * @returns APIticketUser
40
- */
41
- async fetch(id) {
42
- const route = Routes_1.Routes.guilds.tickets.get(this.guild.id, id);
43
- const response = await this.rest.request({
44
- method: "get",
45
- url: route,
46
- });
47
- const ticket = new GuildTicket_1.GuildTicket(response, this.guild, this, this.rest);
48
- this.cache.set(ticket.id, ticket);
49
- return ticket;
50
- }
51
- async fetchAll() {
52
- const route = Routes_1.Routes.guilds.tickets.getAll(this.guild.id);
53
- const response = await this.rest.request({
54
- method: "get",
55
- url: route,
56
- });
57
- for (let ticketData of response) {
58
- const ticket = new GuildTicket_1.GuildTicket(ticketData, this.guild, this, this.rest);
59
- this.cache.set(ticket.id, ticket);
60
- }
61
- return this.cache;
62
- }
63
- set(data) {
64
- if (!data?.id)
65
- return;
66
- const ticket = new GuildTicket_1.GuildTicket(data, this.guild, this, this.rest);
67
- this.cache.set(data?.id?.toString(), ticket);
68
- return ticket;
69
- }
70
- setAll(data) {
71
- if (!data)
72
- return this.cache;
73
- for (let ticket of data)
74
- this.set(ticket);
75
- return this.cache;
76
- }
77
- async delete(id) {
78
- Assertion_1.Assertion.assertString(id);
79
- const route = Routes_1.Routes.guilds.tickets.delete(id, this.guild.id);
80
- const ticket = this.cache.get(id);
81
- this.rest.emit("ticketDelete", ticket);
82
- await this.rest.request({
83
- method: "DELETE",
84
- url: route,
85
- });
86
- this.cache.delete(id);
87
- return this.cache;
88
- }
89
- async deleteAll() {
90
- const route = Routes_1.Routes.guilds.tickets.deleteAll(this.guild.id);
91
- this.rest.emit("ticketsDelete", this.cache);
92
- const value = await this.rest.request({
93
- method: "DELETE",
94
- url: route,
95
- });
96
- this.cache.clear();
97
- return value;
98
- }
99
- }
100
- exports.GuildTicketManager = GuildTicketManager;
@@ -1,33 +0,0 @@
1
- import { REST } from "../../rest/REST";
2
- import { GuildUser } from "../../structures/user/GuildUser";
3
- import { Collection } from "../../structures/Collection";
4
- import { Guild } from "../../structures/guild/Guild";
5
- import { APIGuildUser } from "../../types/api/APIGuildUser";
6
- import { Optional } from "../../types";
7
- export declare class GuildUserManager {
8
- /** A cache of users */
9
- cache: Collection<string, GuildUser>;
10
- /** The rest client */
11
- rest: REST;
12
- /** Bet user 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
- /**
21
- * Fetch a user
22
- * @param id Id of the user to fetch
23
- * @returns GuildUser
24
- */
25
- fetch(id: string, name: string): Promise<GuildUser>;
26
- fetchAll(): Promise<Collection<string, GuildUser>>;
27
- updateUser(id: string, name: string, data: Optional<APIGuildUser>): Promise<GuildUser>;
28
- set(data: APIGuildUser): GuildUser;
29
- setAll(data: APIGuildUser[]): Collection<string, GuildUser>;
30
- resetAll(): Promise<Collection<string, GuildUser>>;
31
- delete(id: string): Promise<Collection<string, GuildUser>>;
32
- deleteAll(): Promise<boolean>;
33
- }
@@ -1,11 +0,0 @@
1
- declare class Guild {
2
- id: string;
3
- tickets: [];
4
- }
5
- export declare const APIEndpoints: {
6
- "guilds/get": {
7
- response: typeof Guild;
8
- };
9
- };
10
- export type APIEndpoint = keyof string;
11
- export {};