@duque.edits/sdk 0.0.3 → 0.0.4

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 (55) hide show
  1. package/package.json +1 -1
  2. package/tsconfig.json +1 -1
  3. package/src/v1/managers/channel/ChannelManager.ts +0 -167
  4. package/src/v1/managers/match/GuildMatchManager.ts +0 -114
  5. /package/{src → v1}/index.ts +0 -0
  6. /package/{src → v1}/managers/bet/GuildBetManager.ts +0 -0
  7. /package/{src → v1}/managers/betuser/GuildBetUserManager.ts +0 -0
  8. /package/{src → v1}/managers/channel/ChannelManager.ts +0 -0
  9. /package/{src → v1}/managers/groupedchannel/GroupedChannelManager.ts +0 -0
  10. /package/{src → v1}/managers/guild/GuildManager.ts +0 -0
  11. /package/{src → v1}/managers/match/GuildMatchManager.ts +0 -0
  12. /package/{src → v1}/managers/mediator/GuildMediatorManager.ts +0 -0
  13. /package/{src → v1}/managers/messages/MessagesManager.ts +0 -0
  14. /package/{src → v1}/managers/permission/GuildPermissionManager.ts +0 -0
  15. /package/{src → v1}/managers/product/GuildProductManager.ts +0 -0
  16. /package/{src → v1}/managers/ticket/GuildTicketManager.ts +0 -0
  17. /package/{src → v1}/managers/user/GuildUserManager.ts +0 -0
  18. /package/{src → v1}/rest/APIEndpoints.ts +0 -0
  19. /package/{src → v1}/rest/REST.ts +0 -0
  20. /package/{src → v1}/rest/Routes.ts +0 -0
  21. /package/{src → v1}/structures/Collection.ts +0 -0
  22. /package/{src → v1}/structures/bet/GuildBet.ts +0 -0
  23. /package/{src → v1}/structures/betuser/GuildBetUser.ts +0 -0
  24. /package/{src → v1}/structures/channel/Channel.ts +0 -0
  25. /package/{src → v1}/structures/groupedchannel/GroupedChannel.ts +0 -0
  26. /package/{src → v1}/structures/guild/Guild.ts +0 -0
  27. /package/{src → v1}/structures/match/GuildMatch.ts +0 -0
  28. /package/{src → v1}/structures/mediator/GuildMediator.ts +0 -0
  29. /package/{src → v1}/structures/product/GuildProduct.ts +0 -0
  30. /package/{src → v1}/structures/shop/GuildShop.ts +0 -0
  31. /package/{src → v1}/structures/ticket/GuildTicket.ts +0 -0
  32. /package/{src → v1}/structures/user/GuildUser.ts +0 -0
  33. /package/{src → v1}/types/api/APIBaseChannel.ts +0 -0
  34. /package/{src → v1}/types/api/APIBetChannel.ts +0 -0
  35. /package/{src → v1}/types/api/APIBetMessage.ts +0 -0
  36. /package/{src → v1}/types/api/APIGuild.ts +0 -0
  37. /package/{src → v1}/types/api/APIGuildBet.ts +0 -0
  38. /package/{src → v1}/types/api/APIGuildBetUser.ts +0 -0
  39. /package/{src → v1}/types/api/APIGuildChannel.ts +0 -0
  40. /package/{src → v1}/types/api/APIGuildEmoji.ts +0 -0
  41. /package/{src → v1}/types/api/APIGuildGroupedChannel.ts +0 -0
  42. /package/{src → v1}/types/api/APIGuildMatch.ts +0 -0
  43. /package/{src → v1}/types/api/APIGuildMediator.ts +0 -0
  44. /package/{src → v1}/types/api/APIGuildMessage.ts +0 -0
  45. /package/{src → v1}/types/api/APIGuildPermissions.ts +0 -0
  46. /package/{src → v1}/types/api/APIGuildRole.ts +0 -0
  47. /package/{src → v1}/types/api/APIGuildShop.ts +0 -0
  48. /package/{src → v1}/types/api/APIGuildTicket.ts +0 -0
  49. /package/{src → v1}/types/api/APIGuildUser.ts +0 -0
  50. /package/{src → v1}/types/api/APIMessage.ts +0 -0
  51. /package/{src → v1}/types/api/APIPlayer.ts +0 -0
  52. /package/{src → v1}/types/api/APIProduct.ts +0 -0
  53. /package/{src → v1}/types/api/index.ts +0 -0
  54. /package/{src → v1}/types/index.ts +0 -0
  55. /package/{src → v1}/utils/Assertion.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duque.edits/sdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "typings": "./dist/index.d.ts",
package/tsconfig.json CHANGED
@@ -11,5 +11,5 @@
11
11
  "removeComments": false,
12
12
  "strictNullChecks": false,
13
13
  },
14
- "include": ["src"]
14
+ "include": ["v1"]
15
15
  }
