@duque.edits/sdk 0.1.2 → 0.1.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.
@@ -19,7 +19,7 @@ export declare class MessagesManager {
19
19
  * @param rest The rest client
20
20
  */
21
21
  constructor(guild: Guild, key: string, rest: REST);
22
- create(payload: Optional<APIMessage>): Promise<APIMessage>;
22
+ create(payload: Optional<APIMessage>): Promise<boolean>;
23
23
  /**
24
24
  * Fetch a message
25
25
  * @param id Id of the message to fetch
@@ -27,6 +27,6 @@ export declare class MessagesManager {
27
27
  */
28
28
  fetch(type: string): Promise<APIMessage>;
29
29
  fetchAll(): Promise<Collection<string, APIMessage>>;
30
- set(data: APIMessage): APIMessage;
30
+ set(data: APIMessage | APIMessage[]): Collection<string, APIMessage>;
31
31
  setAll(data: APIMessage[]): Collection<string, APIMessage>;
32
32
  }
@@ -34,8 +34,8 @@ class MessagesManager {
34
34
  url: route,
35
35
  payload,
36
36
  });
37
- const message = this.set(response);
38
- return message;
37
+ this.set(response);
38
+ return true;
39
39
  }
40
40
  /**
41
41
  * Fetch a message
@@ -48,9 +48,9 @@ class MessagesManager {
48
48
  method: "get",
49
49
  url: route,
50
50
  });
51
- const channel = this.set(response);
52
- this.cache.set(channel.type, channel);
53
- return channel;
51
+ const message = this.set(response);
52
+ this.set(response);
53
+ return response;
54
54
  }
55
55
  async fetchAll() {
56
56
  const route = this.baseUrl;
@@ -61,15 +61,22 @@ class MessagesManager {
61
61
  for (let data of response) {
62
62
  if (!data.type)
63
63
  continue;
64
- this.cache.set(data?.type, data);
64
+ this.cache.set(`${data?.userId}-${Date.now() * Math.random() + 100}`, data);
65
65
  }
66
66
  return this.cache;
67
67
  }
68
68
  set(data) {
69
- if (!data?.type)
70
- return;
71
- this.cache.set(data?.type, data);
72
- return 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;
73
80
  }
74
81
  setAll(data) {
75
82
  if (!data)
@@ -77,7 +77,7 @@ export declare class GuildBet {
77
77
  setLoser(userId: string): Promise<string>;
78
78
  delete(): Promise<boolean>;
79
79
  addChannel(id: string, type: string): Promise<import("../..").Channel<GuildBet>>;
80
- addMessage(id: string, type: string, content?: string): Promise<import("../..").APIMessage>;
80
+ addMessage(id: string, type: string, content?: string): Promise<boolean>;
81
81
  setChannels(channels: APIBetChannel[]): Promise<ChannelManager<GuildBet>>;
82
82
  addPlayer(player: Optional<APIPlayer>): Promise<APIPlayer[]>;
83
83
  removePlayer(player: Optional<APIPlayer>): Promise<APIPlayer[]>;
@@ -66,7 +66,7 @@ export declare class GuildMatch {
66
66
  * @returns New Instance of the match
67
67
  */
68
68
  fetch(): Promise<GuildMatch>;
69
- addMessage(id: string, type: string, content?: string): Promise<import("../..").APIMessage>;
69
+ addMessage(id: string, type: string, content?: string): Promise<boolean>;
70
70
  addConfirmed(type: string, id: string): Promise<Confirm>;
71
71
  setConfirmed(set: Confirm[]): Promise<GuildMatch>;
72
72
  setStatus(status: BaseMatchStatus): Promise<GuildMatch>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duque.edits/sdk",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "typings": "./dist/index.d.ts",