seyfert 0.1.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 -0
- package/README.md +57 -0
- package/lib/api/CDN.d.ts +220 -0
- package/lib/api/CDN.js +236 -0
- package/lib/api/REST.d.ts +127 -0
- package/lib/api/REST.js +424 -0
- package/lib/api/Router.d.ts +17 -0
- package/lib/api/Router.js +63 -0
- package/lib/api/Routes/applications.d.ts +46 -0
- package/lib/api/Routes/applications.js +2 -0
- package/lib/api/Routes/cdn.d.ts +66 -0
- package/lib/api/Routes/cdn.js +2 -0
- package/lib/api/Routes/channels.d.ts +109 -0
- package/lib/api/Routes/channels.js +2 -0
- package/lib/api/Routes/gateway.d.ts +11 -0
- package/lib/api/Routes/gateway.js +2 -0
- package/lib/api/Routes/guilds.d.ts +171 -0
- package/lib/api/Routes/guilds.js +2 -0
- package/lib/api/Routes/index.d.ts +13 -0
- package/lib/api/Routes/index.js +17 -0
- package/lib/api/Routes/interactions.d.ts +14 -0
- package/lib/api/Routes/interactions.js +2 -0
- package/lib/api/Routes/invites.d.ts +9 -0
- package/lib/api/Routes/invites.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +13 -0
- package/lib/api/Routes/stage-instances.js +2 -0
- package/lib/api/Routes/stickers.d.ts +11 -0
- package/lib/api/Routes/stickers.js +2 -0
- package/lib/api/Routes/users.d.ts +35 -0
- package/lib/api/Routes/users.js +2 -0
- package/lib/api/Routes/voice.d.ts +10 -0
- package/lib/api/Routes/voice.js +2 -0
- package/lib/api/Routes/webhooks.d.ts +29 -0
- package/lib/api/Routes/webhooks.js +2 -0
- package/lib/api/errors/DiscordAPIError.d.ts +51 -0
- package/lib/api/errors/DiscordAPIError.js +81 -0
- package/lib/api/errors/HTTPError.d.ts +20 -0
- package/lib/api/errors/HTTPError.js +28 -0
- package/lib/api/errors/RateLimitError.d.ts +19 -0
- package/lib/api/errors/RateLimitError.js +37 -0
- package/lib/api/handlers/BurstHandler.d.ts +51 -0
- package/lib/api/handlers/BurstHandler.js +124 -0
- package/lib/api/handlers/SequentialHandler.d.ts +81 -0
- package/lib/api/handlers/SequentialHandler.js +365 -0
- package/lib/api/handlers/Shared.d.ts +14 -0
- package/lib/api/handlers/Shared.js +125 -0
- package/lib/api/index.d.ts +5 -0
- package/lib/api/index.js +21 -0
- package/lib/api/interfaces/Handler.d.ts +21 -0
- package/lib/api/interfaces/Handler.js +2 -0
- package/lib/api/shared.d.ts +7 -0
- package/lib/api/shared.js +27 -0
- package/lib/api/utils/constants.d.ts +39 -0
- package/lib/api/utils/constants.js +50 -0
- package/lib/api/utils/types.d.ts +335 -0
- package/lib/api/utils/types.js +14 -0
- package/lib/api/utils/utils.d.ts +52 -0
- package/lib/api/utils/utils.js +159 -0
- package/lib/builders/ActionRow.d.ts +40 -0
- package/lib/builders/ActionRow.js +58 -0
- package/lib/builders/Attachment.d.ts +106 -0
- package/lib/builders/Attachment.js +196 -0
- package/lib/builders/Base.d.ts +10 -0
- package/lib/builders/Base.js +13 -0
- package/lib/builders/Button.d.ts +59 -0
- package/lib/builders/Button.js +94 -0
- package/lib/builders/MessageEmbed.d.ts +116 -0
- package/lib/builders/MessageEmbed.js +159 -0
- package/lib/builders/Modal.d.ts +111 -0
- package/lib/builders/Modal.js +162 -0
- package/lib/builders/SelectMenu.d.ts +201 -0
- package/lib/builders/SelectMenu.js +293 -0
- package/lib/builders/index.d.ts +12 -0
- package/lib/builders/index.js +54 -0
- package/lib/builders/types.d.ts +21 -0
- package/lib/builders/types.js +2 -0
- package/lib/cache/adapters/default.d.ts +24 -0
- package/lib/cache/adapters/default.js +118 -0
- package/lib/cache/adapters/index.d.ts +4 -0
- package/lib/cache/adapters/index.js +20 -0
- package/lib/cache/adapters/redis.d.ts +35 -0
- package/lib/cache/adapters/redis.js +180 -0
- package/lib/cache/adapters/types.d.ts +25 -0
- package/lib/cache/adapters/types.js +2 -0
- package/lib/cache/adapters/workeradapter.d.ts +24 -0
- package/lib/cache/adapters/workeradapter.js +76 -0
- package/lib/cache/index.d.ts +97 -0
- package/lib/cache/index.js +394 -0
- package/lib/cache/resources/channels.d.ts +7 -0
- package/lib/cache/resources/channels.js +20 -0
- package/lib/cache/resources/default/base.d.ts +25 -0
- package/lib/cache/resources/default/base.js +75 -0
- package/lib/cache/resources/default/guild-based.d.ts +33 -0
- package/lib/cache/resources/default/guild-based.js +91 -0
- package/lib/cache/resources/default/guild-related.d.ts +32 -0
- package/lib/cache/resources/default/guild-related.js +102 -0
- package/lib/cache/resources/emojis.d.ts +7 -0
- package/lib/cache/resources/emojis.js +17 -0
- package/lib/cache/resources/guilds.d.ts +10 -0
- package/lib/cache/resources/guilds.js +117 -0
- package/lib/cache/resources/members.d.ts +10 -0
- package/lib/cache/resources/members.js +41 -0
- package/lib/cache/resources/presence.d.ts +9 -0
- package/lib/cache/resources/presence.js +14 -0
- package/lib/cache/resources/roles.d.ts +7 -0
- package/lib/cache/resources/roles.js +17 -0
- package/lib/cache/resources/stage-instances.d.ts +5 -0
- package/lib/cache/resources/stage-instances.js +8 -0
- package/lib/cache/resources/stickers.d.ts +7 -0
- package/lib/cache/resources/stickers.js +17 -0
- package/lib/cache/resources/threads.d.ts +7 -0
- package/lib/cache/resources/threads.js +17 -0
- package/lib/cache/resources/users.d.ts +7 -0
- package/lib/cache/resources/users.js +17 -0
- package/lib/cache/resources/voice-states.d.ts +9 -0
- package/lib/cache/resources/voice-states.js +13 -0
- package/lib/client/base.d.ts +244 -0
- package/lib/client/base.js +178 -0
- package/lib/client/client.d.ts +32 -0
- package/lib/client/client.js +156 -0
- package/lib/client/httpclient.d.ts +21 -0
- package/lib/client/httpclient.js +143 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +19 -0
- package/lib/client/oninteraction.d.ts +4 -0
- package/lib/client/oninteraction.js +180 -0
- package/lib/client/workerclient.d.ts +28 -0
- package/lib/client/workerclient.js +213 -0
- package/lib/collection.d.ts +233 -0
- package/lib/collection.js +371 -0
- package/lib/commands/applications/chat.d.ts +139 -0
- package/lib/commands/applications/chat.js +173 -0
- package/lib/commands/applications/chatcontext.d.ts +28 -0
- package/lib/commands/applications/chatcontext.js +53 -0
- package/lib/commands/applications/menu.d.ts +39 -0
- package/lib/commands/applications/menu.js +87 -0
- package/lib/commands/applications/menucontext.d.ts +25 -0
- package/lib/commands/applications/menucontext.js +64 -0
- package/lib/commands/applications/options.d.ts +67 -0
- package/lib/commands/applications/options.js +44 -0
- package/lib/commands/applications/shared.d.ts +35 -0
- package/lib/commands/applications/shared.js +2 -0
- package/lib/commands/decorators.d.ts +107 -0
- package/lib/commands/decorators.js +85 -0
- package/lib/commands/handler.d.ts +15 -0
- package/lib/commands/handler.js +140 -0
- package/lib/commands/index.d.ts +8 -0
- package/lib/commands/index.js +24 -0
- package/lib/commands/optionresolver.d.ts +49 -0
- package/lib/commands/optionresolver.js +146 -0
- package/lib/common/bot/watcher.d.ts +53 -0
- package/lib/common/bot/watcher.js +104 -0
- package/lib/common/index.d.ts +13 -0
- package/lib/common/index.js +30 -0
- package/lib/common/it/colors.d.ts +274 -0
- package/lib/common/it/colors.js +453 -0
- package/lib/common/it/constants.d.ts +36 -0
- package/lib/common/it/constants.js +40 -0
- package/lib/common/it/logger.d.ts +114 -0
- package/lib/common/it/logger.js +189 -0
- package/lib/common/it/utils.d.ts +107 -0
- package/lib/common/it/utils.js +275 -0
- package/lib/common/shorters/base.d.ts +5 -0
- package/lib/common/shorters/base.js +10 -0
- package/lib/common/shorters/channels.d.ts +90 -0
- package/lib/common/shorters/channels.js +95 -0
- package/lib/common/shorters/guilds.d.ts +389 -0
- package/lib/common/shorters/guilds.js +350 -0
- package/lib/common/shorters/members.d.ts +115 -0
- package/lib/common/shorters/members.js +179 -0
- package/lib/common/shorters/messages.d.ts +27 -0
- package/lib/common/shorters/messages.js +117 -0
- package/lib/common/shorters/roles.d.ts +12 -0
- package/lib/common/shorters/roles.js +51 -0
- package/lib/common/shorters/templates.d.ts +12 -0
- package/lib/common/shorters/templates.js +29 -0
- package/lib/common/shorters/users.d.ts +11 -0
- package/lib/common/shorters/users.js +42 -0
- package/lib/common/shorters/webhook.d.ts +33 -0
- package/lib/common/shorters/webhook.js +69 -0
- package/lib/common/types/options.d.ts +10 -0
- package/lib/common/types/options.js +2 -0
- package/lib/common/types/resolvables.d.ts +10 -0
- package/lib/common/types/resolvables.js +2 -0
- package/lib/common/types/util.d.ts +90 -0
- package/lib/common/types/util.js +2 -0
- package/lib/common/types/write.d.ts +21 -0
- package/lib/common/types/write.js +2 -0
- package/lib/components/ActionRow.d.ts +10 -0
- package/lib/components/ActionRow.js +13 -0
- package/lib/components/ButtonComponent.d.ts +19 -0
- package/lib/components/ButtonComponent.js +34 -0
- package/lib/components/ChannelSelectMenuComponent.d.ts +6 -0
- package/lib/components/ChannelSelectMenuComponent.js +12 -0
- package/lib/components/MentionableSelectMenuComponent.d.ts +4 -0
- package/lib/components/MentionableSelectMenuComponent.js +7 -0
- package/lib/components/RoleSelectMenuComponent.d.ts +4 -0
- package/lib/components/RoleSelectMenuComponent.js +7 -0
- package/lib/components/StringSelectMenuComponent.d.ts +6 -0
- package/lib/components/StringSelectMenuComponent.js +12 -0
- package/lib/components/TextInputComponent.d.ts +7 -0
- package/lib/components/TextInputComponent.js +14 -0
- package/lib/components/UserSelectMenuComponent.d.ts +4 -0
- package/lib/components/UserSelectMenuComponent.js +7 -0
- package/lib/components/command.d.ts +23 -0
- package/lib/components/command.js +15 -0
- package/lib/components/handler.d.ts +48 -0
- package/lib/components/handler.js +231 -0
- package/lib/components/index.d.ts +20 -0
- package/lib/components/index.js +55 -0
- package/lib/components/listener.d.ts +11 -0
- package/lib/components/listener.js +18 -0
- package/lib/events/event.d.ts +23 -0
- package/lib/events/event.js +2 -0
- package/lib/events/handler.d.ts +19 -0
- package/lib/events/handler.js +112 -0
- package/lib/events/hooks/application_command.d.ts +12 -0
- package/lib/events/hooks/application_command.js +8 -0
- package/lib/events/hooks/auto_moderation.d.ts +22 -0
- package/lib/events/hooks/auto_moderation.js +21 -0
- package/lib/events/hooks/channel.d.ts +11 -0
- package/lib/events/hooks/channel.js +24 -0
- package/lib/events/hooks/custom.d.ts +4 -0
- package/lib/events/hooks/custom.js +11 -0
- package/lib/events/hooks/dispatch.d.ts +5 -0
- package/lib/events/hooks/dispatch.js +12 -0
- package/lib/events/hooks/entitlement.d.ts +35 -0
- package/lib/events/hooks/entitlement.js +16 -0
- package/lib/events/hooks/guild.d.ts +228 -0
- package/lib/events/hooks/guild.js +101 -0
- package/lib/events/hooks/index.d.ts +23 -0
- package/lib/events/hooks/index.js +34 -0
- package/lib/events/hooks/integration.d.ts +94 -0
- package/lib/events/hooks/integration.js +27 -0
- package/lib/events/hooks/interactions.d.ts +4 -0
- package/lib/events/hooks/interactions.js +8 -0
- package/lib/events/hooks/invite.d.ts +21 -0
- package/lib/events/hooks/invite.js +12 -0
- package/lib/events/hooks/message.d.ts +69 -0
- package/lib/events/hooks/message.js +37 -0
- package/lib/events/hooks/presence.d.ts +27 -0
- package/lib/events/hooks/presence.js +8 -0
- package/lib/events/hooks/stage.d.ts +29 -0
- package/lib/events/hooks/stage.js +16 -0
- package/lib/events/hooks/thread.d.ts +198 -0
- package/lib/events/hooks/thread.js +29 -0
- package/lib/events/hooks/typing.d.ts +16 -0
- package/lib/events/hooks/typing.js +14 -0
- package/lib/events/hooks/user.d.ts +4 -0
- package/lib/events/hooks/user.js +8 -0
- package/lib/events/hooks/voice.d.ts +37 -0
- package/lib/events/hooks/voice.js +18 -0
- package/lib/events/hooks/webhook.d.ts +6 -0
- package/lib/events/hooks/webhook.js +8 -0
- package/lib/events/index.d.ts +2 -0
- package/lib/events/index.js +18 -0
- package/lib/index.d.ts +79 -0
- package/lib/index.js +104 -0
- package/lib/langs/handler.d.ts +11 -0
- package/lib/langs/handler.js +34 -0
- package/lib/langs/index.d.ts +2 -0
- package/lib/langs/index.js +18 -0
- package/lib/langs/router.d.ts +18 -0
- package/lib/langs/router.js +42 -0
- package/lib/structures/AnonymousGuild.d.ts +7 -0
- package/lib/structures/AnonymousGuild.js +11 -0
- package/lib/structures/AutoModerationRule.d.ts +22 -0
- package/lib/structures/AutoModerationRule.js +34 -0
- package/lib/structures/ClientUser.d.ts +25 -0
- package/lib/structures/ClientUser.js +52 -0
- package/lib/structures/Guild.d.ts +86 -0
- package/lib/structures/Guild.js +66 -0
- package/lib/structures/GuildEmoji.d.ts +29 -0
- package/lib/structures/GuildEmoji.js +47 -0
- package/lib/structures/GuildMember.d.ts +92 -0
- package/lib/structures/GuildMember.js +137 -0
- package/lib/structures/GuildPreview.d.ts +10 -0
- package/lib/structures/GuildPreview.js +14 -0
- package/lib/structures/GuildRole.d.ts +21 -0
- package/lib/structures/GuildRole.js +32 -0
- package/lib/structures/GuildTemplate.d.ts +23 -0
- package/lib/structures/GuildTemplate.js +36 -0
- package/lib/structures/Interaction.d.ts +152 -0
- package/lib/structures/Interaction.js +409 -0
- package/lib/structures/Message.d.ts +53 -0
- package/lib/structures/Message.js +123 -0
- package/lib/structures/Sticker.d.ts +27 -0
- package/lib/structures/Sticker.js +44 -0
- package/lib/structures/User.d.ts +20 -0
- package/lib/structures/User.js +37 -0
- package/lib/structures/Webhook.d.ts +42 -0
- package/lib/structures/Webhook.js +63 -0
- package/lib/structures/channels.d.ts +232 -0
- package/lib/structures/channels.js +366 -0
- package/lib/structures/extra/Base.d.ts +7 -0
- package/lib/structures/extra/Base.js +39 -0
- package/lib/structures/extra/BaseComponent.d.ts +9 -0
- package/lib/structures/extra/BaseComponent.js +12 -0
- package/lib/structures/extra/BaseGuild.d.ts +40 -0
- package/lib/structures/extra/BaseGuild.js +71 -0
- package/lib/structures/extra/BaseSelectMenuComponent.d.ts +9 -0
- package/lib/structures/extra/BaseSelectMenuComponent.js +13 -0
- package/lib/structures/extra/BitField.d.ts +14 -0
- package/lib/structures/extra/BitField.js +56 -0
- package/lib/structures/extra/DiscordBase.d.ts +18 -0
- package/lib/structures/extra/DiscordBase.js +28 -0
- package/lib/structures/extra/Permissions.d.ts +54 -0
- package/lib/structures/extra/Permissions.js +9 -0
- package/lib/structures/extra/functions.d.ts +11 -0
- package/lib/structures/extra/functions.js +69 -0
- package/lib/structures/index.d.ts +15 -0
- package/lib/structures/index.js +31 -0
- package/lib/websocket/SharedTypes.d.ts +128 -0
- package/lib/websocket/SharedTypes.js +2 -0
- package/lib/websocket/constants/index.d.ts +26 -0
- package/lib/websocket/constants/index.js +31 -0
- package/lib/websocket/discord/basesocket.d.ts +12 -0
- package/lib/websocket/discord/basesocket.js +37 -0
- package/lib/websocket/discord/events/memberUpdate.d.ts +16 -0
- package/lib/websocket/discord/events/memberUpdate.js +47 -0
- package/lib/websocket/discord/events/presenceUpdate.d.ts +24 -0
- package/lib/websocket/discord/events/presenceUpdate.js +46 -0
- package/lib/websocket/discord/handlemessage.d.ts +0 -0
- package/lib/websocket/discord/handlemessage.js +1 -0
- package/lib/websocket/discord/index.d.ts +4 -0
- package/lib/websocket/discord/index.js +20 -0
- package/lib/websocket/discord/memberUpdate.d.ts +16 -0
- package/lib/websocket/discord/memberUpdate.js +47 -0
- package/lib/websocket/discord/shard.d.ts +46 -0
- package/lib/websocket/discord/shard.js +278 -0
- package/lib/websocket/discord/sharder.d.ts +25 -0
- package/lib/websocket/discord/sharder.js +153 -0
- package/lib/websocket/discord/shared.d.ts +99 -0
- package/lib/websocket/discord/shared.js +8 -0
- package/lib/websocket/discord/worker.d.ts +43 -0
- package/lib/websocket/discord/worker.js +2 -0
- package/lib/websocket/discord/workermanager.d.ts +69 -0
- package/lib/websocket/discord/workermanager.js +273 -0
- package/lib/websocket/index.d.ts +3 -0
- package/lib/websocket/index.js +19 -0
- package/lib/websocket/structures/index.d.ts +117 -0
- package/lib/websocket/structures/index.js +261 -0
- package/lib/websocket/structures/timeout.d.ts +20 -0
- package/lib/websocket/structures/timeout.js +75 -0
- package/package.json +70 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuildRelatedResource = void 0;
|
|
4
|
+
class GuildRelatedResource {
|
|
5
|
+
cache;
|
|
6
|
+
client;
|
|
7
|
+
namespace = 'base';
|
|
8
|
+
constructor(cache, client) {
|
|
9
|
+
this.cache = cache;
|
|
10
|
+
if (client) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** @internal */
|
|
15
|
+
__setClient(client) {
|
|
16
|
+
this.client = client;
|
|
17
|
+
}
|
|
18
|
+
parse(data, _id, guild_id) {
|
|
19
|
+
data.guild_id = guild_id;
|
|
20
|
+
return data;
|
|
21
|
+
}
|
|
22
|
+
get adapter() {
|
|
23
|
+
return this.cache.adapter;
|
|
24
|
+
}
|
|
25
|
+
async removeIfNI(intent, id, guildId) {
|
|
26
|
+
if (!this.cache.hasIntent(intent)) {
|
|
27
|
+
await this.remove(id, guildId);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async setIfNI(intent, id, guildId, data) {
|
|
31
|
+
if (!this.cache.hasIntent(intent)) {
|
|
32
|
+
await this.set(id, guildId, data);
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async get(id) {
|
|
37
|
+
return this.adapter.get(this.hashId(id));
|
|
38
|
+
}
|
|
39
|
+
async set(__keys, guild, data) {
|
|
40
|
+
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
41
|
+
await this.addToRelationship(keys.map(x => x[0]), guild);
|
|
42
|
+
await this.adapter.set(keys.map(([key, value]) => {
|
|
43
|
+
return [this.hashId(key), this.parse(value, key, guild)];
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
async patch(__keys, guild, data) {
|
|
47
|
+
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
48
|
+
if (guild) {
|
|
49
|
+
await this.addToRelationship(keys.map(x => x[0]), guild);
|
|
50
|
+
await this.adapter.patch(false, keys.map(([key, value]) => {
|
|
51
|
+
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
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async remove(id, guild) {
|
|
61
|
+
const ids = Array.isArray(id) ? id : [id];
|
|
62
|
+
await this.removeToRelationship(ids, guild);
|
|
63
|
+
await this.adapter.remove(ids.map(x => this.hashId(x)));
|
|
64
|
+
}
|
|
65
|
+
async keys(guild) {
|
|
66
|
+
return guild === '*'
|
|
67
|
+
? await this.adapter.scan(this.hashId(guild), true)
|
|
68
|
+
: (async () => {
|
|
69
|
+
return (await this.adapter.getToRelationship(this.hashId(guild))).map(x => `${this.namespace}.${x}`);
|
|
70
|
+
})();
|
|
71
|
+
}
|
|
72
|
+
async values(guild) {
|
|
73
|
+
return guild === '*'
|
|
74
|
+
? await this.adapter.scan(this.hashId(guild))
|
|
75
|
+
: (async () => {
|
|
76
|
+
const keys = (await this.adapter.getToRelationship(this.hashId(guild))).map(x => `${this.namespace}.${x}`);
|
|
77
|
+
return this.adapter.get(keys);
|
|
78
|
+
})();
|
|
79
|
+
}
|
|
80
|
+
async count(to) {
|
|
81
|
+
return this.adapter.count(this.hashId(to));
|
|
82
|
+
}
|
|
83
|
+
async contains(id, guild) {
|
|
84
|
+
return this.adapter.contains(this.hashId(guild), id);
|
|
85
|
+
}
|
|
86
|
+
async getToRelationship(guild) {
|
|
87
|
+
return this.adapter.getToRelationship(this.hashId(guild));
|
|
88
|
+
}
|
|
89
|
+
async addToRelationship(id, guild) {
|
|
90
|
+
await this.adapter.addToRelationship(this.hashId(guild), id);
|
|
91
|
+
}
|
|
92
|
+
async removeToRelationship(id, guild) {
|
|
93
|
+
await this.adapter.removeToRelationship(this.hashId(guild), id);
|
|
94
|
+
}
|
|
95
|
+
async removeRelationship(id) {
|
|
96
|
+
await this.adapter.removeRelationship((Array.isArray(id) ? id : [id]).map(x => this.hashId(x)));
|
|
97
|
+
}
|
|
98
|
+
hashId(id) {
|
|
99
|
+
return `${this.namespace}.${id}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.GuildRelatedResource = GuildRelatedResource;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GuildEmoji } from '../../structures';
|
|
2
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
3
|
+
export declare class Emojis extends GuildRelatedResource {
|
|
4
|
+
namespace: string;
|
|
5
|
+
get(id: string): Promise<GuildEmoji | undefined>;
|
|
6
|
+
values(guild: string): Promise<GuildEmoji[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Emojis = void 0;
|
|
4
|
+
const structures_1 = require("../../structures");
|
|
5
|
+
const guild_related_1 = require("./default/guild-related");
|
|
6
|
+
class Emojis extends guild_related_1.GuildRelatedResource {
|
|
7
|
+
namespace = 'emoji';
|
|
8
|
+
async get(id) {
|
|
9
|
+
const rawEmoji = await super.get(id);
|
|
10
|
+
return rawEmoji ? new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id) : undefined;
|
|
11
|
+
}
|
|
12
|
+
async values(guild) {
|
|
13
|
+
const emojis = (await super.values(guild));
|
|
14
|
+
return emojis.map(rawEmoji => new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Emojis = Emojis;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Guild } from '../../structures';
|
|
2
|
+
import { BaseResource } from './default/base';
|
|
3
|
+
export declare class Guilds extends BaseResource {
|
|
4
|
+
namespace: string;
|
|
5
|
+
get(id: string): Promise<Guild<'cached'> | undefined>;
|
|
6
|
+
values(): Promise<Guild<"cached">[]>;
|
|
7
|
+
remove(id: string): Promise<void>;
|
|
8
|
+
set(id: string, data: any): Promise<void>;
|
|
9
|
+
patch(id: string, data: any): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Guilds = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const structures_1 = require("../../structures");
|
|
6
|
+
const base_1 = require("./default/base");
|
|
7
|
+
class Guilds extends base_1.BaseResource {
|
|
8
|
+
namespace = 'guild';
|
|
9
|
+
async get(id) {
|
|
10
|
+
const guild = (await super.get(id));
|
|
11
|
+
return guild ? new structures_1.Guild(this.client, guild) : undefined;
|
|
12
|
+
}
|
|
13
|
+
async values() {
|
|
14
|
+
const guilds = (await super.values());
|
|
15
|
+
return guilds.map(x => new structures_1.Guild(this.client, x));
|
|
16
|
+
}
|
|
17
|
+
async remove(id) {
|
|
18
|
+
await this.cache.adapter.remove((0, common_1.fastFlat)(await Promise.all([
|
|
19
|
+
this.cache.members?.keys(id) ?? [],
|
|
20
|
+
this.cache.roles?.keys(id) ?? [],
|
|
21
|
+
this.cache.channels?.keys(id) ?? [],
|
|
22
|
+
this.cache.emojis?.keys(id) ?? [],
|
|
23
|
+
this.cache.stickers?.keys(id) ?? [],
|
|
24
|
+
this.cache.voiceStates?.keys(id) ?? [],
|
|
25
|
+
this.cache.presences?.keys(id) ?? [],
|
|
26
|
+
this.cache.threads?.keys(id) ?? [],
|
|
27
|
+
this.cache.stageInstances?.keys(id) ?? [],
|
|
28
|
+
])));
|
|
29
|
+
await this.cache.adapter.removeRelationship([
|
|
30
|
+
this.cache.members?.hashId(id),
|
|
31
|
+
this.cache.roles?.hashId(id),
|
|
32
|
+
this.cache.channels?.hashId(id),
|
|
33
|
+
this.cache.emojis?.hashId(id),
|
|
34
|
+
this.cache.stickers?.hashId(id),
|
|
35
|
+
this.cache.voiceStates?.hashId(id),
|
|
36
|
+
this.cache.presences?.hashId(id),
|
|
37
|
+
this.cache.threads?.hashId(id),
|
|
38
|
+
this.cache.stageInstances?.hashId(id),
|
|
39
|
+
].filter(Boolean));
|
|
40
|
+
await super.remove(id);
|
|
41
|
+
}
|
|
42
|
+
async set(id, data) {
|
|
43
|
+
const bulkData = [];
|
|
44
|
+
for (const member of data.members ?? []) {
|
|
45
|
+
if (!member.user?.id) {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
bulkData.push(['members', member, member.user.id, id]);
|
|
49
|
+
bulkData.push(['users', member.user, member.user.id]);
|
|
50
|
+
}
|
|
51
|
+
for (const role of data.roles ?? []) {
|
|
52
|
+
bulkData.push(['roles', role, role.id, id]);
|
|
53
|
+
}
|
|
54
|
+
for (const channel of data.channels ?? []) {
|
|
55
|
+
bulkData.push(['channels', channel, channel.id, id]);
|
|
56
|
+
}
|
|
57
|
+
for (const emoji of data.emojis ?? []) {
|
|
58
|
+
bulkData.push(['emojis', emoji, emoji.id, id]);
|
|
59
|
+
}
|
|
60
|
+
for (const sticker of data.stickers ?? []) {
|
|
61
|
+
bulkData.push(['stickers', sticker, sticker.id, id]);
|
|
62
|
+
}
|
|
63
|
+
for (const voiceState of data.voice_states ?? []) {
|
|
64
|
+
bulkData.push(['voiceStates', voiceState, voiceState.user_id, id]);
|
|
65
|
+
}
|
|
66
|
+
for (const presence of data.presences ?? []) {
|
|
67
|
+
bulkData.push(['presences', presence, presence.user.id, id]);
|
|
68
|
+
}
|
|
69
|
+
for (const thread of data.threads ?? []) {
|
|
70
|
+
bulkData.push(['threads', thread, thread.id, id]);
|
|
71
|
+
}
|
|
72
|
+
for (const instance of data.stage_instances ?? []) {
|
|
73
|
+
bulkData.push(['stageInstances', instance, instance.id, id]);
|
|
74
|
+
}
|
|
75
|
+
const { voice_states, members, channels, threads, presences, stage_instances, guild_scheduled_events, roles, emojis, stickers, guild_hashes, ...guild } = data;
|
|
76
|
+
bulkData.push(['guilds', guild, id]);
|
|
77
|
+
await this.cache.bulkSet(bulkData);
|
|
78
|
+
}
|
|
79
|
+
async patch(id, data) {
|
|
80
|
+
const bulkData = [];
|
|
81
|
+
for (const member of data.members ?? []) {
|
|
82
|
+
if (!member.user?.id) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
bulkData.push(['members', member, member.user.id, id]);
|
|
86
|
+
bulkData.push(['users', member.user, member.user.id]);
|
|
87
|
+
}
|
|
88
|
+
for (const role of data.roles ?? []) {
|
|
89
|
+
bulkData.push(['roles', role, role.id, id]);
|
|
90
|
+
}
|
|
91
|
+
for (const channel of data.channels ?? []) {
|
|
92
|
+
bulkData.push(['channels', channel, channel.id, id]);
|
|
93
|
+
}
|
|
94
|
+
for (const emoji of data.emojis ?? []) {
|
|
95
|
+
bulkData.push(['emojis', emoji, emoji.id, id]);
|
|
96
|
+
}
|
|
97
|
+
for (const sticker of data.stickers ?? []) {
|
|
98
|
+
bulkData.push(['stickers', sticker, sticker.id, id]);
|
|
99
|
+
}
|
|
100
|
+
for (const voiceState of data.voice_states ?? []) {
|
|
101
|
+
bulkData.push(['voiceStates', voiceState, voiceState.user_id, id]);
|
|
102
|
+
}
|
|
103
|
+
for (const presence of data.presences ?? []) {
|
|
104
|
+
bulkData.push(['presences', presence, presence.user.id, id]);
|
|
105
|
+
}
|
|
106
|
+
for (const thread of data.threads ?? []) {
|
|
107
|
+
bulkData.push(['threads', thread, thread.id, id]);
|
|
108
|
+
}
|
|
109
|
+
for (const instance of data.stage_instances ?? []) {
|
|
110
|
+
bulkData.push(['stageInstances', instance, instance.id, id]);
|
|
111
|
+
}
|
|
112
|
+
const { voice_states, members, channels, threads, presences, stage_instances, guild_scheduled_events, roles, emojis, stickers, guild_hashes, ...guild } = data;
|
|
113
|
+
bulkData.push(['guilds', guild, id]);
|
|
114
|
+
await this.cache.bulkPatch(bulkData);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
exports.Guilds = Guilds;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { GuildMember } from '../../structures';
|
|
2
|
+
import { GuildBasedResource } from './default/guild-based';
|
|
3
|
+
export declare class Members extends GuildBasedResource {
|
|
4
|
+
namespace: string;
|
|
5
|
+
parse(data: any, key: string, guild_id: string): any;
|
|
6
|
+
get(id: string, guild: string): Promise<GuildMember | undefined>;
|
|
7
|
+
values(guild: string): Promise<GuildMember[]>;
|
|
8
|
+
set(memberId: string, guildId: string, data: any): Promise<void>;
|
|
9
|
+
set(memberId_dataArray: [string, any][], guildId: string): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Members = void 0;
|
|
4
|
+
const structures_1 = require("../../structures");
|
|
5
|
+
const guild_based_1 = require("./default/guild-based");
|
|
6
|
+
class Members extends guild_based_1.GuildBasedResource {
|
|
7
|
+
namespace = 'member';
|
|
8
|
+
parse(data, key, guild_id) {
|
|
9
|
+
data.guild_id = guild_id;
|
|
10
|
+
data.id = data.user?.id ?? key;
|
|
11
|
+
const { user, ...obj } = data;
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
async get(id, guild) {
|
|
15
|
+
const rawMember = (await super.get(id, guild));
|
|
16
|
+
const user = await this.client.cache.users?.get(id);
|
|
17
|
+
return rawMember && user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
|
|
18
|
+
}
|
|
19
|
+
async values(guild) {
|
|
20
|
+
const members = await super.values(guild);
|
|
21
|
+
const users = (await this.client.cache.users?.values()) ?? [];
|
|
22
|
+
return members
|
|
23
|
+
.map(rawMember => {
|
|
24
|
+
const user = users.find(x => x.id === rawMember.id);
|
|
25
|
+
return user ? new structures_1.GuildMember(this.client, rawMember, user, guild) : undefined;
|
|
26
|
+
})
|
|
27
|
+
.filter(Boolean);
|
|
28
|
+
}
|
|
29
|
+
async set(__keys, guild, data) {
|
|
30
|
+
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
31
|
+
const bulkData = [];
|
|
32
|
+
for (const [id, value] of keys) {
|
|
33
|
+
if (value.user) {
|
|
34
|
+
bulkData.push(['members', value, id, guild]);
|
|
35
|
+
bulkData.push(['users', value.user, id]);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
await this.cache.bulkSet(bulkData);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.Members = Members;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GatewayPresenceUpdate } from '../../common';
|
|
2
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
3
|
+
export declare class Presences extends GuildRelatedResource<PresenceResource> {
|
|
4
|
+
namespace: string;
|
|
5
|
+
parse(data: any, key: string, guild_id: string): PresenceResource;
|
|
6
|
+
}
|
|
7
|
+
export type PresenceResource = Omit<GatewayPresenceUpdate, 'user'> & {
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Presences = void 0;
|
|
4
|
+
const guild_related_1 = require("./default/guild-related");
|
|
5
|
+
class Presences extends guild_related_1.GuildRelatedResource {
|
|
6
|
+
namespace = 'presence';
|
|
7
|
+
parse(data, key, guild_id) {
|
|
8
|
+
super.parse(data, key, guild_id);
|
|
9
|
+
data.user_id = data.user?.id ?? key;
|
|
10
|
+
data.user = undefined;
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.Presences = Presences;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GuildRole } from '../../structures';
|
|
2
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
3
|
+
export declare class Roles extends GuildRelatedResource {
|
|
4
|
+
namespace: string;
|
|
5
|
+
get(id: string): Promise<GuildRole | undefined>;
|
|
6
|
+
values(guild: string): Promise<GuildRole[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Roles = void 0;
|
|
4
|
+
const structures_1 = require("../../structures");
|
|
5
|
+
const guild_related_1 = require("./default/guild-related");
|
|
6
|
+
class Roles extends guild_related_1.GuildRelatedResource {
|
|
7
|
+
namespace = 'role';
|
|
8
|
+
async get(id) {
|
|
9
|
+
const rawRole = await super.get(id);
|
|
10
|
+
return rawRole ? new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id) : undefined;
|
|
11
|
+
}
|
|
12
|
+
async values(guild) {
|
|
13
|
+
const roles = await super.values(guild);
|
|
14
|
+
return roles.map(rawRole => new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Roles = Roles;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StageInstances = void 0;
|
|
4
|
+
const guild_related_1 = require("./default/guild-related");
|
|
5
|
+
class StageInstances extends guild_related_1.GuildRelatedResource {
|
|
6
|
+
namespace = 'stage_instances';
|
|
7
|
+
}
|
|
8
|
+
exports.StageInstances = StageInstances;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Sticker } from '../../structures';
|
|
2
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
3
|
+
export declare class Stickers extends GuildRelatedResource {
|
|
4
|
+
namespace: string;
|
|
5
|
+
get(id: string): Promise<Sticker | undefined>;
|
|
6
|
+
values(guild: string): Promise<Sticker[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Stickers = void 0;
|
|
4
|
+
const structures_1 = require("../../structures");
|
|
5
|
+
const guild_related_1 = require("./default/guild-related");
|
|
6
|
+
class Stickers extends guild_related_1.GuildRelatedResource {
|
|
7
|
+
namespace = 'sticker';
|
|
8
|
+
async get(id) {
|
|
9
|
+
const rawSticker = (await super.get(id));
|
|
10
|
+
return rawSticker ? new structures_1.Sticker(this.client, rawSticker) : undefined;
|
|
11
|
+
}
|
|
12
|
+
async values(guild) {
|
|
13
|
+
const emojis = (await super.values(guild));
|
|
14
|
+
return emojis.map(rawSticker => new structures_1.Sticker(this.client, rawSticker));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Stickers = Stickers;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ThreadChannel } from '../../structures';
|
|
2
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
3
|
+
export declare class Threads extends GuildRelatedResource {
|
|
4
|
+
namespace: string;
|
|
5
|
+
get(id: string): Promise<ThreadChannel | undefined>;
|
|
6
|
+
values(guild: string): Promise<ThreadChannel[]>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Threads = void 0;
|
|
4
|
+
const structures_1 = require("../../structures");
|
|
5
|
+
const guild_related_1 = require("./default/guild-related");
|
|
6
|
+
class Threads extends guild_related_1.GuildRelatedResource {
|
|
7
|
+
namespace = 'thread';
|
|
8
|
+
async get(id) {
|
|
9
|
+
const rawThread = (await super.get(id));
|
|
10
|
+
return rawThread ? new structures_1.ThreadChannel(this.client, rawThread) : undefined;
|
|
11
|
+
}
|
|
12
|
+
async values(guild) {
|
|
13
|
+
const members = (await super.values(guild));
|
|
14
|
+
return members.map(rawThread => new structures_1.ThreadChannel(this.client, rawThread));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Threads = Threads;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Users = void 0;
|
|
4
|
+
const structures_1 = require("../../structures");
|
|
5
|
+
const base_1 = require("./default/base");
|
|
6
|
+
class Users extends base_1.BaseResource {
|
|
7
|
+
namespace = 'user';
|
|
8
|
+
async get(id) {
|
|
9
|
+
const rawUser = (await super.get(id));
|
|
10
|
+
return rawUser ? new structures_1.User(this.client, rawUser) : undefined;
|
|
11
|
+
}
|
|
12
|
+
async values() {
|
|
13
|
+
const members = (await super.values());
|
|
14
|
+
return members.map(rawUser => new structures_1.User(this.client, rawUser));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Users = Users;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GatewayVoiceState } from '../../common';
|
|
2
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
3
|
+
export declare class VoiceStates extends GuildRelatedResource<VoiceStateResource> {
|
|
4
|
+
namespace: string;
|
|
5
|
+
parse(data: any, _id: string, guild_id: string): VoiceStateResource;
|
|
6
|
+
}
|
|
7
|
+
export type VoiceStateResource = Omit<GatewayVoiceState, 'member'> & {
|
|
8
|
+
guild_id: string;
|
|
9
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VoiceStates = void 0;
|
|
4
|
+
const guild_related_1 = require("./default/guild-related");
|
|
5
|
+
class VoiceStates extends guild_related_1.GuildRelatedResource {
|
|
6
|
+
namespace = 'voice-state';
|
|
7
|
+
parse(data, _id, guild_id) {
|
|
8
|
+
data.guild_id = guild_id;
|
|
9
|
+
delete data.member;
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.VoiceStates = VoiceStates;
|