seyfert 2.1.1-dev-12485652015.0 → 2.1.1-dev-12489494190.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/lib/cache/index.d.ts +9 -0
- package/lib/cache/index.js +41 -35
- package/lib/cache/resources/bans.d.ts +2 -2
- package/lib/cache/resources/bans.js +1 -1
- package/lib/cache/resources/channels.d.ts +2 -2
- package/lib/cache/resources/channels.js +1 -1
- package/lib/cache/resources/default/base.d.ts +5 -5
- package/lib/cache/resources/default/base.js +7 -7
- package/lib/cache/resources/default/guild-based.d.ts +7 -7
- package/lib/cache/resources/default/guild-based.js +7 -7
- package/lib/cache/resources/default/guild-related.d.ts +7 -7
- package/lib/cache/resources/default/guild-related.js +7 -7
- package/lib/cache/resources/emojis.d.ts +2 -2
- package/lib/cache/resources/emojis.js +1 -1
- package/lib/cache/resources/guilds.d.ts +4 -4
- package/lib/cache/resources/guilds.js +27 -27
- package/lib/cache/resources/members.d.ts +4 -4
- package/lib/cache/resources/members.js +4 -4
- package/lib/cache/resources/messages.d.ts +2 -2
- package/lib/cache/resources/messages.js +1 -1
- package/lib/cache/resources/overwrites.d.ts +2 -2
- package/lib/cache/resources/overwrites.js +1 -1
- package/lib/cache/resources/presence.d.ts +2 -1
- package/lib/cache/resources/presence.js +1 -1
- package/lib/cache/resources/roles.d.ts +2 -2
- package/lib/cache/resources/roles.js +1 -1
- package/lib/cache/resources/stage-instances.d.ts +2 -1
- package/lib/cache/resources/stage-instances.js +1 -1
- package/lib/cache/resources/stickers.d.ts +2 -2
- package/lib/cache/resources/stickers.js +1 -1
- package/lib/cache/resources/users.d.ts +2 -2
- package/lib/cache/resources/users.js +1 -1
- package/lib/cache/resources/voice-states.d.ts +2 -2
- package/lib/cache/resources/voice-states.js +1 -1
- package/lib/client/base.d.ts +0 -2
- package/lib/client/base.js +1 -2
- package/lib/common/shorters/bans.js +3 -2
- package/lib/common/shorters/channels.js +6 -5
- package/lib/common/shorters/emojis.js +4 -3
- package/lib/common/shorters/guilds.js +13 -12
- package/lib/common/shorters/members.d.ts +1 -1
- package/lib/common/shorters/members.js +7 -6
- package/lib/common/shorters/messages.js +5 -4
- package/lib/common/shorters/roles.js +6 -5
- package/lib/common/shorters/threads.js +3 -2
- package/lib/common/shorters/users.js +3 -2
- package/package.json +1 -1
package/lib/cache/index.d.ts
CHANGED
|
@@ -97,20 +97,24 @@ export declare class Cache {
|
|
|
97
97
|
bans: import("..").GuildBan[];
|
|
98
98
|
}>>;
|
|
99
99
|
bulkPatch(keys: (readonly [
|
|
100
|
+
CacheFrom,
|
|
100
101
|
NonGuildBased,
|
|
101
102
|
any,
|
|
102
103
|
string
|
|
103
104
|
] | readonly [
|
|
105
|
+
CacheFrom,
|
|
104
106
|
GuildBased | GuildRelated,
|
|
105
107
|
any,
|
|
106
108
|
string,
|
|
107
109
|
string
|
|
108
110
|
])[]): Promise<void>;
|
|
109
111
|
bulkSet(keys: (readonly [
|
|
112
|
+
CacheFrom,
|
|
110
113
|
NonGuildBased,
|
|
111
114
|
any,
|
|
112
115
|
string
|
|
113
116
|
] | readonly [
|
|
117
|
+
CacheFrom,
|
|
114
118
|
GuildBased | GuildRelated,
|
|
115
119
|
any,
|
|
116
120
|
string,
|
|
@@ -122,3 +126,8 @@ export declare class Cache {
|
|
|
122
126
|
private testUsersAndMembers;
|
|
123
127
|
private testChannelsAndOverwrites;
|
|
124
128
|
}
|
|
129
|
+
export declare enum CacheFrom {
|
|
130
|
+
Gateway = 1,
|
|
131
|
+
Rest = 2,
|
|
132
|
+
Test = 3
|
|
133
|
+
}
|
package/lib/cache/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Cache = exports.GuildRelatedResource = exports.GuildBasedResource = exports.BaseResource = void 0;
|
|
17
|
+
exports.CacheFrom = exports.Cache = exports.GuildRelatedResource = exports.GuildBasedResource = exports.BaseResource = void 0;
|
|
18
18
|
const common_1 = require("../common");
|
|
19
19
|
const guilds_1 = require("./resources/guilds");
|
|
20
20
|
const users_1 = require("./resources/users");
|
|
@@ -172,7 +172,7 @@ class Cache {
|
|
|
172
172
|
async bulkPatch(keys) {
|
|
173
173
|
const allData = [];
|
|
174
174
|
const relationshipsData = {};
|
|
175
|
-
for (const [type, data, id, guildId] of keys) {
|
|
175
|
+
for (const [from, type, data, id, guildId] of keys) {
|
|
176
176
|
switch (type) {
|
|
177
177
|
case 'roles':
|
|
178
178
|
case 'stickers':
|
|
@@ -184,7 +184,7 @@ class Cache {
|
|
|
184
184
|
case 'bans':
|
|
185
185
|
case 'messages':
|
|
186
186
|
{
|
|
187
|
-
if (!this[type]?.filter(data, id, guildId))
|
|
187
|
+
if (!this[type]?.filter(data, id, guildId, from))
|
|
188
188
|
continue;
|
|
189
189
|
const hashId = this[type]?.hashId(guildId);
|
|
190
190
|
if (!hashId) {
|
|
@@ -203,7 +203,7 @@ class Cache {
|
|
|
203
203
|
case 'voiceStates':
|
|
204
204
|
case 'members':
|
|
205
205
|
{
|
|
206
|
-
if (!this[type]?.filter(data, id, guildId))
|
|
206
|
+
if (!this[type]?.filter(data, id, guildId, from))
|
|
207
207
|
continue;
|
|
208
208
|
const hashId = this[type]?.hashId(guildId);
|
|
209
209
|
if (!hashId) {
|
|
@@ -220,7 +220,7 @@ class Cache {
|
|
|
220
220
|
case 'users':
|
|
221
221
|
case 'guilds':
|
|
222
222
|
{
|
|
223
|
-
if (!this[type]?.filter(data, id))
|
|
223
|
+
if (!this[type]?.filter(data, id, from))
|
|
224
224
|
continue;
|
|
225
225
|
const hashId = this[type]?.namespace;
|
|
226
226
|
if (!hashId) {
|
|
@@ -243,7 +243,7 @@ class Cache {
|
|
|
243
243
|
async bulkSet(keys) {
|
|
244
244
|
const allData = [];
|
|
245
245
|
const relationshipsData = {};
|
|
246
|
-
for (const [type, data, id, guildId] of keys) {
|
|
246
|
+
for (const [from, type, data, id, guildId] of keys) {
|
|
247
247
|
switch (type) {
|
|
248
248
|
case 'roles':
|
|
249
249
|
case 'stickers':
|
|
@@ -254,7 +254,7 @@ class Cache {
|
|
|
254
254
|
case 'overwrites':
|
|
255
255
|
case 'messages':
|
|
256
256
|
{
|
|
257
|
-
if (!this[type]?.filter(data, id, guildId))
|
|
257
|
+
if (!this[type]?.filter(data, id, guildId, from))
|
|
258
258
|
continue;
|
|
259
259
|
const hashId = this[type]?.hashId(guildId);
|
|
260
260
|
if (!hashId) {
|
|
@@ -274,7 +274,7 @@ class Cache {
|
|
|
274
274
|
case 'voiceStates':
|
|
275
275
|
case 'members':
|
|
276
276
|
{
|
|
277
|
-
if (!this[type]?.filter(data, id, guildId))
|
|
277
|
+
if (!this[type]?.filter(data, id, guildId, from))
|
|
278
278
|
continue;
|
|
279
279
|
const hashId = this[type]?.hashId(guildId);
|
|
280
280
|
if (!hashId) {
|
|
@@ -291,7 +291,7 @@ class Cache {
|
|
|
291
291
|
case 'users':
|
|
292
292
|
case 'guilds':
|
|
293
293
|
{
|
|
294
|
-
if (!this[type]?.filter(data, id))
|
|
294
|
+
if (!this[type]?.filter(data, id, from))
|
|
295
295
|
continue;
|
|
296
296
|
const hashId = this[type]?.namespace;
|
|
297
297
|
if (!hashId) {
|
|
@@ -317,17 +317,17 @@ class Cache {
|
|
|
317
317
|
async onPacketDefault(event) {
|
|
318
318
|
switch (event.t) {
|
|
319
319
|
case 'READY':
|
|
320
|
-
await this.users?.set(event.d.user.id, event.d.user);
|
|
320
|
+
await this.users?.set(CacheFrom.Gateway, event.d.user.id, event.d.user);
|
|
321
321
|
break;
|
|
322
322
|
case 'GUILD_CREATE':
|
|
323
323
|
case 'GUILD_UPDATE':
|
|
324
324
|
case 'RAW_GUILD_CREATE':
|
|
325
|
-
await this.guilds?.patch(event.d.id, { unavailable: false, ...event.d });
|
|
325
|
+
await this.guilds?.patch(CacheFrom.Gateway, event.d.id, { unavailable: false, ...event.d });
|
|
326
326
|
break;
|
|
327
327
|
case 'GUILD_DELETE':
|
|
328
328
|
case 'RAW_GUILD_DELETE':
|
|
329
329
|
if (event.d.unavailable) {
|
|
330
|
-
await this.guilds?.patch(event.d.id, event.d);
|
|
330
|
+
await this.guilds?.patch(CacheFrom.Gateway, event.d.id, event.d);
|
|
331
331
|
}
|
|
332
332
|
else {
|
|
333
333
|
await this.guilds?.remove(event.d.id);
|
|
@@ -337,13 +337,13 @@ class Cache {
|
|
|
337
337
|
case 'CHANNEL_UPDATE':
|
|
338
338
|
{
|
|
339
339
|
if ('guild_id' in event.d) {
|
|
340
|
-
await this.channels?.set(event.d.id, event.d.guild_id, event.d);
|
|
340
|
+
await this.channels?.set(CacheFrom.Gateway, event.d.id, event.d.guild_id, event.d);
|
|
341
341
|
if (event.d.permission_overwrites?.length)
|
|
342
|
-
await this.overwrites?.set(event.d.id, event.d.guild_id, event.d.permission_overwrites);
|
|
342
|
+
await this.overwrites?.set(CacheFrom.Gateway, event.d.id, event.d.guild_id, event.d.permission_overwrites);
|
|
343
343
|
break;
|
|
344
344
|
}
|
|
345
345
|
if (event.d.type === types_1.ChannelType.DM) {
|
|
346
|
-
await this.channels?.set(event.d.recipients[0]?.id, '@me', event.d);
|
|
346
|
+
await this.channels?.set(CacheFrom.Gateway, event.d.recipients[0]?.id, '@me', event.d);
|
|
347
347
|
break;
|
|
348
348
|
}
|
|
349
349
|
}
|
|
@@ -353,13 +353,13 @@ class Cache {
|
|
|
353
353
|
break;
|
|
354
354
|
case 'GUILD_ROLE_CREATE':
|
|
355
355
|
case 'GUILD_ROLE_UPDATE':
|
|
356
|
-
await this.roles?.set(event.d.role.id, event.d.guild_id, event.d.role);
|
|
356
|
+
await this.roles?.set(CacheFrom.Gateway, event.d.role.id, event.d.guild_id, event.d.role);
|
|
357
357
|
break;
|
|
358
358
|
case 'GUILD_ROLE_DELETE':
|
|
359
359
|
await this.roles?.remove(event.d.role_id, event.d.guild_id);
|
|
360
360
|
break;
|
|
361
361
|
case 'GUILD_BAN_ADD':
|
|
362
|
-
await this.bans?.set(event.d.user.id, event.d.guild_id, event.d);
|
|
362
|
+
await this.bans?.set(CacheFrom.Gateway, event.d.user.id, event.d.guild_id, event.d);
|
|
363
363
|
break;
|
|
364
364
|
case 'GUILD_BAN_REMOVE':
|
|
365
365
|
await this.bans?.remove(event.d.user.id, event.d.guild_id);
|
|
@@ -367,37 +367,37 @@ class Cache {
|
|
|
367
367
|
case 'GUILD_EMOJIS_UPDATE':
|
|
368
368
|
{
|
|
369
369
|
await this.emojis?.remove(await this.emojis?.keys(event.d.guild_id), event.d.guild_id);
|
|
370
|
-
await this.emojis?.set(event.d.emojis.map(x => [x.id, x]), event.d.guild_id);
|
|
370
|
+
await this.emojis?.set(CacheFrom.Gateway, event.d.emojis.map(x => [x.id, x]), event.d.guild_id);
|
|
371
371
|
}
|
|
372
372
|
break;
|
|
373
373
|
case 'GUILD_STICKERS_UPDATE':
|
|
374
374
|
{
|
|
375
375
|
await this.stickers?.remove(await this.stickers?.keys(event.d.guild_id), event.d.guild_id);
|
|
376
|
-
await this.stickers?.set(event.d.stickers.map(x => [x.id, x]), event.d.guild_id);
|
|
376
|
+
await this.stickers?.set(CacheFrom.Gateway, event.d.stickers.map(x => [x.id, x]), event.d.guild_id);
|
|
377
377
|
}
|
|
378
378
|
break;
|
|
379
379
|
case 'GUILD_MEMBER_ADD':
|
|
380
380
|
case 'GUILD_MEMBER_UPDATE':
|
|
381
381
|
if (event.d.user)
|
|
382
|
-
await this.members?.set(event.d.user.id, event.d.guild_id, event.d);
|
|
382
|
+
await this.members?.set(CacheFrom.Gateway, event.d.user.id, event.d.guild_id, event.d);
|
|
383
383
|
break;
|
|
384
384
|
case 'GUILD_MEMBER_REMOVE':
|
|
385
385
|
await this.members?.remove(event.d.user.id, event.d.guild_id);
|
|
386
386
|
break;
|
|
387
387
|
case 'PRESENCE_UPDATE':
|
|
388
388
|
// Should update member data?
|
|
389
|
-
await this.presences?.set(event.d.user.id, event.d.guild_id, event.d);
|
|
389
|
+
await this.presences?.set(CacheFrom.Gateway, event.d.user.id, event.d.guild_id, event.d);
|
|
390
390
|
break;
|
|
391
391
|
case 'THREAD_CREATE':
|
|
392
392
|
case 'THREAD_UPDATE':
|
|
393
393
|
if (event.d.guild_id)
|
|
394
|
-
await this.channels?.set(event.d.id, event.d.guild_id, event.d);
|
|
394
|
+
await this.channels?.set(CacheFrom.Gateway, event.d.id, event.d.guild_id, event.d);
|
|
395
395
|
break;
|
|
396
396
|
case 'THREAD_DELETE':
|
|
397
397
|
await this.channels?.remove(event.d.id, event.d.guild_id);
|
|
398
398
|
break;
|
|
399
399
|
case 'USER_UPDATE':
|
|
400
|
-
await this.users?.set(event.d.id, event.d);
|
|
400
|
+
await this.users?.set(CacheFrom.Gateway, event.d.id, event.d);
|
|
401
401
|
break;
|
|
402
402
|
case 'VOICE_STATE_UPDATE':
|
|
403
403
|
{
|
|
@@ -405,7 +405,7 @@ class Cache {
|
|
|
405
405
|
return;
|
|
406
406
|
}
|
|
407
407
|
if (event.d.channel_id != null) {
|
|
408
|
-
await this.voiceStates?.set(event.d.user_id, event.d.guild_id, event.d);
|
|
408
|
+
await this.voiceStates?.set(CacheFrom.Gateway, event.d.user_id, event.d.guild_id, event.d);
|
|
409
409
|
}
|
|
410
410
|
else {
|
|
411
411
|
await this.voiceStates?.remove(event.d.user_id, event.d.guild_id);
|
|
@@ -414,7 +414,7 @@ class Cache {
|
|
|
414
414
|
break;
|
|
415
415
|
case 'STAGE_INSTANCE_CREATE':
|
|
416
416
|
case 'STAGE_INSTANCE_UPDATE':
|
|
417
|
-
await this.stageInstances?.set(event.d.id, event.d.guild_id, event.d);
|
|
417
|
+
await this.stageInstances?.set(CacheFrom.Gateway, event.d.id, event.d.guild_id, event.d);
|
|
418
418
|
break;
|
|
419
419
|
case 'STAGE_INSTANCE_DELETE':
|
|
420
420
|
await this.stageInstances?.remove(event.d.id, event.d.guild_id);
|
|
@@ -423,12 +423,12 @@ class Cache {
|
|
|
423
423
|
{
|
|
424
424
|
if (this.messages !== undefined) {
|
|
425
425
|
const data = [
|
|
426
|
-
['messages', event.d, event.d.id, event.d.channel_id],
|
|
427
|
-
['users', event.d.author, event.d.author.id],
|
|
426
|
+
[CacheFrom.Gateway, 'messages', event.d, event.d.id, event.d.channel_id],
|
|
427
|
+
[CacheFrom.Gateway, 'users', event.d.author, event.d.author.id],
|
|
428
428
|
];
|
|
429
429
|
if (event.d.guild_id) {
|
|
430
430
|
if (event.d.member)
|
|
431
|
-
data.push(['members', event.d.member, event.d.author.id, event.d.guild_id]);
|
|
431
|
+
data.push([CacheFrom.Gateway, 'members', event.d.member, event.d.author.id, event.d.guild_id]);
|
|
432
432
|
}
|
|
433
433
|
await this.bulkPatch(data);
|
|
434
434
|
}
|
|
@@ -438,12 +438,12 @@ class Cache {
|
|
|
438
438
|
{
|
|
439
439
|
if (this.messages !== undefined) {
|
|
440
440
|
const data = [
|
|
441
|
-
['messages', event.d, event.d.id, event.d.channel_id],
|
|
442
|
-
['users', event.d.author, event.d.author.id],
|
|
441
|
+
[CacheFrom.Gateway, 'messages', event.d, event.d.id, event.d.channel_id],
|
|
442
|
+
[CacheFrom.Gateway, 'users', event.d.author, event.d.author.id],
|
|
443
443
|
];
|
|
444
444
|
if (event.d.guild_id) {
|
|
445
445
|
if (event.d.member)
|
|
446
|
-
data.push(['members', event.d.member, event.d.author.id, event.d.guild_id]);
|
|
446
|
+
data.push([CacheFrom.Gateway, 'members', event.d.member, event.d.author.id, event.d.guild_id]);
|
|
447
447
|
}
|
|
448
448
|
await this.bulkPatch(data);
|
|
449
449
|
}
|
|
@@ -512,7 +512,7 @@ class Cache {
|
|
|
512
512
|
createUser('marcrock'),
|
|
513
513
|
];
|
|
514
514
|
for (const user of users) {
|
|
515
|
-
await this.users.set(user.id, user);
|
|
515
|
+
await this.users.set(CacheFrom.Test, user.id, user);
|
|
516
516
|
}
|
|
517
517
|
let count = 0;
|
|
518
518
|
if ((await this.users.values()).length !== users.length)
|
|
@@ -559,7 +559,7 @@ class Cache {
|
|
|
559
559
|
for (const guildId in guildMembers) {
|
|
560
560
|
const members = guildMembers[guildId];
|
|
561
561
|
for (const member of members) {
|
|
562
|
-
await this.members.set(member.user.id, guildId, member);
|
|
562
|
+
await this.members.set(CacheFrom.Test, member.user.id, guildId, member);
|
|
563
563
|
}
|
|
564
564
|
if ((await this.members.values(guildId)).length !== members.length)
|
|
565
565
|
throw new Error('members.values(guildId) is not of the expected size.');
|
|
@@ -654,7 +654,7 @@ class Cache {
|
|
|
654
654
|
for (const guildId in guildChannels) {
|
|
655
655
|
const channels = guildChannels[guildId];
|
|
656
656
|
for (const channel of channels) {
|
|
657
|
-
await this.channels.set(channel.id, guildId, channel);
|
|
657
|
+
await this.channels.set(CacheFrom.Test, channel.id, guildId, channel);
|
|
658
658
|
}
|
|
659
659
|
if ((await this.channels.values(guildId)).length !== channels.length)
|
|
660
660
|
throw new Error('channels.values(guildId) is not of the expected size');
|
|
@@ -712,7 +712,7 @@ class Cache {
|
|
|
712
712
|
for (const guildId in guildOverwrites) {
|
|
713
713
|
const bulkOverwrites = guildOverwrites[guildId];
|
|
714
714
|
for (const overwrites of bulkOverwrites) {
|
|
715
|
-
await this.overwrites.set(overwrites[0].channel_id, guildId, overwrites);
|
|
715
|
+
await this.overwrites.set(CacheFrom.Test, overwrites[0].channel_id, guildId, overwrites);
|
|
716
716
|
}
|
|
717
717
|
if ((await this.overwrites.values(guildId)).length !== bulkOverwrites.length)
|
|
718
718
|
throw new Error('overwrites.values(channelId) is not of the expected size');
|
|
@@ -753,3 +753,9 @@ class Cache {
|
|
|
753
753
|
}
|
|
754
754
|
}
|
|
755
755
|
exports.Cache = Cache;
|
|
756
|
+
var CacheFrom;
|
|
757
|
+
(function (CacheFrom) {
|
|
758
|
+
CacheFrom[CacheFrom["Gateway"] = 1] = "Gateway";
|
|
759
|
+
CacheFrom[CacheFrom["Rest"] = 2] = "Rest";
|
|
760
|
+
CacheFrom[CacheFrom["Test"] = 3] = "Test";
|
|
761
|
+
})(CacheFrom || (exports.CacheFrom = CacheFrom = {}));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ReturnCache } from '../..';
|
|
1
|
+
import type { CacheFrom, ReturnCache } from '../..';
|
|
2
2
|
import { type GuildBanStructure } from '../../client/transformers';
|
|
3
3
|
import type { APIBan, GatewayGuildBanModifyDispatchData } from '../../types';
|
|
4
4
|
import { GuildBasedResource } from './default/guild-based';
|
|
5
5
|
export declare class Bans extends GuildBasedResource<any, GatewayGuildBanModifyDispatchData | APIBan> {
|
|
6
6
|
namespace: string;
|
|
7
|
-
filter(data: APIBan, id: string, guild_id: string): boolean;
|
|
7
|
+
filter(data: APIBan, id: string, guild_id: string, from: CacheFrom): boolean;
|
|
8
8
|
parse(data: any, key: string, guild_id: string): any;
|
|
9
9
|
get(id: string, guild: string): ReturnCache<GuildBanStructure | undefined>;
|
|
10
10
|
raw(id: string, guild: string): ReturnCache<Omit<GatewayGuildBanModifyDispatchData | APIBan, 'user'> | undefined>;
|
|
@@ -7,7 +7,7 @@ const guild_based_1 = require("./default/guild-based");
|
|
|
7
7
|
class Bans extends guild_based_1.GuildBasedResource {
|
|
8
8
|
namespace = 'ban';
|
|
9
9
|
//@ts-expect-error
|
|
10
|
-
filter(data, id, guild_id) {
|
|
10
|
+
filter(data, id, guild_id, from) {
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
parse(data, key, guild_id) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type AllChannels, channelFrom } from '../../structures';
|
|
2
2
|
import type { APIChannel } from '../../types';
|
|
3
|
-
import type { ReturnCache } from '../index';
|
|
3
|
+
import type { CacheFrom, ReturnCache } from '../index';
|
|
4
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
5
5
|
export declare class Channels extends GuildRelatedResource<any, APIChannel> {
|
|
6
6
|
namespace: string;
|
|
7
|
-
filter(data: APIChannel, id: string, guild_id: string): boolean;
|
|
7
|
+
filter(data: APIChannel, id: string, guild_id: string, from: CacheFrom): boolean;
|
|
8
8
|
parse(data: APIChannel, id: string, guild_id: string): any;
|
|
9
9
|
get(id: string): ReturnCache<AllChannels | undefined>;
|
|
10
10
|
raw(id: string): ReturnCache<Omit<APIChannel, 'permission_overwrites'> | undefined>;
|
|
@@ -7,7 +7,7 @@ const guild_related_1 = require("./default/guild-related");
|
|
|
7
7
|
class Channels extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'channel';
|
|
9
9
|
//@ts-expect-error
|
|
10
|
-
filter(data, id, guild_id) {
|
|
10
|
+
filter(data, id, guild_id, from) {
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
parse(data, id, guild_id) {
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import type { UsingClient } from '../../../commands';
|
|
2
2
|
import type { GatewayIntentBits } from '../../../types';
|
|
3
|
-
import type { Cache, ReturnCache } from '../../index';
|
|
3
|
+
import type { Cache, CacheFrom, ReturnCache } from '../../index';
|
|
4
4
|
export declare class BaseResource<T = any, S = any> {
|
|
5
5
|
protected cache: Cache;
|
|
6
6
|
readonly client: UsingClient;
|
|
7
7
|
namespace: string;
|
|
8
8
|
constructor(cache: Cache, client: UsingClient);
|
|
9
|
-
filter(data: any, id: string): boolean;
|
|
9
|
+
filter(data: any, id: string, from: CacheFrom): boolean;
|
|
10
10
|
get adapter(): import("../../index").Adapter;
|
|
11
11
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("../../../common").Awaitable<void>;
|
|
12
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: S): import("../../../common").Awaitable<void>;
|
|
12
|
+
setIfNI(from: CacheFrom, intent: keyof typeof GatewayIntentBits, id: string, data: S): import("../../../common").Awaitable<void>;
|
|
13
13
|
get(id: string): ReturnCache<T | undefined>;
|
|
14
14
|
bulk(ids: string[]): ReturnCache<T[]>;
|
|
15
|
-
set(id: string, data: S): import("../../../common").Awaitable<void>;
|
|
16
|
-
patch(id: string, data: S): import("../../../common").Awaitable<void>;
|
|
15
|
+
set(from: CacheFrom, id: string, data: S): import("../../../common").Awaitable<void>;
|
|
16
|
+
patch(from: CacheFrom, id: string, data: S): import("../../../common").Awaitable<void>;
|
|
17
17
|
remove(id: string): import("../../../common").Awaitable<void>;
|
|
18
18
|
keys(): ReturnCache<string[]>;
|
|
19
19
|
values(): ReturnCache<T[]>;
|
|
@@ -11,7 +11,7 @@ class BaseResource {
|
|
|
11
11
|
this.client = client;
|
|
12
12
|
}
|
|
13
13
|
//@ts-expect-error
|
|
14
|
-
filter(data, id) {
|
|
14
|
+
filter(data, id, from) {
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
17
|
get adapter() {
|
|
@@ -23,9 +23,9 @@ class BaseResource {
|
|
|
23
23
|
}
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
setIfNI(intent, id, data) {
|
|
26
|
+
setIfNI(from, intent, id, data) {
|
|
27
27
|
if (!this.cache.hasIntent(intent)) {
|
|
28
|
-
return this.set(id, data);
|
|
28
|
+
return this.set(from, id, data);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
get(id) {
|
|
@@ -34,13 +34,13 @@ class BaseResource {
|
|
|
34
34
|
bulk(ids) {
|
|
35
35
|
return (0, common_1.fakePromise)(this.adapter.bulkGet(ids.map(id => this.hashId(id)))).then(x => x.filter(y => y));
|
|
36
36
|
}
|
|
37
|
-
set(id, data) {
|
|
38
|
-
if (!this.filter(data, id))
|
|
37
|
+
set(from, id, data) {
|
|
38
|
+
if (!this.filter(data, id, from))
|
|
39
39
|
return;
|
|
40
40
|
return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.set(this.hashId(id), data));
|
|
41
41
|
}
|
|
42
|
-
patch(id, data) {
|
|
43
|
-
if (!this.filter(data, id))
|
|
42
|
+
patch(from, id, data) {
|
|
43
|
+
if (!this.filter(data, id, from))
|
|
44
44
|
return;
|
|
45
45
|
return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.patch(this.hashId(id), data));
|
|
46
46
|
}
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import type { UsingClient } from '../../../commands';
|
|
2
2
|
import type { GatewayIntentBits } from '../../../types';
|
|
3
|
-
import type { Cache, ReturnCache } from '../../index';
|
|
3
|
+
import type { Cache, CacheFrom, ReturnCache } from '../../index';
|
|
4
4
|
export declare class GuildBasedResource<T = any, S = any> {
|
|
5
5
|
protected cache: Cache;
|
|
6
6
|
readonly client: UsingClient;
|
|
7
7
|
namespace: string;
|
|
8
8
|
constructor(cache: Cache, client: UsingClient);
|
|
9
|
-
filter(data: any, id: string, guild_id: string): boolean;
|
|
9
|
+
filter(data: any, id: string, guild_id: string, from: CacheFrom): boolean;
|
|
10
10
|
parse(data: any, id: string, guild_id: string): any;
|
|
11
11
|
get adapter(): import("../../index").Adapter;
|
|
12
12
|
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: S): void;
|
|
13
|
+
setIfNI(from: CacheFrom, intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: S): void;
|
|
14
14
|
get(id: string, guild: string): ReturnCache<(T & {
|
|
15
15
|
guild_id: string;
|
|
16
16
|
}) | undefined>;
|
|
17
17
|
bulk(ids: string[], guild: string): ReturnCache<(T & {
|
|
18
18
|
guild_id: string;
|
|
19
19
|
})[]>;
|
|
20
|
-
set(__keys: string, guild: string, data: S): ReturnCache<void>;
|
|
21
|
-
set(__keys: [string, S][], guild: string): ReturnCache<void>;
|
|
22
|
-
patch(__keys: string, guild: string, data: S): ReturnCache<void>;
|
|
23
|
-
patch(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
20
|
+
set(from: CacheFrom, __keys: string, guild: string, data: S): ReturnCache<void>;
|
|
21
|
+
set(from: CacheFrom, __keys: [string, S][], guild: string): ReturnCache<void>;
|
|
22
|
+
patch(from: CacheFrom, __keys: string, guild: string, data: S): ReturnCache<void>;
|
|
23
|
+
patch(from: CacheFrom, __keys: [string, any][], guild: string): ReturnCache<void>;
|
|
24
24
|
remove(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
25
25
|
keys(guild: string): ReturnCache<string[]>;
|
|
26
26
|
values(guild: string): ReturnCache<(T & {
|
|
@@ -11,7 +11,7 @@ class GuildBasedResource {
|
|
|
11
11
|
this.client = client;
|
|
12
12
|
}
|
|
13
13
|
//@ts-expect-error
|
|
14
|
-
filter(data, id, guild_id) {
|
|
14
|
+
filter(data, id, guild_id, from) {
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
17
|
parse(data, id, guild_id) {
|
|
@@ -29,9 +29,9 @@ class GuildBasedResource {
|
|
|
29
29
|
}
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
setIfNI(intent, id, guildId, data) {
|
|
32
|
+
setIfNI(from, intent, id, guildId, data) {
|
|
33
33
|
if (!this.cache.hasIntent(intent)) {
|
|
34
|
-
return this.set(id, guildId, data);
|
|
34
|
+
return this.set(from, id, guildId, data);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
get(id, guild) {
|
|
@@ -40,14 +40,14 @@ class GuildBasedResource {
|
|
|
40
40
|
bulk(ids, guild) {
|
|
41
41
|
return (0, common_1.fakePromise)(this.adapter.bulkGet(ids.map(id => this.hashGuildId(guild, id)))).then(x => x.filter(y => y));
|
|
42
42
|
}
|
|
43
|
-
set(__keys, guild, data) {
|
|
44
|
-
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
43
|
+
set(from, __keys, guild, data) {
|
|
44
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild, from));
|
|
45
45
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.bulkSet(keys.map(([key, value]) => {
|
|
46
46
|
return [this.hashGuildId(guild, key), this.parse(value, key, guild)];
|
|
47
47
|
})));
|
|
48
48
|
}
|
|
49
|
-
patch(__keys, guild, data) {
|
|
50
|
-
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
49
|
+
patch(from, __keys, guild, data) {
|
|
50
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild, from));
|
|
51
51
|
return (0, common_1.fakePromise)(this.adapter.bulkGet(keys.map(([key]) => this.hashGuildId(guild, key)))).then(oldDatas => (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.bulkSet(keys.map(([key, value]) => {
|
|
52
52
|
const oldData = oldDatas.find(x => x.id === key) ?? {};
|
|
53
53
|
return [this.hashGuildId(guild, key), this.parse({ ...oldData, ...value }, key, guild)];
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import type { UsingClient } from '../../../commands';
|
|
2
2
|
import type { GatewayIntentBits } from '../../../types';
|
|
3
|
-
import type { Cache, ReturnCache } from '../../index';
|
|
3
|
+
import type { Cache, CacheFrom, ReturnCache } from '../../index';
|
|
4
4
|
export declare class GuildRelatedResource<T = any, S = any> {
|
|
5
5
|
protected cache: Cache;
|
|
6
6
|
readonly client: UsingClient;
|
|
7
7
|
namespace: string;
|
|
8
8
|
constructor(cache: Cache, client: UsingClient);
|
|
9
|
-
filter(data: any, id: string, guild_id
|
|
9
|
+
filter(data: any, id: string, guild_id: string, from: CacheFrom): boolean;
|
|
10
10
|
parse(data: any, id: string, guild_id: string): any;
|
|
11
11
|
get adapter(): import("../../index").Adapter;
|
|
12
12
|
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: S): void;
|
|
13
|
+
setIfNI(from: CacheFrom, intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: S): void;
|
|
14
14
|
get(id: string): ReturnCache<(T & {
|
|
15
15
|
guild_id: string;
|
|
16
16
|
}) | undefined>;
|
|
17
17
|
bulk(ids: string[]): ReturnCache<(T & {
|
|
18
18
|
guild_id: string;
|
|
19
19
|
})[]>;
|
|
20
|
-
set(__keys: string, guild: string, data: S): ReturnCache<void>;
|
|
21
|
-
set(__keys: [string, S][], guild: string): ReturnCache<void>;
|
|
22
|
-
patch(__keys: string, guild: string, data?: any): ReturnCache<void>;
|
|
23
|
-
patch(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
20
|
+
set(from: CacheFrom, __keys: string, guild: string, data: S): ReturnCache<void>;
|
|
21
|
+
set(from: CacheFrom, __keys: [string, S][], guild: string): ReturnCache<void>;
|
|
22
|
+
patch(from: CacheFrom, __keys: string, guild: string, data?: any): ReturnCache<void>;
|
|
23
|
+
patch(from: CacheFrom, __keys: [string, any][], guild: string): ReturnCache<void>;
|
|
24
24
|
remove(id: string | string[], guild: string): import("../../../common").Awaitable<void>;
|
|
25
25
|
keys(guild: string): ReturnCache<string[]>;
|
|
26
26
|
values(guild: string): ReturnCache<(T & {
|
|
@@ -11,7 +11,7 @@ class GuildRelatedResource {
|
|
|
11
11
|
this.client = client;
|
|
12
12
|
}
|
|
13
13
|
//@ts-expect-error
|
|
14
|
-
filter(data, id, guild_id) {
|
|
14
|
+
filter(data, id, guild_id, from) {
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
17
|
parse(data, id, guild_id) {
|
|
@@ -28,9 +28,9 @@ class GuildRelatedResource {
|
|
|
28
28
|
return this.remove(id, guildId);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
setIfNI(intent, id, guildId, data) {
|
|
31
|
+
setIfNI(from, intent, id, guildId, data) {
|
|
32
32
|
if (!this.cache.hasIntent(intent)) {
|
|
33
|
-
return this.set(id, guildId, data);
|
|
33
|
+
return this.set(from, id, guildId, data);
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
get(id) {
|
|
@@ -39,14 +39,14 @@ class GuildRelatedResource {
|
|
|
39
39
|
bulk(ids) {
|
|
40
40
|
return (0, common_1.fakePromise)(this.adapter.bulkGet(ids.map(x => this.hashId(x)))).then(x => x.filter(y => y));
|
|
41
41
|
}
|
|
42
|
-
set(__keys, guild, data) {
|
|
43
|
-
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
42
|
+
set(from, __keys, guild, data) {
|
|
43
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild, from));
|
|
44
44
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.bulkSet(keys.map(([key, value]) => {
|
|
45
45
|
return [this.hashId(key), this.parse(value, key, guild)];
|
|
46
46
|
})));
|
|
47
47
|
}
|
|
48
|
-
patch(__keys, guild, data) {
|
|
49
|
-
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
48
|
+
patch(from, __keys, guild, data) {
|
|
49
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild, from));
|
|
50
50
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.bulkPatch(keys.map(([key, value]) => {
|
|
51
51
|
return [this.hashId(key), this.parse(value, key, guild)];
|
|
52
52
|
})));
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ReturnCache } from '../..';
|
|
1
|
+
import type { CacheFrom, ReturnCache } from '../..';
|
|
2
2
|
import { type GuildEmojiStructure } from '../../client/transformers';
|
|
3
3
|
import type { APIEmoji } from '../../types';
|
|
4
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
5
5
|
export declare class Emojis extends GuildRelatedResource<any, APIEmoji> {
|
|
6
6
|
namespace: string;
|
|
7
|
-
filter(data: APIEmoji, id: string, guild_id
|
|
7
|
+
filter(data: APIEmoji, id: string, guild_id: string, from: CacheFrom): boolean;
|
|
8
8
|
get(id: string): ReturnCache<GuildEmojiStructure | undefined>;
|
|
9
9
|
raw(id: string): ReturnCache<APIEmoji | undefined>;
|
|
10
10
|
bulk(ids: string[]): ReturnCache<GuildEmojiStructure[]>;
|
|
@@ -7,7 +7,7 @@ const guild_related_1 = require("./default/guild-related");
|
|
|
7
7
|
class Emojis extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'emoji';
|
|
9
9
|
//@ts-expect-error
|
|
10
|
-
filter(data, id, guild_id) {
|
|
10
|
+
filter(data, id, guild_id, from) {
|
|
11
11
|
return true;
|
|
12
12
|
}
|
|
13
13
|
get(id) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ReturnCache } from '..';
|
|
1
|
+
import type { CacheFrom, ReturnCache } from '..';
|
|
2
2
|
import { type GuildStructure } from '../../client/transformers';
|
|
3
3
|
import type { APIGuild, GatewayGuildCreateDispatchData } from '../../types';
|
|
4
4
|
import { BaseResource } from './default/base';
|
|
5
5
|
export declare class Guilds extends BaseResource<any, APIGuild | GatewayGuildCreateDispatchData> {
|
|
6
6
|
namespace: string;
|
|
7
|
-
filter(data: APIGuild, id: string): boolean;
|
|
7
|
+
filter(data: APIGuild, id: string, from: CacheFrom): boolean;
|
|
8
8
|
get(id: string): ReturnCache<GuildStructure<'cached'> | undefined>;
|
|
9
9
|
raw(id: string): ReturnCache<APIGuild | undefined>;
|
|
10
10
|
bulk(ids: string[]): ReturnCache<GuildStructure<'cached'>[]>;
|
|
@@ -12,6 +12,6 @@ export declare class Guilds extends BaseResource<any, APIGuild | GatewayGuildCre
|
|
|
12
12
|
values(): ReturnCache<GuildStructure<'cached'>[]>;
|
|
13
13
|
valuesRaw(): ReturnCache<APIGuild[]>;
|
|
14
14
|
remove(id: string): Promise<void>;
|
|
15
|
-
set(id: string, data: any): Promise<void>;
|
|
16
|
-
patch(id: string, data: any): Promise<void>;
|
|
15
|
+
set(from: CacheFrom, id: string, data: any): Promise<void>;
|
|
16
|
+
patch(from: CacheFrom, id: string, data: any): Promise<void>;
|
|
17
17
|
}
|