@@ -1,167 +0,0 @@
1
- import { REST } from "../../../rest/REST";
2
- import { Routes } from "../../../rest/Routes";
3
- import { GuildBet } from "../../../structures/bet/GuildBet";
4
- import { Channel } from "../../../structures/channel/Channel";
5
- import { Collection } from "../../../structures/Collection";
6
- import { Guild } from "../../../structures/guild/Guild";
7
- import { GuildMatch } from "../../../structures/match/GuildMatch";
8
- import { APIBaseChannel, Optional } from "../../../types";
9
- import { Assertion } from "../../../utils/Assertion";
10
-
11
- type Channels = Optional<APIBaseChannel>;
12
-
13
- export class ChannelManager<Structure extends GuildBet | GuildMatch> {
14
- /** A cache of bet channels */
15
- cache: Collection<string, Channel<Structure>>;
16
-
17
- /** The rest client */
18
- rest: REST;
19
-
20
- /** GuildBet user guild */
21
- guild: Guild;
22
-
23
- /** The bet */
24
- structure: Structure;
25
-
26
- /** Base Url */
27
- baseUrl: string;
28
-
29
- /**
30
- * Manage channels of a bet
31
- * @param guild The guild at hand
32
- * @param bet The bet at hand
33
- * @param rest The rest client
34
- */
35
- constructor(guild: Guild, structure: Structure, rest: REST) {
36
- this.structure = structure;
37
- this.rest = rest;
38
- this.guild = guild;
39
- this.cache = new Collection<string, Channel<Structure>>("channels");
40
- this.baseUrl = Routes.guilds[structure.key as "bets"].resource(guild.id, structure._id, "channels");
41
- }
42
- async create(id: string, type: string): Promise<Channel<Structure>> {
43
- Assertion.assertString(id);
44
- Assertion.assertString(type);
45
-
46
- const route = this.baseUrl;
47
- const payload = { id, type };
48
- const response = await this.rest.request<APIBaseChannel, typeof payload>({
49
- method: "POST",
50
- url: route,
51
- payload,
52
- });
53
- const channel = this.set(response);
54
-
55
- this.rest.emit("channelCreate", channel);
56
- return channel;
57
- }
58
- async createMany(...channels: Channels[]) {
59
- Assertion.assertArray(channels);
60
- const route = Routes.fields(this.baseUrl, "bulk");
61
- const payload = { channels };
62
- const response = await this.rest.request<APIBaseChannel[], typeof payload>({
63
- method: "POST",
64
- url: route,
65
- payload,
66
- });
67
-
68
- this.rest.emit("channelBulkCreate", response);
69
- return this.setAll(response);
70
- }
71
- async deleteMany(...channels: Optional<APIBaseChannel>[]) {
72
- Assertion.assertArray(channels);
73
-
74
- const route = Routes.fields(this.baseUrl, "bulk");
75
- const payload = { channels };
76
- const response = await this.rest.request<APIBaseChannel[], typeof payload>({
77
- method: "DELETE",
78
- url: route,
79
- payload,
80
- });
81
- const channel = this.setAll(response);
82
-
83
- this.rest.emit("channelBulkDelete", channel);
84
- return channel;
85
- }
86
- setAll(data: APIBaseChannel[]): Collection<string, Channel<Structure>> {
87
- if (!data) return this.cache;
88
- for (let channelData of data) this.set(channelData);
89
- return this.cache;
90
- }
91
- set(data: APIBaseChannel): Channel<Structure> {
92
- if (!data.type) return;
93
- const channel = new Channel(
94
- {
95
- baseUrl: Routes.guilds[this.structure.key as "bets"].resource(this.guild.id, this.structure._id, "channels"),
96
- data: data,
97
- guild: this.guild,
98
- manager: this,
99
- },
100
- this.rest
101
- );
102
- this.cache.set(data.type, channel);
103
- return channel;
104
- }
105
- async update(type: string, payload: Optional<APIBaseChannel>): Promise<Channel<Structure>> {
106
- Assertion.assertString(type);
107
- Assertion.assertObject(payload);
108
-
109
- const route = Routes.fields(this.baseUrl, type);
110
- const response = await this.rest.request<APIBaseChannel, {}>({
111
- method: "PATCH",
112
- url: route,
113
- payload,
114
- });
115
- const channel = this.set(response);
116
- this.rest.emit("betUpdate", this.structure, this.structure);
117
- return channel;
118
- }
119
- async fetch(type: string): Promise<Channel<Structure>> {
120
- Assertion.assertString(type);
121
-
122
- const route = Routes.fields(this.baseUrl, type);
123
- const response = await this.rest.request<APIBaseChannel, {}>({
124
- method: "GET",
125
- url: route,
126
- });
127
-
128
- const channel = this.set(response);
129
- this.cache.set(channel.type, channel);
130
-
131
- return channel;
132
- }
133
- async fetchAll() {
134
- const response = await this.rest.request<APIBaseChannel[], {}>({
135
- method: "GET",
136
- url: this.baseUrl,
137
- });
138
- if (Array.isArray(response) && response.length === 0) {
139
- this.cache.clear();
140
- return this.cache;
141
- }
142
- for (let channelData of response) this.set(channelData);
143
- return this.cache;
144
- }
145
-
146
- async delete(type: string): Promise<Collection<string, Channel<Structure>>> {
147
- Assertion.assertString(type);
148
-
149
- const route = this.baseUrl;
150
- const response = await this.rest.request<APIBaseChannel[], {}>({
151
- method: "DELETE",
152
- url: Routes.fields(route, type),
153
- });
154
- this.cache.delete(type);
155
- return this.cache;
156
- }
157
-
158
- async deleteAll(): Promise<boolean> {
159
- const route = this.baseUrl;
160
- const value = await this.rest.request<boolean, {}>({
161
- method: "DELETE",
162
- url: route,
163
- });
164
- this.cache.clear();
165
- return value;
166
- }
167
- }
@@ -1,114 +0,0 @@
1
- import { REST } from "../../../rest/REST";
2
- import { Routes } from "../../../rest/Routes";
3
- import { Collection } from "../../../structures/Collection";
4
- import { Guild } from "../../../structures/guild/Guild";
5
- import { GuildMatch } from "../../../structures/match/GuildMatch";
6
- import { APIGuildMatch, Optional } from "../../../types";
7
- import { Assertion } from "../../../utils/Assertion";
8
-
9
- export class GuildMatchManager {
10
- /** A cache of users */
11
- cache: Collection<string, GuildMatch>;
12
-
13
- /** The rest client */
14
- rest: REST;
15
-
16
- /** GuildMatch match guild */
17
- guild: Guild;
18
- /**
19
- * Manage users with the given client
20
- * @param users An array of users
21
- * @param rest The rest client
22
- */
23
- constructor(guild: Guild, rest: REST) {
24
- this.guild = guild;
25
-
26
- this.cache = new Collection<string, GuildMatch>("matches");
27
- this.rest = rest;
28
- }
29
-
30
- /**
31
- * Fetch a match
32
- * @param id Id of the match to fetch
33
- * @returns APIBetUser
34
- */
35
- async fetch(id: string) {
36
- const route = Routes.guilds.matches.get(this.guild.id, id);
37
- const response = await this.rest.request<APIGuildMatch, {}>({
38
- method: "get",
39
- url: route,
40
- });
41
- const match = new GuildMatch(response, this.guild, this, this.rest);
42
- this.cache.set(match._id, match);
43
- this.rest.matches.set(match._id, match);
44
-
45
- return match;
46
- }
47
-
48
- async fetchAll() {
49
- const route = Routes.guilds.matches.getAll(this.guild.id);
50
- const response = await this.rest.request<APIGuildMatch[], {}>({
51
- method: "get",
52
- url: route,
53
- });
54
- if (Array.isArray(response) && response.length === 0) {
55
- this.cache.clear();
56
- return this.cache;
57
- }
58
- this.setAll(response);
59
- return this.cache;
60
- }
61
- set(data: APIGuildMatch): GuildMatch {
62
- if (!data?._id) return;
63
- const match = new GuildMatch(data, this?.guild, this, this.rest);
64
-
65
- this.cache.set(data?._id, match);
66
- this.rest.matches.set(data?._id, match);
67
- return match;
68
- }
69
- setAll(data: APIGuildMatch[]) {
70
- if (!data) return this.cache;
71
- for (let match of data || []) this.set(match);
72
- return this.cache;
73
- }
74
-
75
- async create(payload: Optional<APIGuildMatch>): Promise<GuildMatch> {
76
- Assertion.assertObject(payload);
77
-
78
- const route = Routes.guilds.matches.create(this.guild.id);
79
- const response = await this.rest.request<APIGuildMatch, typeof payload>({
80
- method: "POST",
81
- url: route,
82
- payload,
83
- });
84
- const match = this.set(response);
85
- return match;
86
- }
87
-
88
- async delete(id: string) {
89
- Assertion.assertString(id);
90
-
91
- const route = Routes.guilds.matches.delete(id, this.guild.id);
92
- const match = this.cache.get(id);
93
- this.rest.emit("matchDelete", match);
94
-
95
- await this.rest.request<boolean, {}>({
96
- method: "DELETE",
97
- url: route,
98
- });
99
-
100
- this.cache.delete(id);
101
- return this.cache;
102
- }
103
- async deleteAll() {
104
- const route = Routes.guilds.matches.deleteAll(this.guild.id);
105
- this.rest.emit("matchesDelete", this.cache);
106
-
107
- const value = await this.rest.request<boolean, {}>({
108
- method: "DELETE",
109
- url: route,
110
- });
111
- this.cache.clear();
112
- return value;
113
- }
114
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes