seyfert 0.1.0 → 1.0.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/README.md +19 -30
- package/lib/api/CDN.d.ts +0 -8
- package/lib/api/CDN.js +7 -13
- package/lib/api/Router.d.ts +2 -2
- package/lib/api/Router.js +1 -1
- package/lib/api/Routes/applications.d.ts +1 -1
- package/lib/api/Routes/channels.d.ts +1 -1
- package/lib/api/Routes/gateway.d.ts +1 -1
- package/lib/api/Routes/guilds.d.ts +1 -1
- package/lib/api/Routes/interactions.d.ts +1 -1
- package/lib/api/Routes/invites.d.ts +1 -1
- package/lib/api/Routes/stage-instances.d.ts +1 -1
- package/lib/api/Routes/stickers.d.ts +1 -1
- package/lib/api/Routes/users.d.ts +1 -1
- package/lib/api/Routes/voice.d.ts +1 -1
- package/lib/api/Routes/webhooks.d.ts +1 -1
- package/lib/api/api.d.ts +39 -0
- package/lib/api/api.js +318 -0
- package/lib/api/bucket.d.ts +19 -0
- package/lib/api/bucket.js +71 -0
- package/lib/api/index.d.ts +1 -1
- package/lib/api/index.js +1 -1
- package/lib/api/shared.d.ts +31 -5
- package/lib/api/shared.js +2 -7
- package/lib/api/utils/constants.d.ts +1 -30
- package/lib/api/utils/constants.js +2 -41
- package/lib/api/utils/types.d.ts +1 -320
- package/lib/api/utils/utils.d.ts +0 -38
- package/lib/api/utils/utils.js +1 -139
- package/lib/builders/ActionRow.js +1 -1
- package/lib/builders/Attachment.d.ts +14 -6
- package/lib/builders/Attachment.js +30 -7
- package/lib/builders/Button.d.ts +3 -12
- package/lib/builders/Button.js +0 -11
- package/lib/builders/{MessageEmbed.d.ts → Embed.d.ts} +15 -15
- package/lib/builders/{MessageEmbed.js → Embed.js} +16 -16
- package/lib/builders/Modal.js +1 -1
- package/lib/builders/SelectMenu.d.ts +14 -15
- package/lib/builders/SelectMenu.js +19 -18
- package/lib/builders/index.d.ts +1 -1
- package/lib/builders/index.js +1 -1
- package/lib/builders/types.d.ts +2 -2
- package/lib/cache/adapters/default.js +2 -2
- package/lib/cache/adapters/redis.d.ts +2 -3
- package/lib/cache/adapters/redis.js +13 -5
- package/lib/cache/adapters/workeradapter.d.ts +9 -1
- package/lib/cache/adapters/workeradapter.js +7 -3
- package/lib/cache/index.d.ts +20 -6
- package/lib/cache/index.js +26 -10
- package/lib/cache/resources/channels.d.ts +6 -2
- package/lib/cache/resources/channels.js +12 -6
- package/lib/cache/resources/default/base.d.ts +17 -16
- package/lib/cache/resources/default/base.js +25 -24
- package/lib/cache/resources/default/guild-based.d.ts +22 -19
- package/lib/cache/resources/default/guild-based.js +32 -31
- package/lib/cache/resources/default/guild-related.d.ts +22 -19
- package/lib/cache/resources/default/guild-related.js +37 -43
- package/lib/cache/resources/emojis.d.ts +4 -2
- package/lib/cache/resources/emojis.js +8 -6
- package/lib/cache/resources/guilds.d.ts +4 -2
- package/lib/cache/resources/guilds.js +15 -8
- package/lib/cache/resources/members.d.ts +4 -2
- package/lib/cache/resources/members.js +16 -13
- package/lib/cache/resources/overwrites.d.ts +25 -0
- package/lib/cache/resources/overwrites.js +39 -0
- package/lib/cache/resources/presence.js +3 -4
- package/lib/cache/resources/roles.d.ts +4 -2
- package/lib/cache/resources/roles.js +8 -6
- package/lib/cache/resources/stickers.d.ts +4 -2
- package/lib/cache/resources/stickers.js +8 -6
- package/lib/cache/resources/threads.d.ts +4 -2
- package/lib/cache/resources/threads.js +8 -6
- package/lib/cache/resources/users.d.ts +4 -2
- package/lib/cache/resources/users.js +8 -6
- package/lib/cache/resources/voice-states.d.ts +3 -3
- package/lib/cache/resources/voice-states.js +6 -7
- package/lib/client/base.d.ts +49 -16
- package/lib/client/base.js +21 -17
- package/lib/client/client.d.ts +14 -3
- package/lib/client/client.js +21 -21
- package/lib/client/httpclient.d.ts +3 -5
- package/lib/client/httpclient.js +29 -16
- package/lib/client/{oninteraction.d.ts → oninteractioncreate.d.ts} +1 -1
- package/lib/client/{oninteraction.js → oninteractioncreate.js} +34 -23
- package/lib/client/onmessagecreate.d.ts +3 -0
- package/lib/client/onmessagecreate.js +337 -0
- package/lib/client/workerclient.d.ts +5 -1
- package/lib/client/workerclient.js +67 -44
- package/lib/collection.d.ts +1 -1
- package/lib/collection.js +9 -6
- package/lib/commands/applications/chat.d.ts +32 -25
- package/lib/commands/applications/chat.js +51 -34
- package/lib/commands/applications/chatcontext.d.ts +34 -16
- package/lib/commands/applications/chatcontext.js +99 -20
- package/lib/commands/applications/menu.d.ts +9 -8
- package/lib/commands/applications/menu.js +14 -5
- package/lib/commands/applications/menucontext.d.ts +27 -10
- package/lib/commands/applications/menucontext.js +51 -7
- package/lib/commands/applications/options.d.ts +13 -13
- package/lib/commands/applications/shared.d.ts +7 -2
- package/lib/commands/decorators.d.ts +14 -14
- package/lib/commands/decorators.js +9 -5
- package/lib/commands/handler.d.ts +2 -1
- package/lib/commands/handler.js +60 -14
- package/lib/commands/index.d.ts +1 -1
- package/lib/commands/index.js +2 -1
- package/lib/commands/optionresolver.d.ts +6 -5
- package/lib/commands/optionresolver.js +10 -6
- package/lib/common/bot/watcher.d.ts +3 -3
- package/lib/common/bot/watcher.js +3 -1
- package/lib/common/index.d.ts +1 -1
- package/lib/common/index.js +2 -1
- package/lib/common/it/logger.d.ts +11 -0
- package/lib/common/it/logger.js +51 -2
- package/lib/common/it/utils.d.ts +3 -13
- package/lib/common/it/utils.js +9 -30
- package/lib/common/shorters/channels.d.ts +55 -5
- package/lib/common/shorters/channels.js +59 -0
- package/lib/common/shorters/guilds.d.ts +5 -2
- package/lib/common/shorters/guilds.js +18 -0
- package/lib/common/shorters/messages.js +0 -2
- package/lib/common/shorters/overwrites.d.ts +29 -0
- package/lib/common/shorters/overwrites.js +63 -0
- package/lib/common/shorters/roles.js +3 -3
- package/lib/common/shorters/webhook.d.ts +2 -2
- package/lib/common/types/util.d.ts +2 -1
- package/lib/common/types/write.d.ts +3 -7
- package/lib/components/handler.d.ts +12 -18
- package/lib/components/handler.js +58 -103
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -1
- package/lib/components/listener.d.ts +2 -2
- package/lib/components/listener.js +2 -3
- package/lib/events/event.d.ts +2 -2
- package/lib/events/handler.d.ts +3 -2
- package/lib/events/handler.js +14 -6
- package/lib/events/hooks/dispatch.d.ts +2 -1
- package/lib/events/hooks/dispatch.js +5 -1
- package/lib/events/hooks/thread.d.ts +63 -63
- package/lib/index.d.ts +8 -5
- package/lib/index.js +20 -10
- package/lib/langs/handler.d.ts +6 -4
- package/lib/langs/handler.js +10 -8
- package/lib/langs/router.d.ts +8 -9
- package/lib/langs/router.js +5 -5
- package/lib/structures/ClientUser.d.ts +1 -16
- package/lib/structures/ClientUser.js +0 -31
- package/lib/structures/Guild.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +12 -0
- package/lib/structures/GuildMember.js +14 -0
- package/lib/structures/GuildRole.d.ts +4 -2
- package/lib/structures/GuildRole.js +4 -1
- package/lib/structures/GuildTemplate.js +1 -1
- package/lib/structures/Interaction.d.ts +2 -0
- package/lib/structures/Interaction.js +12 -13
- package/lib/structures/Message.d.ts +7 -2
- package/lib/structures/Message.js +6 -3
- package/lib/structures/Sticker.d.ts +1 -1
- package/lib/structures/Sticker.js +1 -1
- package/lib/structures/User.d.ts +5 -0
- package/lib/structures/User.js +3 -0
- package/lib/structures/Webhook.d.ts +1 -1
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +45 -6
- package/lib/structures/channels.js +23 -7
- package/lib/structures/extra/BitField.d.ts +9 -6
- package/lib/structures/extra/BitField.js +27 -3
- package/lib/structures/extra/Permissions.d.ts +6 -1
- package/lib/structures/extra/Permissions.js +7 -0
- package/lib/websocket/discord/basesocket.js +0 -1
- package/lib/websocket/discord/workermanager.d.ts +9 -1
- package/lib/websocket/discord/workermanager.js +21 -13
- package/package.json +21 -20
- package/lib/api/REST.d.ts +0 -127
- package/lib/api/REST.js +0 -424
- package/lib/api/errors/DiscordAPIError.d.ts +0 -51
- package/lib/api/errors/DiscordAPIError.js +0 -81
- package/lib/api/errors/HTTPError.d.ts +0 -20
- package/lib/api/errors/HTTPError.js +0 -28
- package/lib/api/errors/RateLimitError.d.ts +0 -19
- package/lib/api/errors/RateLimitError.js +0 -37
- package/lib/api/handlers/BurstHandler.d.ts +0 -51
- package/lib/api/handlers/BurstHandler.js +0 -124
- package/lib/api/handlers/SequentialHandler.d.ts +0 -81
- package/lib/api/handlers/SequentialHandler.js +0 -365
- package/lib/api/handlers/Shared.d.ts +0 -14
- package/lib/api/handlers/Shared.js +0 -125
- package/lib/api/interfaces/Handler.d.ts +0 -21
- package/lib/api/interfaces/Handler.js +0 -2
- package/lib/websocket/discord/handlemessage.d.ts +0 -0
- package/lib/websocket/discord/handlemessage.js +0 -1
- package/lib/websocket/discord/memberUpdate.d.ts +0 -16
- package/lib/websocket/discord/memberUpdate.js +0 -47
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseResource = void 0;
|
|
4
|
+
const common_1 = require("../../../common");
|
|
4
5
|
class BaseResource {
|
|
5
6
|
cache;
|
|
6
7
|
client;
|
|
@@ -21,52 +22,52 @@ class BaseResource {
|
|
|
21
22
|
get adapter() {
|
|
22
23
|
return this.cache.adapter;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
removeIfNI(intent, id) {
|
|
25
26
|
if (!this.cache.hasIntent(intent)) {
|
|
26
|
-
|
|
27
|
+
return this.remove(id);
|
|
27
28
|
}
|
|
29
|
+
return;
|
|
28
30
|
}
|
|
29
|
-
|
|
31
|
+
setIfNI(intent, id, data) {
|
|
30
32
|
if (!this.cache.hasIntent(intent)) {
|
|
31
|
-
|
|
32
|
-
return data;
|
|
33
|
+
return (0, common_1.fakePromise)(this.set(id, data)).then(() => data);
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
|
|
36
|
+
get(id) {
|
|
36
37
|
return this.adapter.get(this.hashId(id));
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
await this.adapter.set(this.hashId(id), data);
|
|
39
|
+
bulk(ids) {
|
|
40
|
+
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashId(id)))).then(x => x.filter(y => y));
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
await this.adapter.patch(false, this.hashId(id), data);
|
|
42
|
+
set(id, data) {
|
|
43
|
+
return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.set(this.hashId(id), data));
|
|
45
44
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
await this.adapter.remove(this.hashId(id));
|
|
45
|
+
patch(id, data) {
|
|
46
|
+
return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.patch(false, this.hashId(id), data));
|
|
49
47
|
}
|
|
50
|
-
|
|
48
|
+
remove(id) {
|
|
49
|
+
return (0, common_1.fakePromise)(this.removeToRelationship(id)).then(() => this.adapter.remove(this.hashId(id)));
|
|
50
|
+
}
|
|
51
|
+
keys() {
|
|
51
52
|
return this.adapter.keys(this.namespace);
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
+
values() {
|
|
54
55
|
return this.adapter.values(this.namespace);
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
count() {
|
|
57
58
|
return this.adapter.count(this.namespace);
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
contains(id) {
|
|
60
61
|
return this.adapter.contains(this.namespace, id);
|
|
61
62
|
}
|
|
62
|
-
|
|
63
|
+
getToRelationship() {
|
|
63
64
|
return this.adapter.getToRelationship(this.namespace);
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
|
|
66
|
+
addToRelationship(id) {
|
|
67
|
+
return this.adapter.addToRelationship(this.namespace, id);
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
removeToRelationship(id) {
|
|
70
|
+
return this.adapter.removeToRelationship(this.namespace, id);
|
|
70
71
|
}
|
|
71
72
|
hashId(id) {
|
|
72
73
|
return `${this.namespace}.${id}`;
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import type { BaseClient } from '../../../client/base';
|
|
2
|
-
import type
|
|
3
|
-
import type { Cache } from '../../index';
|
|
2
|
+
import { type GatewayIntentBits } from '../../../common';
|
|
3
|
+
import type { Cache, ReturnCache } from '../../index';
|
|
4
4
|
export declare class GuildBasedResource<T = any> {
|
|
5
5
|
protected cache: Cache;
|
|
6
6
|
client: BaseClient;
|
|
7
7
|
namespace: string;
|
|
8
8
|
constructor(cache: Cache, client?: BaseClient);
|
|
9
|
-
parse(data: any,
|
|
9
|
+
parse(data: any, id: string, guild_id: string): any;
|
|
10
10
|
get adapter(): import("../../index").Adapter;
|
|
11
|
-
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string):
|
|
12
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any):
|
|
13
|
-
get(id: string, guild: string):
|
|
11
|
+
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../index").RPV<void>;
|
|
12
|
+
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
|
|
13
|
+
get(id: string, guild: string): ReturnCache<(T & {
|
|
14
14
|
guild_id: string;
|
|
15
15
|
}) | undefined>;
|
|
16
|
-
|
|
17
|
-
set(__keys: [string, any][], guild: string): Promise<void>;
|
|
18
|
-
patch(__keys: string, guild: string, data: any): Promise<void>;
|
|
19
|
-
patch(__keys: [string, any][], guild: string): Promise<void>;
|
|
20
|
-
remove(id: string | string[], guild: string): Promise<void>;
|
|
21
|
-
keys(guild: string): Promise<string[]>;
|
|
22
|
-
values(guild: string): Promise<(T & {
|
|
16
|
+
bulk(ids: string[], guild: string): ReturnCache<(T & {
|
|
23
17
|
guild_id: string;
|
|
24
18
|
})[]>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
set(__keys: string, guild: string, data: any): ReturnCache<void>;
|
|
20
|
+
set(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
21
|
+
patch(__keys: string, guild: string, data: any): ReturnCache<void>;
|
|
22
|
+
patch(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
23
|
+
remove(id: string | string[], guild: string): import("../../index").RPV<void>;
|
|
24
|
+
keys(guild: string): ReturnCache<string[]>;
|
|
25
|
+
values(guild: string): ReturnCache<(T & {
|
|
26
|
+
guild_id: string;
|
|
27
|
+
})[]>;
|
|
28
|
+
count(guild: string): ReturnCache<number>;
|
|
29
|
+
contains(id: string, guild: string): ReturnCache<boolean>;
|
|
30
|
+
getToRelationship(guild: string): import("../../index").RPV<string[]>;
|
|
31
|
+
addToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
|
|
32
|
+
removeToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
|
|
33
|
+
removeRelationship(id: string | string[]): import("../../index").RPV<void>;
|
|
31
34
|
hashId(id: string): string;
|
|
32
35
|
hashGuildId(guild: string, id: string): string;
|
|
33
36
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GuildBasedResource = void 0;
|
|
4
|
+
const common_1 = require("../../../common");
|
|
4
5
|
class GuildBasedResource {
|
|
5
6
|
cache;
|
|
6
7
|
client;
|
|
@@ -15,71 +16,71 @@ class GuildBasedResource {
|
|
|
15
16
|
__setClient(client) {
|
|
16
17
|
this.client = client;
|
|
17
18
|
}
|
|
18
|
-
parse(data,
|
|
19
|
+
parse(data, id, guild_id) {
|
|
20
|
+
data.id = id;
|
|
19
21
|
data.guild_id = guild_id;
|
|
20
22
|
return data;
|
|
21
23
|
}
|
|
22
24
|
get adapter() {
|
|
23
25
|
return this.cache.adapter;
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
removeIfNI(intent, id, guildId) {
|
|
26
28
|
if (!this.cache.hasIntent(intent)) {
|
|
27
|
-
|
|
29
|
+
return this.remove(id, guildId);
|
|
28
30
|
}
|
|
31
|
+
return;
|
|
29
32
|
}
|
|
30
|
-
|
|
33
|
+
setIfNI(intent, id, guildId, data) {
|
|
31
34
|
if (!this.cache.hasIntent(intent)) {
|
|
32
|
-
|
|
33
|
-
return data;
|
|
35
|
+
return (0, common_1.fakePromise)(this.set(id, guildId, data)).then(() => data);
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
get(id, guild) {
|
|
37
39
|
return this.adapter.get(this.hashGuildId(id, guild));
|
|
38
40
|
}
|
|
39
|
-
|
|
41
|
+
bulk(ids, guild) {
|
|
42
|
+
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashGuildId(id, guild)))).then(x => x.filter(y => y));
|
|
43
|
+
}
|
|
44
|
+
set(__keys, guild, data) {
|
|
40
45
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
41
|
-
|
|
42
|
-
await this.adapter.set(keys.map(([key, value]) => {
|
|
46
|
+
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
43
47
|
return [this.hashGuildId(key, guild), this.parse(value, key, guild)];
|
|
44
|
-
}));
|
|
48
|
+
})));
|
|
45
49
|
}
|
|
46
|
-
|
|
50
|
+
patch(__keys, guild, data) {
|
|
47
51
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
48
|
-
|
|
49
|
-
await this.addToRelationship(keys.map(x => x[0]), guild);
|
|
50
|
-
await this.adapter.set(keys.map(([key, value]) => {
|
|
52
|
+
return (0, common_1.fakePromise)(this.adapter.get(keys.map(([key]) => this.hashGuildId(key, guild)))).then(oldDatas => (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
51
53
|
const oldData = oldDatas.find(x => x.id === key) ?? {};
|
|
52
54
|
return [this.hashGuildId(key, guild), this.parse({ ...oldData, ...value }, key, guild)];
|
|
53
|
-
}));
|
|
55
|
+
}))));
|
|
54
56
|
}
|
|
55
|
-
|
|
57
|
+
remove(id, guild) {
|
|
56
58
|
const ids = Array.isArray(id) ? id : [id];
|
|
57
|
-
|
|
58
|
-
await this.adapter.remove(ids.map(x => this.hashGuildId(x, guild)));
|
|
59
|
+
return (0, common_1.fakePromise)(this.removeToRelationship(ids, guild)).then(() => this.adapter.remove(ids.map(x => this.hashGuildId(x, guild))));
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
+
keys(guild) {
|
|
61
62
|
return this.adapter.scan(this.hashGuildId(guild, '*'), true);
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
+
values(guild) {
|
|
64
65
|
return this.adapter.scan(this.hashGuildId(guild, '*'));
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
return (
|
|
67
|
+
count(guild) {
|
|
68
|
+
return (0, common_1.fakePromise)(this.adapter.scan(this.hashGuildId(guild, '*'), true)).then(data => data.length);
|
|
68
69
|
}
|
|
69
|
-
|
|
70
|
+
contains(id, guild) {
|
|
70
71
|
return this.adapter.contains(this.hashId(guild), id);
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
getToRelationship(guild) {
|
|
73
74
|
return this.adapter.getToRelationship(this.hashId(guild));
|
|
74
75
|
}
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
addToRelationship(id, guild) {
|
|
77
|
+
return this.adapter.addToRelationship(this.hashId(guild), id);
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
removeToRelationship(id, guild) {
|
|
80
|
+
return this.adapter.removeToRelationship(this.hashId(guild), id);
|
|
80
81
|
}
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
removeRelationship(id) {
|
|
83
|
+
return this.adapter.removeRelationship((Array.isArray(id) ? id : [id]).map(x => this.hashId(x)));
|
|
83
84
|
}
|
|
84
85
|
hashId(id) {
|
|
85
86
|
return `${this.namespace}.${id}`;
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import type { BaseClient } from '../../../client/base';
|
|
2
|
-
import type
|
|
3
|
-
import type { Cache } from '../../index';
|
|
2
|
+
import { type GatewayIntentBits } from '../../../common';
|
|
3
|
+
import type { Cache, ReturnCache } from '../../index';
|
|
4
4
|
export declare class GuildRelatedResource<T = any> {
|
|
5
5
|
protected cache: Cache;
|
|
6
6
|
client: BaseClient;
|
|
7
7
|
namespace: string;
|
|
8
8
|
constructor(cache: Cache, client?: BaseClient);
|
|
9
|
-
parse(data: any,
|
|
9
|
+
parse(data: any, id: string, guild_id: string): any;
|
|
10
10
|
get adapter(): import("../../index").Adapter;
|
|
11
|
-
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string):
|
|
12
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any):
|
|
13
|
-
get(id: string):
|
|
11
|
+
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../index").RPV<void>;
|
|
12
|
+
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): any;
|
|
13
|
+
get(id: string): ReturnCache<(T & {
|
|
14
14
|
guild_id: string;
|
|
15
15
|
}) | undefined>;
|
|
16
|
-
|
|
17
|
-
set(__keys: [string, any][], guild: string): Promise<void>;
|
|
18
|
-
patch(__keys: string, guild?: string, data?: any): Promise<void>;
|
|
19
|
-
patch(__keys: [string, any][], guild?: string): Promise<void>;
|
|
20
|
-
remove(id: string | string[], guild: string): Promise<void>;
|
|
21
|
-
keys(guild: string): Promise<string[]>;
|
|
22
|
-
values(guild: string): Promise<(T & {
|
|
16
|
+
bulk(ids: string[]): ReturnCache<(T & {
|
|
23
17
|
guild_id: string;
|
|
24
18
|
})[]>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
set(__keys: string, guild: string, data: any): ReturnCache<void>;
|
|
20
|
+
set(__keys: [string, any][], guild: string): ReturnCache<void>;
|
|
21
|
+
patch(__keys: string, guild?: string, data?: any): ReturnCache<void>;
|
|
22
|
+
patch(__keys: [string, any][], guild?: string): ReturnCache<void>;
|
|
23
|
+
remove(id: string | string[], guild: string): import("../../index").RPV<void>;
|
|
24
|
+
keys(guild: string): ReturnCache<string[]>;
|
|
25
|
+
values(guild: string): ReturnCache<(T & {
|
|
26
|
+
guild_id: string;
|
|
27
|
+
})[]>;
|
|
28
|
+
count(to: string): import("../../index").RPV<number>;
|
|
29
|
+
contains(id: string, guild: string): import("../../index").RPV<boolean>;
|
|
30
|
+
getToRelationship(guild: string): import("../../index").RPV<string[]>;
|
|
31
|
+
addToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
|
|
32
|
+
removeToRelationship(id: string | string[], guild: string): import("../../index").RPV<void>;
|
|
33
|
+
removeRelationship(id: string | string[]): import("../../index").RPV<void>;
|
|
31
34
|
hashId(id: string): string;
|
|
32
35
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GuildRelatedResource = void 0;
|
|
4
|
+
const common_1 = require("../../../common");
|
|
4
5
|
class GuildRelatedResource {
|
|
5
6
|
cache;
|
|
6
7
|
client;
|
|
@@ -15,85 +16,78 @@ class GuildRelatedResource {
|
|
|
15
16
|
__setClient(client) {
|
|
16
17
|
this.client = client;
|
|
17
18
|
}
|
|
18
|
-
parse(data,
|
|
19
|
+
parse(data, id, guild_id) {
|
|
20
|
+
data.id = id;
|
|
19
21
|
data.guild_id = guild_id;
|
|
20
22
|
return data;
|
|
21
23
|
}
|
|
22
24
|
get adapter() {
|
|
23
25
|
return this.cache.adapter;
|
|
24
26
|
}
|
|
25
|
-
|
|
27
|
+
removeIfNI(intent, id, guildId) {
|
|
26
28
|
if (!this.cache.hasIntent(intent)) {
|
|
27
|
-
|
|
29
|
+
return this.remove(id, guildId);
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
|
-
|
|
32
|
+
setIfNI(intent, id, guildId, data) {
|
|
31
33
|
if (!this.cache.hasIntent(intent)) {
|
|
32
|
-
|
|
33
|
-
return data;
|
|
34
|
+
return (0, common_1.fakePromise)(this.set(id, guildId, data)).then(() => data);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
get(id) {
|
|
37
38
|
return this.adapter.get(this.hashId(id));
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
bulk(ids) {
|
|
41
|
+
return (0, common_1.fakePromise)(this.adapter.get(ids.map(x => this.hashId(x)))).then(x => x.filter(y => y));
|
|
42
|
+
}
|
|
43
|
+
set(__keys, guild, data) {
|
|
40
44
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
41
|
-
|
|
42
|
-
await this.adapter.set(keys.map(([key, value]) => {
|
|
45
|
+
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
43
46
|
return [this.hashId(key), this.parse(value, key, guild)];
|
|
44
|
-
}));
|
|
47
|
+
})));
|
|
45
48
|
}
|
|
46
|
-
|
|
49
|
+
patch(__keys, guild, data) {
|
|
47
50
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
48
51
|
if (guild) {
|
|
49
|
-
|
|
50
|
-
await this.adapter.patch(false, keys.map(([key, value]) => {
|
|
52
|
+
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.patch(false, keys.map(([key, value]) => {
|
|
51
53
|
return [this.hashId(key), this.parse(value, key, guild)];
|
|
52
|
-
}));
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
await this.adapter.patch(true, keys.map(([key, value]) => {
|
|
56
|
-
return [this.hashId(key), value];
|
|
57
|
-
}));
|
|
54
|
+
})));
|
|
58
55
|
}
|
|
56
|
+
return (0, common_1.fakePromise)(this.adapter.patch(true, keys.map(([key, value]) => {
|
|
57
|
+
return [this.hashId(key), value];
|
|
58
|
+
}))).then(x => x);
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
remove(id, guild) {
|
|
61
61
|
const ids = Array.isArray(id) ? id : [id];
|
|
62
|
-
|
|
63
|
-
await this.adapter.remove(ids.map(x => this.hashId(x)));
|
|
62
|
+
return (0, common_1.fakePromise)(this.removeToRelationship(ids, guild)).then(() => this.adapter.remove(ids.map(x => this.hashId(x))));
|
|
64
63
|
}
|
|
65
|
-
|
|
64
|
+
keys(guild) {
|
|
66
65
|
return guild === '*'
|
|
67
|
-
?
|
|
68
|
-
: (
|
|
69
|
-
return (await this.adapter.getToRelationship(this.hashId(guild))).map(x => `${this.namespace}.${x}`);
|
|
70
|
-
})();
|
|
66
|
+
? this.adapter.scan(this.hashId(guild), true)
|
|
67
|
+
: (0, common_1.fakePromise)(this.adapter.getToRelationship(this.hashId(guild))).then(keys => keys.map(x => `${this.namespace}.${x}`));
|
|
71
68
|
}
|
|
72
|
-
|
|
69
|
+
values(guild) {
|
|
73
70
|
return guild === '*'
|
|
74
|
-
?
|
|
75
|
-
: (
|
|
76
|
-
const keys = (await this.adapter.getToRelationship(this.hashId(guild))).map(x => `${this.namespace}.${x}`);
|
|
77
|
-
return this.adapter.get(keys);
|
|
78
|
-
})();
|
|
71
|
+
? (0, common_1.fakePromise)(this.adapter.scan(this.hashId(guild))).then(x => x)
|
|
72
|
+
: (0, common_1.fakePromise)(this.adapter.getToRelationship(this.hashId(guild))).then(keys => this.adapter.get(keys.map(x => `${this.namespace}.${x}`)));
|
|
79
73
|
}
|
|
80
|
-
|
|
74
|
+
count(to) {
|
|
81
75
|
return this.adapter.count(this.hashId(to));
|
|
82
76
|
}
|
|
83
|
-
|
|
77
|
+
contains(id, guild) {
|
|
84
78
|
return this.adapter.contains(this.hashId(guild), id);
|
|
85
79
|
}
|
|
86
|
-
|
|
80
|
+
getToRelationship(guild) {
|
|
87
81
|
return this.adapter.getToRelationship(this.hashId(guild));
|
|
88
82
|
}
|
|
89
|
-
|
|
90
|
-
|
|
83
|
+
addToRelationship(id, guild) {
|
|
84
|
+
return this.adapter.addToRelationship(this.hashId(guild), id);
|
|
91
85
|
}
|
|
92
|
-
|
|
93
|
-
|
|
86
|
+
removeToRelationship(id, guild) {
|
|
87
|
+
return this.adapter.removeToRelationship(this.hashId(guild), id);
|
|
94
88
|
}
|
|
95
|
-
|
|
96
|
-
|
|
89
|
+
removeRelationship(id) {
|
|
90
|
+
return this.adapter.removeRelationship((Array.isArray(id) ? id : [id]).map(x => this.hashId(x)));
|
|
97
91
|
}
|
|
98
92
|
hashId(id) {
|
|
99
93
|
return `${this.namespace}.${id}`;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { ReturnCache } from '../..';
|
|
1
2
|
import { GuildEmoji } from '../../structures';
|
|
2
3
|
import { GuildRelatedResource } from './default/guild-related';
|
|
3
4
|
export declare class Emojis extends GuildRelatedResource {
|
|
4
5
|
namespace: string;
|
|
5
|
-
get(id: string):
|
|
6
|
-
|
|
6
|
+
get(id: string): ReturnCache<GuildEmoji | undefined>;
|
|
7
|
+
bulk(ids: string[]): ReturnCache<GuildEmoji[]>;
|
|
8
|
+
values(guild: string): ReturnCache<GuildEmoji[]>;
|
|
7
9
|
}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Emojis = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
4
5
|
const structures_1 = require("../../structures");
|
|
5
6
|
const guild_related_1 = require("./default/guild-related");
|
|
6
7
|
class Emojis extends guild_related_1.GuildRelatedResource {
|
|
7
8
|
namespace = 'emoji';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return rawEmoji ? new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id) : undefined;
|
|
9
|
+
get(id) {
|
|
10
|
+
return (0, common_1.fakePromise)(super.get(id)).then(rawEmoji => rawEmoji ? new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id) : undefined);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
bulk(ids) {
|
|
13
|
+
return (0, common_1.fakePromise)(super.bulk(ids)).then(emojis => emojis.map(rawEmoji => new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id)));
|
|
14
|
+
}
|
|
15
|
+
values(guild) {
|
|
16
|
+
return (0, common_1.fakePromise)(super.values(guild)).then(emojis => emojis.map(rawEmoji => new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id)));
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
exports.Emojis = Emojis;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import type { ReturnCache } from '..';
|
|
1
2
|
import { Guild } from '../../structures';
|
|
2
3
|
import { BaseResource } from './default/base';
|
|
3
4
|
export declare class Guilds extends BaseResource {
|
|
4
5
|
namespace: string;
|
|
5
|
-
get(id: string):
|
|
6
|
-
|
|
6
|
+
get(id: string): ReturnCache<Guild<'cached'> | undefined>;
|
|
7
|
+
bulk(ids: string[]): ReturnCache<Guild<'cached'>[]>;
|
|
8
|
+
values(): ReturnCache<Guild<'cached'>[]>;
|
|
7
9
|
remove(id: string): Promise<void>;
|
|
8
10
|
set(id: string, data: any): Promise<void>;
|
|
9
11
|
patch(id: string, data: any): Promise<void>;
|
|
@@ -6,16 +6,17 @@ 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
|
-
|
|
10
|
-
|
|
11
|
-
return guild ? new structures_1.Guild(this.client, guild) : undefined;
|
|
9
|
+
get(id) {
|
|
10
|
+
return (0, common_1.fakePromise)(super.get(id)).then(guild => (guild ? new structures_1.Guild(this.client, guild) : undefined));
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
bulk(ids) {
|
|
13
|
+
return (0, common_1.fakePromise)(super.bulk(ids)).then(guilds => guilds.map(x => new structures_1.Guild(this.client, x)));
|
|
14
|
+
}
|
|
15
|
+
values() {
|
|
16
|
+
return (0, common_1.fakePromise)(super.values()).then(guilds => guilds.map(x => new structures_1.Guild(this.client, x)));
|
|
16
17
|
}
|
|
17
18
|
async remove(id) {
|
|
18
|
-
await this.cache.adapter.remove((
|
|
19
|
+
await this.cache.adapter.remove((await Promise.all([
|
|
19
20
|
this.cache.members?.keys(id) ?? [],
|
|
20
21
|
this.cache.roles?.keys(id) ?? [],
|
|
21
22
|
this.cache.channels?.keys(id) ?? [],
|
|
@@ -25,7 +26,7 @@ class Guilds extends base_1.BaseResource {
|
|
|
25
26
|
this.cache.presences?.keys(id) ?? [],
|
|
26
27
|
this.cache.threads?.keys(id) ?? [],
|
|
27
28
|
this.cache.stageInstances?.keys(id) ?? [],
|
|
28
|
-
])));
|
|
29
|
+
])).flat());
|
|
29
30
|
await this.cache.adapter.removeRelationship([
|
|
30
31
|
this.cache.members?.hashId(id),
|
|
31
32
|
this.cache.roles?.hashId(id),
|
|
@@ -53,6 +54,8 @@ class Guilds extends base_1.BaseResource {
|
|
|
53
54
|
}
|
|
54
55
|
for (const channel of data.channels ?? []) {
|
|
55
56
|
bulkData.push(['channels', channel, channel.id, id]);
|
|
57
|
+
if (channel.permission_overwrites?.length)
|
|
58
|
+
bulkData.push(['overwrites', channel.permission_overwrites, channel.id, id]);
|
|
56
59
|
}
|
|
57
60
|
for (const emoji of data.emojis ?? []) {
|
|
58
61
|
bulkData.push(['emojis', emoji, emoji.id, id]);
|
|
@@ -91,6 +94,10 @@ class Guilds extends base_1.BaseResource {
|
|
|
91
94
|
for (const channel of data.channels ?? []) {
|
|
92
95
|
bulkData.push(['channels', channel, channel.id, id]);
|
|
93
96
|
}
|
|
97
|
+
for (const channel of data.channels ?? []) {
|
|
98
|
+
if (channel.permission_overwrites?.length)
|
|
99
|
+
bulkData.push(['overwrites', channel.permission_overwrites, channel.id, id]);
|
|
100
|
+
}
|
|
94
101
|
for (const emoji of data.emojis ?? []) {
|
|
95
102
|
bulkData.push(['emojis', emoji, emoji.id, id]);
|
|
96
103
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { ReturnCache } from '../..';
|
|
1
2
|
import { GuildMember } from '../../structures';
|
|
2
3
|
import { GuildBasedResource } from './default/guild-based';
|
|
3
4
|
export declare class Members extends GuildBasedResource {
|
|
4
5
|
namespace: string;
|
|
5
6
|
parse(data: any, key: string, guild_id: string): any;
|
|
6
|
-
get(id: string, guild: string):
|
|
7
|
-
|
|
7
|
+
get(id: string, guild: string): ReturnCache<GuildMember | undefined>;
|
|
8
|
+
bulk(ids: string[], guild: string): ReturnCache<GuildMember[]>;
|
|
9
|
+
values(guild: string): ReturnCache<GuildMember[]>;
|
|
8
10
|
set(memberId: string, guildId: string, data: any): Promise<void>;
|
|
9
11
|
set(memberId_dataArray: [string, any][], guildId: string): Promise<void>;
|
|
10
12
|
}
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Members = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
4
5
|
const structures_1 = require("../../structures");
|
|
5
6
|
const guild_based_1 = require("./default/guild-based");
|
|
6
7
|
class Members extends guild_based_1.GuildBasedResource {
|
|
7
8
|
namespace = 'member';
|
|
8
9
|
parse(data, key, guild_id) {
|
|
9
|
-
data.
|
|
10
|
-
|
|
11
|
-
const { user, ...obj } = data;
|
|
12
|
-
return obj;
|
|
10
|
+
const { user, ...rest } = super.parse(data, data.user?.id ?? key, guild_id);
|
|
11
|
+
return rest;
|
|
13
12
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const user = await this.client.cache.users?.get(id);
|
|
17
|
-
return rawMember && user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
|
|
13
|
+
get(id, guild) {
|
|
14
|
+
return (0, common_1.fakePromise)(super.get(id, guild)).then(rawMember => (0, common_1.fakePromise)(this.client.cache.users?.get(id)).then(user => rawMember && user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined));
|
|
18
15
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const users = (await this.client.cache.users?.values()) ?? [];
|
|
22
|
-
return members
|
|
16
|
+
bulk(ids, guild) {
|
|
17
|
+
return (0, common_1.fakePromise)(super.bulk(ids, guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.bulk(ids) ?? []).then(users => members
|
|
23
18
|
.map(rawMember => {
|
|
24
19
|
const user = users.find(x => x.id === rawMember.id);
|
|
25
20
|
return user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
|
|
26
21
|
})
|
|
27
|
-
.filter(Boolean);
|
|
22
|
+
.filter(Boolean)));
|
|
23
|
+
}
|
|
24
|
+
values(guild) {
|
|
25
|
+
return (0, common_1.fakePromise)(super.values(guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.values() ?? []).then(users => members
|
|
26
|
+
.map(rawMember => {
|
|
27
|
+
const user = users.find(x => x.id === rawMember.id);
|
|
28
|
+
return user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
|
|
29
|
+
})
|
|
30
|
+
.filter(Boolean)));
|
|
28
31
|
}
|
|
29
32
|
async set(__keys, guild, data) {
|
|
30
33
|
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReturnCache } from '../..';
|
|
2
|
+
import { PermissionsBitField } from '../../structures/extra/Permissions';
|
|
3
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
4
|
+
export declare class Overwrites extends GuildRelatedResource {
|
|
5
|
+
namespace: string;
|
|
6
|
+
parse(data: any, _id: string, _guild_id: string): any;
|
|
7
|
+
get(id: string): ReturnCache<{
|
|
8
|
+
type: number;
|
|
9
|
+
id: string;
|
|
10
|
+
deny: PermissionsBitField;
|
|
11
|
+
allow: PermissionsBitField;
|
|
12
|
+
}[] | undefined>;
|
|
13
|
+
values(guild: string): ReturnCache<{
|
|
14
|
+
type: number;
|
|
15
|
+
id: string;
|
|
16
|
+
deny: PermissionsBitField;
|
|
17
|
+
allow: PermissionsBitField;
|
|
18
|
+
}[][]>;
|
|
19
|
+
bulk(ids: string[]): ReturnCache<{
|
|
20
|
+
type: number;
|
|
21
|
+
id: string;
|
|
22
|
+
deny: PermissionsBitField;
|
|
23
|
+
allow: PermissionsBitField;
|
|
24
|
+
}[][]>;
|
|
25
|
+
}
|