seyfert 1.2.2 → 1.3.0
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.
- package/LICENSE +190 -190
- package/README.md +46 -46
- package/lib/api/Router.d.ts +9 -0
- package/lib/api/Router.js +16 -8
- package/lib/api/Routes/cdn.d.ts +26 -15
- package/lib/api/Routes/channels.d.ts +15 -1
- package/lib/api/api.d.ts +2 -3
- package/lib/api/api.js +4 -9
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +0 -1
- package/lib/api/utils/utils.d.ts +1 -1
- package/lib/api/utils/utils.js +2 -2
- package/lib/builders/Modal.d.ts +4 -1
- package/lib/builders/Modal.js +4 -1
- package/lib/builders/Poll.d.ts +16 -0
- package/lib/builders/Poll.js +48 -0
- package/lib/builders/index.d.ts +1 -0
- package/lib/builders/index.js +1 -0
- package/lib/cache/adapters/default.d.ts +1 -0
- package/lib/cache/adapters/default.js +4 -0
- package/lib/cache/adapters/index.d.ts +1 -0
- package/lib/cache/adapters/index.js +1 -0
- package/lib/cache/adapters/limited.d.ts +50 -0
- package/lib/cache/adapters/limited.js +188 -0
- package/lib/cache/adapters/redis.d.ts +2 -0
- package/lib/cache/adapters/redis.js +17 -0
- package/lib/cache/adapters/types.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.js +6 -9
- package/lib/cache/index.d.ts +8 -3
- package/lib/cache/index.js +41 -7
- package/lib/cache/resources/channels.d.ts +2 -1
- package/lib/cache/resources/default/base.d.ts +3 -3
- package/lib/cache/resources/default/base.js +8 -3
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +7 -3
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +7 -3
- package/lib/cache/resources/emojis.d.ts +2 -0
- package/lib/cache/resources/emojis.js +4 -0
- package/lib/cache/resources/guilds.d.ts +2 -0
- package/lib/cache/resources/guilds.js +4 -0
- package/lib/cache/resources/members.d.ts +2 -0
- package/lib/cache/resources/members.js +5 -1
- package/lib/cache/resources/messages.d.ts +15 -0
- package/lib/cache/resources/messages.js +53 -0
- package/lib/cache/resources/overwrites.d.ts +4 -0
- package/lib/cache/resources/overwrites.js +4 -0
- package/lib/cache/resources/presence.d.ts +1 -0
- package/lib/cache/resources/presence.js +4 -0
- package/lib/cache/resources/roles.d.ts +2 -0
- package/lib/cache/resources/roles.js +4 -0
- package/lib/cache/resources/stage-instances.d.ts +1 -0
- package/lib/cache/resources/stage-instances.js +5 -1
- package/lib/cache/resources/stickers.d.ts +2 -0
- package/lib/cache/resources/stickers.js +4 -0
- package/lib/cache/resources/threads.d.ts +2 -0
- package/lib/cache/resources/threads.js +4 -0
- package/lib/cache/resources/users.d.ts +2 -0
- package/lib/cache/resources/users.js +4 -0
- package/lib/cache/resources/voice-states.d.ts +2 -1
- package/lib/cache/resources/voice-states.js +8 -4
- package/lib/client/base.d.ts +26 -14
- package/lib/client/base.js +41 -13
- package/lib/client/client.d.ts +6 -5
- package/lib/client/client.js +13 -1
- package/lib/client/oninteractioncreate.js +2 -2
- package/lib/client/onmessagecreate.js +17 -14
- package/lib/client/workerclient.d.ts +3 -3
- package/lib/client/workerclient.js +23 -14
- package/lib/collection.d.ts +8 -3
- package/lib/collection.js +22 -4
- package/lib/commands/applications/chat.d.ts +17 -20
- package/lib/commands/applications/chat.js +6 -21
- package/lib/commands/applications/chatcontext.d.ts +1 -1
- package/lib/commands/applications/menucontext.d.ts +1 -1
- package/lib/commands/applications/shared.d.ts +4 -0
- package/lib/commands/applications/shared.js +6 -0
- package/lib/commands/decorators.d.ts +11 -1
- package/lib/commands/decorators.js +24 -0
- package/lib/commands/handler.d.ts +11 -7
- package/lib/commands/handler.js +43 -14
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +2 -0
- package/lib/common/it/utils.d.ts +0 -1
- package/lib/common/it/utils.js +0 -1
- package/lib/common/shorters/channels.d.ts +8 -3
- package/lib/common/shorters/channels.js +27 -12
- package/lib/common/shorters/guilds.d.ts +6 -5
- package/lib/common/shorters/guilds.js +22 -4
- package/lib/common/shorters/interaction.d.ts +13 -0
- package/lib/common/shorters/interaction.js +61 -0
- package/lib/common/shorters/messages.d.ts +6 -3
- package/lib/common/shorters/messages.js +33 -15
- package/lib/common/shorters/roles.d.ts +3 -3
- package/lib/common/shorters/roles.js +12 -17
- package/lib/common/shorters/templates.d.ts +7 -6
- package/lib/common/shorters/templates.js +28 -6
- package/lib/common/shorters/threads.d.ts +39 -0
- package/lib/common/shorters/threads.js +76 -0
- package/lib/common/shorters/webhook.d.ts +1 -1
- package/lib/common/shorters/webhook.js +8 -2
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/write.d.ts +8 -5
- package/lib/components/ButtonComponent.js +1 -1
- package/lib/components/componentcontext.d.ts +1 -1
- package/lib/components/handler.d.ts +6 -17
- package/lib/components/handler.js +7 -2
- package/lib/events/handler.d.ts +8 -14
- package/lib/events/handler.js +9 -4
- package/lib/events/hooks/guild.d.ts +1 -1
- package/lib/events/hooks/guild.js +2 -2
- package/lib/events/hooks/message.d.ts +26 -8
- package/lib/events/hooks/message.js +18 -7
- package/lib/langs/handler.d.ts +4 -8
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +6 -6
- package/lib/structures/Guild.d.ts +15 -13
- package/lib/structures/GuildEmoji.d.ts +2 -2
- package/lib/structures/GuildEmoji.js +1 -1
- package/lib/structures/GuildMember.js +1 -1
- package/lib/structures/GuildRole.d.ts +5 -5
- package/lib/structures/GuildTemplate.d.ts +10 -10
- package/lib/structures/Interaction.d.ts +3 -3
- package/lib/structures/Interaction.js +27 -48
- package/lib/structures/Message.d.ts +5 -3
- package/lib/structures/Message.js +5 -0
- package/lib/structures/Poll.d.ts +15 -0
- package/lib/structures/Poll.js +26 -0
- package/lib/structures/User.d.ts +2 -3
- package/lib/structures/User.js +9 -4
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +11 -3
- package/lib/structures/channels.js +16 -8
- package/lib/structures/extra/BaseGuild.js +3 -3
- package/lib/structures/extra/Permissions.d.ts +1 -0
- package/lib/structures/index.d.ts +1 -0
- package/lib/structures/index.js +1 -0
- package/lib/websocket/SharedTypes.d.ts +7 -2
- package/lib/websocket/discord/worker.d.ts +1 -1
- package/lib/websocket/discord/workermanager.js +3 -9
- package/lib/websocket/structures/timeout.js +9 -12
- package/package.json +8 -8
- package/lib/api/CDN.d.ts +0 -212
- package/lib/api/CDN.js +0 -228
- package/lib/client/http/adapters/bun.d.ts +0 -14
- package/lib/client/http/adapters/bun.js +0 -117
- package/lib/client/http/adapters/index.d.ts +0 -15
- package/lib/client/http/adapters/index.js +0 -27
- package/lib/client/http/adapters/uws.d.ts +0 -17
- package/lib/client/http/adapters/uws.js +0 -142
- package/lib/client/http/httpclient.d.ts +0 -13
- package/lib/client/http/httpclient.js +0 -48
- package/lib/common/shorters/overwrites.d.ts +0 -29
- package/lib/common/shorters/overwrites.js +0 -63
- package/lib/components/listener.d.ts +0 -11
- package/lib/components/listener.js +0 -17
- package/lib/structures/extra/BaseComponent.d.ts +0 -9
- package/lib/structures/extra/BaseComponent.js +0 -12
- package/lib/structures/extra/BaseSelectMenuComponent.d.ts +0 -9
- package/lib/structures/extra/BaseSelectMenuComponent.js +0 -13
package/lib/cache/index.js
CHANGED
|
@@ -28,6 +28,7 @@ const threads_1 = require("./resources/threads");
|
|
|
28
28
|
const voice_states_1 = require("./resources/voice-states");
|
|
29
29
|
const v10_1 = require("discord-api-types/v10");
|
|
30
30
|
const overwrites_1 = require("./resources/overwrites");
|
|
31
|
+
const messages_1 = require("./resources/messages");
|
|
31
32
|
__exportStar(require("./adapters/index"), exports);
|
|
32
33
|
class Cache {
|
|
33
34
|
intents;
|
|
@@ -48,6 +49,7 @@ class Cache {
|
|
|
48
49
|
stickers;
|
|
49
50
|
presences;
|
|
50
51
|
stageInstances;
|
|
52
|
+
messages;
|
|
51
53
|
constructor(intents, adapter, disabledCache = [], client) {
|
|
52
54
|
this.intents = intents;
|
|
53
55
|
this.adapter = adapter;
|
|
@@ -91,6 +93,9 @@ class Cache {
|
|
|
91
93
|
if (!this.disabledCache.includes('stageInstances')) {
|
|
92
94
|
this.stageInstances = new stage_instances_1.StageInstances(this, client);
|
|
93
95
|
}
|
|
96
|
+
if (!this.disabledCache.includes('messages')) {
|
|
97
|
+
this.messages = new messages_1.Messages(this, client);
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
100
|
/** @internal */
|
|
96
101
|
__setClient(client) {
|
|
@@ -106,6 +111,10 @@ class Cache {
|
|
|
106
111
|
this.presences?.__setClient(client);
|
|
107
112
|
this.threads?.__setClient(client);
|
|
108
113
|
this.stageInstances?.__setClient(client);
|
|
114
|
+
this.messages?.__setClient(client);
|
|
115
|
+
}
|
|
116
|
+
flush() {
|
|
117
|
+
return this.adapter.flush();
|
|
109
118
|
}
|
|
110
119
|
// internal use ./structures
|
|
111
120
|
hasIntent(intent) {
|
|
@@ -158,6 +167,7 @@ class Cache {
|
|
|
158
167
|
case 'users':
|
|
159
168
|
case 'guilds':
|
|
160
169
|
case 'overwrites':
|
|
170
|
+
case 'messages':
|
|
161
171
|
{
|
|
162
172
|
if (!allData[type]) {
|
|
163
173
|
allData[type] = [];
|
|
@@ -197,7 +207,10 @@ class Cache {
|
|
|
197
207
|
case 'stageInstances':
|
|
198
208
|
case 'emojis':
|
|
199
209
|
case 'overwrites':
|
|
210
|
+
case 'messages':
|
|
200
211
|
{
|
|
212
|
+
if (!this[type]?.filter(data, id, guildId))
|
|
213
|
+
continue;
|
|
201
214
|
const hashId = this[type]?.hashId(guildId);
|
|
202
215
|
if (!hashId) {
|
|
203
216
|
continue;
|
|
@@ -215,6 +228,8 @@ class Cache {
|
|
|
215
228
|
case 'voiceStates':
|
|
216
229
|
case 'members':
|
|
217
230
|
{
|
|
231
|
+
if (!this[type]?.filter(data, id, guildId))
|
|
232
|
+
continue;
|
|
218
233
|
const hashId = this[type]?.hashId(guildId);
|
|
219
234
|
if (!hashId) {
|
|
220
235
|
continue;
|
|
@@ -230,6 +245,8 @@ class Cache {
|
|
|
230
245
|
case 'users':
|
|
231
246
|
case 'guilds':
|
|
232
247
|
{
|
|
248
|
+
if (!this[type]?.filter(data, id))
|
|
249
|
+
continue;
|
|
233
250
|
const hashId = this[type]?.namespace;
|
|
234
251
|
if (!hashId) {
|
|
235
252
|
continue;
|
|
@@ -245,8 +262,8 @@ class Cache {
|
|
|
245
262
|
throw new Error(`Invalid type ${type}`);
|
|
246
263
|
}
|
|
247
264
|
}
|
|
248
|
-
await this.adapter.patch(false, allData);
|
|
249
265
|
await this.adapter.bulkAddToRelationShip(relationshipsData);
|
|
266
|
+
await this.adapter.patch(false, allData);
|
|
250
267
|
}
|
|
251
268
|
async bulkSet(keys) {
|
|
252
269
|
const allData = [];
|
|
@@ -261,7 +278,10 @@ class Cache {
|
|
|
261
278
|
case 'stageInstances':
|
|
262
279
|
case 'emojis':
|
|
263
280
|
case 'overwrites':
|
|
281
|
+
case 'messages':
|
|
264
282
|
{
|
|
283
|
+
if (!this[type]?.filter(data, id, guildId))
|
|
284
|
+
continue;
|
|
265
285
|
const hashId = this[type]?.hashId(guildId);
|
|
266
286
|
if (!hashId) {
|
|
267
287
|
continue;
|
|
@@ -279,6 +299,8 @@ class Cache {
|
|
|
279
299
|
case 'voiceStates':
|
|
280
300
|
case 'members':
|
|
281
301
|
{
|
|
302
|
+
if (!this[type]?.filter(data, id, guildId))
|
|
303
|
+
continue;
|
|
282
304
|
const hashId = this[type]?.hashId(guildId);
|
|
283
305
|
if (!hashId) {
|
|
284
306
|
continue;
|
|
@@ -294,6 +316,8 @@ class Cache {
|
|
|
294
316
|
case 'users':
|
|
295
317
|
case 'guilds':
|
|
296
318
|
{
|
|
319
|
+
if (!this[type]?.filter(data, id))
|
|
320
|
+
continue;
|
|
297
321
|
const hashId = this[type]?.namespace;
|
|
298
322
|
if (!hashId) {
|
|
299
323
|
continue;
|
|
@@ -309,16 +333,13 @@ class Cache {
|
|
|
309
333
|
throw new Error(`Invalid type ${type}`);
|
|
310
334
|
}
|
|
311
335
|
}
|
|
312
|
-
await this.adapter.set(allData);
|
|
313
336
|
await this.adapter.bulkAddToRelationShip(relationshipsData);
|
|
337
|
+
await this.adapter.set(allData);
|
|
314
338
|
}
|
|
315
339
|
async onPacket(event) {
|
|
316
340
|
switch (event.t) {
|
|
317
341
|
case 'READY':
|
|
318
|
-
|
|
319
|
-
const data = event.d;
|
|
320
|
-
await this.users?.set(data.user.id, data.user);
|
|
321
|
-
}
|
|
342
|
+
await this.users?.set(event.d.user.id, event.d.user);
|
|
322
343
|
break;
|
|
323
344
|
case 'GUILD_CREATE':
|
|
324
345
|
case 'GUILD_UPDATE':
|
|
@@ -377,7 +398,8 @@ class Cache {
|
|
|
377
398
|
break;
|
|
378
399
|
case 'THREAD_CREATE':
|
|
379
400
|
case 'THREAD_UPDATE':
|
|
380
|
-
|
|
401
|
+
if (event.d.guild_id)
|
|
402
|
+
await this.threads?.set(event.d.id, event.d.guild_id, event.d);
|
|
381
403
|
break;
|
|
382
404
|
case 'THREAD_DELETE':
|
|
383
405
|
await this.threads?.remove(event.d.id, event.d.guild_id);
|
|
@@ -403,6 +425,18 @@ class Cache {
|
|
|
403
425
|
case 'STAGE_INSTANCE_DELETE':
|
|
404
426
|
await this.stageInstances?.remove(event.d.id, event.d.guild_id);
|
|
405
427
|
break;
|
|
428
|
+
case 'MESSAGE_CREATE':
|
|
429
|
+
await this.messages?.set(event.d.id, event.d.channel_id, event.d);
|
|
430
|
+
break;
|
|
431
|
+
case 'MESSAGE_UPDATE':
|
|
432
|
+
await this.messages?.patch(event.d.id, event.d.channel_id, event.d);
|
|
433
|
+
break;
|
|
434
|
+
case 'MESSAGE_DELETE':
|
|
435
|
+
await this.messages?.remove(event.d.id, event.d.channel_id);
|
|
436
|
+
break;
|
|
437
|
+
case 'MESSAGE_DELETE_BULK':
|
|
438
|
+
await this.messages?.remove(event.d.ids, event.d.channel_id);
|
|
439
|
+
break;
|
|
406
440
|
}
|
|
407
441
|
}
|
|
408
442
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { APIChannel } from 'discord-api-types/v10';
|
|
1
2
|
import type { AllChannels } from '../../structures';
|
|
2
3
|
import channelFrom from '../../structures/channels';
|
|
3
4
|
import type { ReturnCache } from '../index';
|
|
4
5
|
import { GuildRelatedResource } from './default/guild-related';
|
|
5
6
|
export declare class Channels extends GuildRelatedResource {
|
|
6
7
|
namespace: string;
|
|
7
|
-
parse(data:
|
|
8
|
+
parse(data: APIChannel, id: string, guild_id: string): any;
|
|
8
9
|
get(id: string): ReturnCache<AllChannels | undefined>;
|
|
9
10
|
bulk(ids: string[]): ReturnCache<ReturnType<typeof channelFrom>[]>;
|
|
10
11
|
values(guild: string): ReturnCache<ReturnType<typeof channelFrom>[]>;
|
|
@@ -7,14 +7,14 @@ export declare class BaseResource<T = any> {
|
|
|
7
7
|
client: BaseClient;
|
|
8
8
|
namespace: string;
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
|
-
|
|
10
|
+
filter(data: any, id: string): boolean;
|
|
11
11
|
get adapter(): import("../../index").Adapter;
|
|
12
12
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("../../../common").Awaitable<void>;
|
|
13
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: any):
|
|
13
|
+
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: any): import("../../../common").Awaitable<void>;
|
|
14
14
|
get(id: string): ReturnCache<T | undefined>;
|
|
15
15
|
bulk(ids: string[]): ReturnCache<T[]>;
|
|
16
16
|
set(id: string, data: any): import("../../../common").Awaitable<void>;
|
|
17
|
-
patch
|
|
17
|
+
patch(id: string, data: any): import("../../../common").Awaitable<void>;
|
|
18
18
|
remove(id: string): import("../../../common").Awaitable<void>;
|
|
19
19
|
keys(): ReturnCache<string[]>;
|
|
20
20
|
values(): ReturnCache<T[]>;
|
|
@@ -16,8 +16,9 @@ class BaseResource {
|
|
|
16
16
|
__setClient(client) {
|
|
17
17
|
this.client = client;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
//@ts-expect-error
|
|
20
|
+
filter(data, id) {
|
|
21
|
+
return true;
|
|
21
22
|
}
|
|
22
23
|
get adapter() {
|
|
23
24
|
return this.cache.adapter;
|
|
@@ -30,7 +31,7 @@ class BaseResource {
|
|
|
30
31
|
}
|
|
31
32
|
setIfNI(intent, id, data) {
|
|
32
33
|
if (!this.cache.hasIntent(intent)) {
|
|
33
|
-
return
|
|
34
|
+
return this.set(id, data);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
get(id) {
|
|
@@ -40,9 +41,13 @@ class BaseResource {
|
|
|
40
41
|
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashId(id)))).then(x => x.filter(y => y));
|
|
41
42
|
}
|
|
42
43
|
set(id, data) {
|
|
44
|
+
if (!this.filter(data, id))
|
|
45
|
+
return;
|
|
43
46
|
return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.set(this.hashId(id), data));
|
|
44
47
|
}
|
|
45
48
|
patch(id, data) {
|
|
49
|
+
if (!this.filter(data, id))
|
|
50
|
+
return;
|
|
46
51
|
return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.patch(false, this.hashId(id), data));
|
|
47
52
|
}
|
|
48
53
|
remove(id) {
|
|
@@ -7,10 +7,11 @@ export declare class GuildBasedResource<T = any> {
|
|
|
7
7
|
client: BaseClient;
|
|
8
8
|
namespace: string;
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
|
+
filter(data: any, id: string, guild_id: string): boolean;
|
|
10
11
|
parse(data: any, id: string, guild_id: string): any;
|
|
11
12
|
get adapter(): import("../../index").Adapter;
|
|
12
13
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
|
|
13
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any):
|
|
14
|
+
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): void;
|
|
14
15
|
get(id: string, guild: string): ReturnCache<(T & {
|
|
15
16
|
guild_id: string;
|
|
16
17
|
}) | undefined>;
|
|
@@ -16,6 +16,10 @@ class GuildBasedResource {
|
|
|
16
16
|
__setClient(client) {
|
|
17
17
|
this.client = client;
|
|
18
18
|
}
|
|
19
|
+
//@ts-expect-error
|
|
20
|
+
filter(data, id, guild_id) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
19
23
|
parse(data, id, guild_id) {
|
|
20
24
|
if (!data.id)
|
|
21
25
|
data.id = id;
|
|
@@ -33,7 +37,7 @@ class GuildBasedResource {
|
|
|
33
37
|
}
|
|
34
38
|
setIfNI(intent, id, guildId, data) {
|
|
35
39
|
if (!this.cache.hasIntent(intent)) {
|
|
36
|
-
return
|
|
40
|
+
return this.set(id, guildId, data);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
get(id, guild) {
|
|
@@ -43,13 +47,13 @@ class GuildBasedResource {
|
|
|
43
47
|
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashGuildId(guild, id)))).then(x => x.filter(y => y));
|
|
44
48
|
}
|
|
45
49
|
set(__keys, guild, data) {
|
|
46
|
-
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
50
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
47
51
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
48
52
|
return [this.hashGuildId(guild, key), this.parse(value, key, guild)];
|
|
49
53
|
})));
|
|
50
54
|
}
|
|
51
55
|
patch(__keys, guild, data) {
|
|
52
|
-
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
56
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
53
57
|
return (0, common_1.fakePromise)(this.adapter.get(keys.map(([key]) => this.hashGuildId(guild, key)))).then(oldDatas => (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
54
58
|
const oldData = oldDatas.find(x => x.id === key) ?? {};
|
|
55
59
|
return [this.hashGuildId(guild, key), this.parse({ ...oldData, ...value }, key, guild)];
|
|
@@ -7,10 +7,11 @@ export declare class GuildRelatedResource<T = any> {
|
|
|
7
7
|
client: BaseClient;
|
|
8
8
|
namespace: string;
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
|
+
filter(data: any, id: string, guild_id?: string): boolean;
|
|
10
11
|
parse(data: any, id: string, guild_id: string): any;
|
|
11
12
|
get adapter(): import("../../index").Adapter;
|
|
12
13
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
|
|
13
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any):
|
|
14
|
+
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): void;
|
|
14
15
|
get(id: string): ReturnCache<(T & {
|
|
15
16
|
guild_id: string;
|
|
16
17
|
}) | undefined>;
|
|
@@ -16,6 +16,10 @@ class GuildRelatedResource {
|
|
|
16
16
|
__setClient(client) {
|
|
17
17
|
this.client = client;
|
|
18
18
|
}
|
|
19
|
+
//@ts-expect-error
|
|
20
|
+
filter(data, id, guild_id) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
19
23
|
parse(data, id, guild_id) {
|
|
20
24
|
if (!data.id)
|
|
21
25
|
data.id = id;
|
|
@@ -32,7 +36,7 @@ class GuildRelatedResource {
|
|
|
32
36
|
}
|
|
33
37
|
setIfNI(intent, id, guildId, data) {
|
|
34
38
|
if (!this.cache.hasIntent(intent)) {
|
|
35
|
-
return
|
|
39
|
+
return this.set(id, guildId, data);
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
get(id) {
|
|
@@ -42,13 +46,13 @@ class GuildRelatedResource {
|
|
|
42
46
|
return (0, common_1.fakePromise)(this.adapter.get(ids.map(x => this.hashId(x)))).then(x => x.filter(y => y));
|
|
43
47
|
}
|
|
44
48
|
set(__keys, guild, data) {
|
|
45
|
-
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
49
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
46
50
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
47
51
|
return [this.hashId(key), this.parse(value, key, guild)];
|
|
48
52
|
})));
|
|
49
53
|
}
|
|
50
54
|
patch(__keys, guild, data) {
|
|
51
|
-
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
55
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
52
56
|
if (guild) {
|
|
53
57
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.patch(false, keys.map(([key, value]) => {
|
|
54
58
|
return [this.hashId(key), this.parse(value, key, guild)];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIEmoji } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { GuildEmoji } from '../../structures';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Emojis extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIEmoji, id: string, guild_id?: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<GuildEmoji | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<GuildEmoji[]>;
|
|
8
10
|
values(guild: string): ReturnCache<GuildEmoji[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Emojis extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'emoji';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawEmoji => rawEmoji ? new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id) : undefined);
|
|
11
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIGuild } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '..';
|
|
2
3
|
import { Guild } from '../../structures';
|
|
3
4
|
import { BaseResource } from './default/base';
|
|
4
5
|
export declare class Guilds extends BaseResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIGuild, id: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<Guild<'cached'> | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<Guild<'cached'>[]>;
|
|
8
10
|
values(): ReturnCache<Guild<'cached'>[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const base_1 = require("./default/base");
|
|
7
7
|
class Guilds extends base_1.BaseResource {
|
|
8
8
|
namespace = 'guild';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(guild => (guild ? new structures_1.Guild(this.client, guild) : undefined));
|
|
11
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIGuildMember } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { GuildMember } from '../../structures';
|
|
3
4
|
import { GuildBasedResource } from './default/guild-based';
|
|
4
5
|
export declare class Members extends GuildBasedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIGuildMember, id: string, guild_id: string): boolean;
|
|
6
8
|
parse(data: any, key: string, guild_id: string): any;
|
|
7
9
|
get(id: string, guild: string): ReturnCache<GuildMember | undefined>;
|
|
8
10
|
bulk(ids: string[], guild: string): ReturnCache<GuildMember[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_based_1 = require("./default/guild-based");
|
|
7
7
|
class Members extends guild_based_1.GuildBasedResource {
|
|
8
8
|
namespace = 'member';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
parse(data, key, guild_id) {
|
|
10
14
|
const { user, ...rest } = super.parse(data, data.user?.id ?? key, guild_id);
|
|
11
15
|
return rest;
|
|
@@ -25,7 +29,7 @@ class Members extends guild_based_1.GuildBasedResource {
|
|
|
25
29
|
return (0, common_1.fakePromise)(super.values(guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.values() ?? []).then(users => members
|
|
26
30
|
.map(rawMember => {
|
|
27
31
|
const user = users.find(x => x.id === rawMember.id);
|
|
28
|
-
return user ? new structures_1.GuildMember(this.client, rawMember, user,
|
|
32
|
+
return user ? new structures_1.GuildMember(this.client, rawMember, user, rawMember.guild_id) : undefined;
|
|
29
33
|
})
|
|
30
34
|
.filter(Boolean)));
|
|
31
35
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { APIMessage } from 'discord-api-types/v10';
|
|
2
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
3
|
+
import type { MessageData, ReturnCache } from '../..';
|
|
4
|
+
import { Message } from '../../structures';
|
|
5
|
+
export declare class Messages extends GuildRelatedResource {
|
|
6
|
+
namespace: string;
|
|
7
|
+
filter(data: MessageData, id: string, channel_id?: string): boolean;
|
|
8
|
+
parse(data: any, _key: string, _channel_id: string): any;
|
|
9
|
+
get(id: string): ReturnCache<Message | undefined>;
|
|
10
|
+
bulk(ids: string[]): ReturnCache<Message[]>;
|
|
11
|
+
values(guild: string): ReturnCache<Message[]>;
|
|
12
|
+
}
|
|
13
|
+
export type APIMessageResource = Omit<APIMessage, 'author'> & {
|
|
14
|
+
user_id?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Messages = void 0;
|
|
4
|
+
const guild_related_1 = require("./default/guild-related");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const structures_1 = require("../../structures");
|
|
7
|
+
class Messages extends guild_related_1.GuildRelatedResource {
|
|
8
|
+
namespace = 'message';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, channel_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
parse(data, _key, _channel_id) {
|
|
14
|
+
const { author, member, ...rest } = data;
|
|
15
|
+
if (author?.id)
|
|
16
|
+
rest.user_id = author.id;
|
|
17
|
+
return rest;
|
|
18
|
+
}
|
|
19
|
+
get(id) {
|
|
20
|
+
return (0, common_1.fakePromise)(super.get(id)).then(rawMessage => {
|
|
21
|
+
const user = this.cache.users && rawMessage?.user_id
|
|
22
|
+
? this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id))
|
|
23
|
+
: undefined;
|
|
24
|
+
return user ? new structures_1.Message(this.client, { ...rawMessage, author: user }) : undefined;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
bulk(ids) {
|
|
28
|
+
return (0, common_1.fakePromise)(super.bulk(ids)).then(messages => messages
|
|
29
|
+
.map(rawMessage => {
|
|
30
|
+
const user = this.cache.users && rawMessage.user_id
|
|
31
|
+
? this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id))
|
|
32
|
+
: undefined;
|
|
33
|
+
return user ? new structures_1.Message(this.client, { ...rawMessage, author: user }) : undefined;
|
|
34
|
+
})
|
|
35
|
+
.filter(Boolean));
|
|
36
|
+
}
|
|
37
|
+
values(guild) {
|
|
38
|
+
return (0, common_1.fakePromise)(super.values(guild)).then(messages => {
|
|
39
|
+
const hashes = this.cache.users
|
|
40
|
+
? messages.map(x => (x.user_id ? this.cache.users.hashId(x.user_id) : undefined))
|
|
41
|
+
: [];
|
|
42
|
+
return (0, common_1.fakePromise)(this.cache.adapter.get(hashes.filter(Boolean))).then(users => {
|
|
43
|
+
return messages
|
|
44
|
+
.map(message => {
|
|
45
|
+
const user = users.find(user => user.id === message.user_id);
|
|
46
|
+
return user ? new structures_1.Message(this.client, { ...message, author: user }) : undefined;
|
|
47
|
+
})
|
|
48
|
+
.filter(Boolean);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.Messages = Messages;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
+
import type { APIOverwrite } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { PermissionsBitField } from '../../structures/extra/Permissions';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Overwrites extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIOverwrite[], id: string, guild_id?: string): boolean;
|
|
6
8
|
parse(data: any[], _id: string, guild_id: string): any[];
|
|
7
9
|
get(id: string): ReturnCache<{
|
|
8
10
|
type: number;
|
|
9
11
|
id: string;
|
|
10
12
|
deny: PermissionsBitField;
|
|
11
13
|
allow: PermissionsBitField;
|
|
14
|
+
guildId: string;
|
|
12
15
|
}[] | undefined>;
|
|
13
16
|
values(guild: string): ReturnCache<{
|
|
14
17
|
type: number;
|
|
15
18
|
id: string;
|
|
16
19
|
deny: PermissionsBitField;
|
|
17
20
|
allow: PermissionsBitField;
|
|
21
|
+
guildId: string;
|
|
18
22
|
}[][]>;
|
|
19
23
|
bulk(ids: string[]): ReturnCache<{
|
|
20
24
|
type: number;
|
|
@@ -6,6 +6,10 @@ const Permissions_1 = require("../../structures/extra/Permissions");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'overwrite';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
parse(data, _id, guild_id) {
|
|
10
14
|
data.forEach(x => {
|
|
11
15
|
x.guild_id = guild_id;
|
|
@@ -2,6 +2,7 @@ import type { GatewayPresenceUpdate } from 'discord-api-types/v10';
|
|
|
2
2
|
import { GuildRelatedResource } from './default/guild-related';
|
|
3
3
|
export declare class Presences extends GuildRelatedResource<PresenceResource> {
|
|
4
4
|
namespace: string;
|
|
5
|
+
filter(data: GatewayPresenceUpdate, id: string, guild_id?: string): boolean;
|
|
5
6
|
parse(data: any, key: string, guild_id: string): PresenceResource;
|
|
6
7
|
}
|
|
7
8
|
export type PresenceResource = Omit<GatewayPresenceUpdate, 'user'> & {
|
|
@@ -4,6 +4,10 @@ exports.Presences = void 0;
|
|
|
4
4
|
const guild_related_1 = require("./default/guild-related");
|
|
5
5
|
class Presences extends guild_related_1.GuildRelatedResource {
|
|
6
6
|
namespace = 'presence';
|
|
7
|
+
//@ts-expect-error
|
|
8
|
+
filter(data, id, guild_id) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
7
11
|
parse(data, key, guild_id) {
|
|
8
12
|
const { user, ...rest } = super.parse(data, key, guild_id);
|
|
9
13
|
rest.user_id ??= key;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIRole } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { GuildRole } from '../../structures';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Roles extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIRole, id: string, guild_id?: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<GuildRole | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<GuildRole[]>;
|
|
8
10
|
values(guild: string): ReturnCache<GuildRole[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Roles extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'role';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawRole => rawRole ? new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id) : undefined);
|
|
11
15
|
}
|
|
@@ -2,4 +2,5 @@ import type { APIStageInstance } from 'discord-api-types/v10';
|
|
|
2
2
|
import { GuildRelatedResource } from './default/guild-related';
|
|
3
3
|
export declare class StageInstances extends GuildRelatedResource<APIStageInstance> {
|
|
4
4
|
namespace: string;
|
|
5
|
+
filter(data: APIStageInstance, id: string, guild_id?: string): boolean;
|
|
5
6
|
}
|
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StageInstances = void 0;
|
|
4
4
|
const guild_related_1 = require("./default/guild-related");
|
|
5
5
|
class StageInstances extends guild_related_1.GuildRelatedResource {
|
|
6
|
-
namespace = '
|
|
6
|
+
namespace = 'stage_instance';
|
|
7
|
+
//@ts-expect-error
|
|
8
|
+
filter(data, id, guild_id) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
7
11
|
}
|
|
8
12
|
exports.StageInstances = StageInstances;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APISticker } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { Sticker } from '../../structures';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Stickers extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APISticker, id: string, guild_id?: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<Sticker | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<Sticker[]>;
|
|
8
10
|
values(guild: string): ReturnCache<Sticker[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Stickers extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'sticker';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawSticker => rawSticker ? new structures_1.Sticker(this.client, rawSticker) : undefined);
|
|
11
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIThreadChannel } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { ThreadChannel } from '../../structures';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Threads extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIThreadChannel, id: string, guild_id?: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<ThreadChannel | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<ThreadChannel[]>;
|
|
8
10
|
values(guild: string): ReturnCache<ThreadChannel[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Threads extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'thread';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawThread => rawThread ? new structures_1.ThreadChannel(this.client, rawThread) : undefined);
|
|
11
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIUser } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { User } from '../../structures';
|
|
3
4
|
import { BaseResource } from './default/base';
|
|
4
5
|
export declare class Users extends BaseResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIUser, id: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<User | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<User[]>;
|
|
8
10
|
values(): ReturnCache<User[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const base_1 = require("./default/base");
|
|
7
7
|
class Users extends base_1.BaseResource {
|
|
8
8
|
namespace = 'user';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawUser => (rawUser ? new structures_1.User(this.client, rawUser) : undefined));
|
|
11
15
|
}
|