seyfert 1.2.3 → 1.3.1
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/api/Routes/channels.d.ts +15 -1
- package/lib/api/api.js +5 -1
- package/lib/api/shared.d.ts +3 -1
- package/lib/api/utils/utils.d.ts +1 -1
- package/lib/api/utils/utils.js +2 -2
- package/lib/builders/Poll.d.ts +16 -0
- package/lib/builders/Poll.js +48 -0
- package/lib/builders/index.d.ts +1 -0
- package/lib/builders/index.js +1 -0
- package/lib/cache/adapters/index.d.ts +1 -0
- package/lib/cache/adapters/index.js +1 -0
- package/lib/cache/adapters/limited.d.ts +50 -0
- package/lib/cache/adapters/limited.js +188 -0
- package/lib/cache/index.d.ts +5 -2
- package/lib/cache/index.js +38 -7
- package/lib/cache/resources/channels.d.ts +2 -1
- package/lib/cache/resources/default/base.d.ts +3 -3
- package/lib/cache/resources/default/base.js +8 -3
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +7 -3
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +7 -3
- package/lib/cache/resources/emojis.d.ts +2 -0
- package/lib/cache/resources/emojis.js +4 -0
- package/lib/cache/resources/guilds.d.ts +2 -0
- package/lib/cache/resources/guilds.js +4 -0
- package/lib/cache/resources/members.d.ts +2 -0
- package/lib/cache/resources/members.js +5 -1
- package/lib/cache/resources/messages.d.ts +15 -0
- package/lib/cache/resources/messages.js +53 -0
- package/lib/cache/resources/overwrites.d.ts +2 -0
- package/lib/cache/resources/overwrites.js +4 -0
- package/lib/cache/resources/presence.d.ts +1 -0
- package/lib/cache/resources/presence.js +4 -0
- package/lib/cache/resources/roles.d.ts +2 -0
- package/lib/cache/resources/roles.js +4 -0
- package/lib/cache/resources/stage-instances.d.ts +1 -0
- package/lib/cache/resources/stage-instances.js +5 -1
- package/lib/cache/resources/stickers.d.ts +2 -0
- package/lib/cache/resources/stickers.js +4 -0
- package/lib/cache/resources/threads.d.ts +2 -0
- package/lib/cache/resources/threads.js +4 -0
- package/lib/cache/resources/users.d.ts +2 -0
- package/lib/cache/resources/users.js +4 -0
- package/lib/cache/resources/voice-states.d.ts +2 -1
- package/lib/cache/resources/voice-states.js +8 -4
- package/lib/client/base.d.ts +25 -13
- package/lib/client/base.js +33 -8
- package/lib/client/client.d.ts +6 -5
- package/lib/client/client.js +13 -1
- package/lib/client/oninteractioncreate.js +2 -2
- package/lib/client/onmessagecreate.js +2 -2
- package/lib/client/workerclient.d.ts +3 -3
- package/lib/client/workerclient.js +18 -3
- package/lib/collection.d.ts +8 -3
- package/lib/collection.js +22 -4
- package/lib/commands/applications/chat.d.ts +8 -14
- package/lib/commands/applications/chat.js +2 -20
- package/lib/commands/applications/chatcontext.d.ts +1 -1
- package/lib/commands/applications/menucontext.d.ts +1 -1
- package/lib/commands/handler.d.ts +11 -7
- package/lib/commands/handler.js +43 -14
- package/lib/common/index.d.ts +2 -0
- package/lib/common/index.js +2 -0
- package/lib/common/it/utils.d.ts +0 -1
- package/lib/common/it/utils.js +0 -1
- package/lib/common/shorters/channels.d.ts +5 -3
- package/lib/common/shorters/channels.js +24 -10
- package/lib/common/shorters/guilds.d.ts +7 -6
- package/lib/common/shorters/guilds.js +23 -4
- package/lib/common/shorters/interaction.d.ts +13 -0
- package/lib/common/shorters/interaction.js +61 -0
- package/lib/common/shorters/messages.d.ts +6 -3
- package/lib/common/shorters/messages.js +33 -15
- package/lib/common/shorters/roles.d.ts +3 -3
- package/lib/common/shorters/roles.js +12 -17
- package/lib/common/shorters/templates.d.ts +7 -6
- package/lib/common/shorters/templates.js +28 -6
- package/lib/common/shorters/threads.d.ts +39 -0
- package/lib/common/shorters/threads.js +76 -0
- package/lib/common/shorters/webhook.d.ts +1 -1
- package/lib/common/shorters/webhook.js +8 -2
- package/lib/common/types/util.d.ts +8 -2
- package/lib/common/types/write.d.ts +8 -5
- package/lib/components/ButtonComponent.js +1 -1
- package/lib/components/componentcontext.d.ts +1 -1
- package/lib/components/handler.d.ts +6 -17
- package/lib/components/handler.js +7 -2
- package/lib/events/handler.d.ts +8 -14
- package/lib/events/handler.js +9 -4
- package/lib/events/hooks/auto_moderation.d.ts +5 -1
- package/lib/events/hooks/guild.d.ts +692 -23
- package/lib/events/hooks/guild.js +2 -2
- package/lib/events/hooks/integration.d.ts +52 -47
- package/lib/events/hooks/interactions.d.ts +1 -1
- package/lib/events/hooks/invite.d.ts +67 -3
- package/lib/events/hooks/message.d.ts +96 -12
- package/lib/events/hooks/message.js +18 -7
- package/lib/events/hooks/presence.d.ts +48 -2
- package/lib/events/hooks/thread.d.ts +155 -18
- package/lib/events/hooks/typing.d.ts +13 -1
- package/lib/events/hooks/voice.d.ts +13 -1
- package/lib/langs/handler.d.ts +4 -8
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +7 -7
- package/lib/structures/AutoModerationRule.js +2 -1
- package/lib/structures/Guild.d.ts +15 -13
- package/lib/structures/GuildRole.d.ts +5 -5
- package/lib/structures/GuildTemplate.d.ts +10 -10
- package/lib/structures/Interaction.d.ts +4 -4
- package/lib/structures/Interaction.js +27 -48
- package/lib/structures/Message.d.ts +5 -3
- package/lib/structures/Message.js +5 -0
- package/lib/structures/Poll.d.ts +15 -0
- package/lib/structures/Poll.js +26 -0
- package/lib/structures/User.js +2 -2
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/channels.d.ts +6 -3
- package/lib/structures/channels.js +16 -8
- package/lib/structures/extra/Permissions.d.ts +1 -0
- package/lib/structures/index.d.ts +1 -0
- package/lib/structures/index.js +1 -0
- package/lib/websocket/SharedTypes.d.ts +7 -2
- package/lib/websocket/discord/shard.js +1 -1
- package/package.json +8 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RESTDeleteAPIChannelAllMessageReactionsResult, RESTDeleteAPIChannelMessageReactionResult, RESTDeleteAPIChannelMessageResult, RESTDeleteAPIChannelPermissionResult, RESTDeleteAPIChannelPinResult, RESTDeleteAPIChannelRecipientResult, RESTDeleteAPIChannelResult, RESTDeleteAPIChannelThreadMembersResult, RESTGetAPIChannelInvitesResult, RESTGetAPIChannelMessageReactionUsersQuery, RESTGetAPIChannelMessageReactionUsersResult, RESTGetAPIChannelMessageResult, RESTGetAPIChannelMessagesQuery, RESTGetAPIChannelMessagesResult, RESTGetAPIChannelPinsResult, RESTGetAPIChannelResult, RESTGetAPIChannelThreadMemberQuery, RESTGetAPIChannelThreadMemberResult, RESTGetAPIChannelThreadMembersQuery, RESTGetAPIChannelThreadMembersResult, RESTGetAPIChannelThreadsArchivedPrivateResult, RESTGetAPIChannelThreadsArchivedPublicResult, RESTGetAPIChannelThreadsArchivedQuery, RESTGetAPIChannelUsersThreadsArchivedResult, RESTGetAPIGuildWebhooksResult, RESTPatchAPIChannelJSONBody, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIChannelMessageResult, RESTPatchAPIChannelResult, RESTPostAPIChannelFollowersJSONBody, RESTPostAPIChannelFollowersResult, RESTPostAPIChannelInviteJSONBody, RESTPostAPIChannelInviteResult, RESTPostAPIChannelMessageCrosspostResult, RESTPostAPIChannelMessageJSONBody, RESTPostAPIChannelMessageResult, RESTPostAPIChannelMessagesBulkDeleteJSONBody, RESTPostAPIChannelMessagesBulkDeleteResult, RESTPostAPIChannelMessagesThreadsJSONBody, RESTPostAPIChannelMessagesThreadsResult, RESTPostAPIChannelThreadsJSONBody, RESTPostAPIChannelThreadsResult, RESTPostAPIChannelTypingResult, RESTPostAPIChannelWebhookJSONBody, RESTPostAPIChannelWebhookResult, RESTPostAPIGuildForumThreadsJSONBody, RESTPutAPIChannelMessageReactionResult, RESTPutAPIChannelPermissionJSONBody, RESTPutAPIChannelPermissionResult, RESTPutAPIChannelPinResult, RESTPutAPIChannelRecipientJSONBody, RESTPutAPIChannelRecipientResult, RESTPutAPIChannelThreadMembersResult } from 'discord-api-types/v10';
|
|
1
|
+
import type { RESTDeleteAPIChannelAllMessageReactionsResult, RESTDeleteAPIChannelMessageReactionResult, RESTDeleteAPIChannelMessageResult, RESTDeleteAPIChannelPermissionResult, RESTDeleteAPIChannelPinResult, RESTDeleteAPIChannelRecipientResult, RESTDeleteAPIChannelResult, RESTDeleteAPIChannelThreadMembersResult, RESTGetAPIChannelInvitesResult, RESTGetAPIChannelMessageReactionUsersQuery, RESTGetAPIChannelMessageReactionUsersResult, RESTGetAPIChannelMessageResult, RESTGetAPIChannelMessagesQuery, RESTGetAPIChannelMessagesResult, RESTGetAPIChannelPinsResult, RESTGetAPIChannelResult, RESTGetAPIChannelThreadMemberQuery, RESTGetAPIChannelThreadMemberResult, RESTGetAPIChannelThreadMembersQuery, RESTGetAPIChannelThreadMembersResult, RESTGetAPIChannelThreadsArchivedPrivateResult, RESTGetAPIChannelThreadsArchivedPublicResult, RESTGetAPIChannelThreadsArchivedQuery, RESTGetAPIChannelUsersThreadsArchivedResult, RESTGetAPIGuildWebhooksResult, RESTGetAPIPollAnswerVotersQuery, RESTGetAPIPollAnswerVotersResult, RESTPatchAPIChannelJSONBody, RESTPatchAPIChannelMessageJSONBody, RESTPatchAPIChannelMessageResult, RESTPatchAPIChannelResult, RESTPostAPIChannelFollowersJSONBody, RESTPostAPIChannelFollowersResult, RESTPostAPIChannelInviteJSONBody, RESTPostAPIChannelInviteResult, RESTPostAPIChannelMessageCrosspostResult, RESTPostAPIChannelMessageJSONBody, RESTPostAPIChannelMessageResult, RESTPostAPIChannelMessagesBulkDeleteJSONBody, RESTPostAPIChannelMessagesBulkDeleteResult, RESTPostAPIChannelMessagesThreadsJSONBody, RESTPostAPIChannelMessagesThreadsResult, RESTPostAPIChannelThreadsJSONBody, RESTPostAPIChannelThreadsResult, RESTPostAPIChannelTypingResult, RESTPostAPIChannelWebhookJSONBody, RESTPostAPIChannelWebhookResult, RESTPostAPIGuildForumThreadsJSONBody, RESTPostAPIPollExpireResult, RESTPutAPIChannelMessageReactionResult, RESTPutAPIChannelPermissionJSONBody, RESTPutAPIChannelPermissionResult, RESTPutAPIChannelPinResult, RESTPutAPIChannelRecipientJSONBody, RESTPutAPIChannelRecipientResult, RESTPutAPIChannelThreadMembersResult } from 'discord-api-types/v10';
|
|
2
2
|
import type { ProxyRequestMethod } from '../Router';
|
|
3
3
|
import type { RestArguments } from '../api';
|
|
4
4
|
export interface ChannelRoutes {
|
|
@@ -99,5 +99,19 @@ export interface ChannelRoutes {
|
|
|
99
99
|
get(args?: RestArguments<ProxyRequestMethod.Get>): Promise<RESTGetAPIGuildWebhooksResult>;
|
|
100
100
|
post(args: RestArguments<ProxyRequestMethod.Post, RESTPostAPIChannelWebhookJSONBody>): Promise<RESTPostAPIChannelWebhookResult>;
|
|
101
101
|
};
|
|
102
|
+
'voice-status': {
|
|
103
|
+
put(args: RestArguments<ProxyRequestMethod.Put, {
|
|
104
|
+
status: string | null;
|
|
105
|
+
}>): Promise<never>;
|
|
106
|
+
};
|
|
107
|
+
polls(messageId: string): {
|
|
108
|
+
answers(id: ValidAnswerId): {
|
|
109
|
+
get(args?: RestArguments<ProxyRequestMethod.Get, never, RESTGetAPIPollAnswerVotersQuery>): Promise<RESTGetAPIPollAnswerVotersResult>;
|
|
110
|
+
};
|
|
111
|
+
expire: {
|
|
112
|
+
post(args?: RestArguments<ProxyRequestMethod.Post>): Promise<RESTPostAPIPollExpireResult>;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
102
115
|
};
|
|
103
116
|
}
|
|
117
|
+
export type ValidAnswerId = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
package/lib/api/api.js
CHANGED
|
@@ -23,6 +23,7 @@ class ApiHandler {
|
|
|
23
23
|
this.options = {
|
|
24
24
|
baseUrl: 'api/v10',
|
|
25
25
|
domain: 'https://discord.com',
|
|
26
|
+
type: 'Bot',
|
|
26
27
|
...options,
|
|
27
28
|
userAgent: shared_1.DefaultUserAgent,
|
|
28
29
|
};
|
|
@@ -270,7 +271,7 @@ class ApiHandler {
|
|
|
270
271
|
let finalUrl = options.url;
|
|
271
272
|
let data;
|
|
272
273
|
if (options.request.auth) {
|
|
273
|
-
options.headers.Authorization =
|
|
274
|
+
options.headers.Authorization = `${this.options.type} ${options.request.token || this.options.token}`;
|
|
274
275
|
}
|
|
275
276
|
if (options.request.query) {
|
|
276
277
|
finalUrl += `?${new URLSearchParams(options.request.query)}`;
|
|
@@ -318,6 +319,9 @@ class ApiHandler {
|
|
|
318
319
|
return { data, finalUrl };
|
|
319
320
|
}
|
|
320
321
|
routefy(url, method) {
|
|
322
|
+
if (url.startsWith('/interactions/') && url.endsWith('/callback')) {
|
|
323
|
+
return '/interactions/:id/:token/callback';
|
|
324
|
+
}
|
|
321
325
|
let route = url
|
|
322
326
|
.replace(/\/([a-z-]+)\/(?:[0-9]{17,19})/g, (match, p) => p === 'channels' || p === 'guilds' || p === 'webhooks' ? match : `/${p}/:id`)
|
|
323
327
|
.replace(/\/reactions\/[^/]+/g, '/reactions/:id')
|
package/lib/api/shared.d.ts
CHANGED
|
@@ -12,8 +12,9 @@ export interface ApiHandlerOptions {
|
|
|
12
12
|
agent?: string;
|
|
13
13
|
smartBucket?: boolean;
|
|
14
14
|
workerProxy?: boolean;
|
|
15
|
+
type?: 'Bearer' | 'Bot';
|
|
15
16
|
}
|
|
16
|
-
export interface ApiHandlerInternalOptions extends MakeRequired<ApiHandlerOptions, 'baseUrl' | 'domain'> {
|
|
17
|
+
export interface ApiHandlerInternalOptions extends MakeRequired<ApiHandlerOptions, 'baseUrl' | 'domain' | 'type'> {
|
|
17
18
|
userAgent: string;
|
|
18
19
|
}
|
|
19
20
|
export interface RawFile {
|
|
@@ -31,5 +32,6 @@ export interface ApiRequestOptions {
|
|
|
31
32
|
route?: `/${string}`;
|
|
32
33
|
unshift?: boolean;
|
|
33
34
|
appendToFormData?: boolean;
|
|
35
|
+
token?: string;
|
|
34
36
|
}
|
|
35
37
|
export type HttpMethods = 'GET' | 'DELETE' | 'PUT' | 'POST' | 'PATCH';
|
package/lib/api/utils/utils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { Snowflake } from 'discord-api-types/v10';
|
|
|
5
5
|
*
|
|
6
6
|
* @param userId - The user id to calculate the default avatar index for
|
|
7
7
|
*/
|
|
8
|
-
export declare function calculateUserDefaultAvatarIndex(userId: Snowflake): number;
|
|
8
|
+
export declare function calculateUserDefaultAvatarIndex(userId: Snowflake, discriminator: string): number;
|
|
9
9
|
/**
|
|
10
10
|
* Verifies that a value is a buffer-like object.
|
|
11
11
|
*
|
package/lib/api/utils/utils.js
CHANGED
|
@@ -6,8 +6,8 @@ exports.isBufferLike = exports.calculateUserDefaultAvatarIndex = void 0;
|
|
|
6
6
|
*
|
|
7
7
|
* @param userId - The user id to calculate the default avatar index for
|
|
8
8
|
*/
|
|
9
|
-
function calculateUserDefaultAvatarIndex(userId) {
|
|
10
|
-
return Number(BigInt(userId) >> 22n) % 6;
|
|
9
|
+
function calculateUserDefaultAvatarIndex(userId, discriminator) {
|
|
10
|
+
return discriminator === '0' ? Number(BigInt(userId) >> 22n) % 6 : Number.parseInt(discriminator) % 5;
|
|
11
11
|
}
|
|
12
12
|
exports.calculateUserDefaultAvatarIndex = calculateUserDefaultAvatarIndex;
|
|
13
13
|
/**
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type APIPollMedia, type RESTAPIPollCreate } from 'discord-api-types/v10';
|
|
2
|
+
import type { DeepPartial, EmojiResolvable, RestOrArray } from '../common';
|
|
3
|
+
export declare class PollBuilder {
|
|
4
|
+
data: DeepPartial<RESTAPIPollCreate>;
|
|
5
|
+
constructor(data?: DeepPartial<RESTAPIPollCreate>);
|
|
6
|
+
addAnswers(...answers: RestOrArray<PollMedia>): this;
|
|
7
|
+
setAnswers(...answers: RestOrArray<PollMedia>): this;
|
|
8
|
+
setQuestion(data: PollMedia): this;
|
|
9
|
+
setDuration(hours: number): this;
|
|
10
|
+
allowMultiselect(value?: boolean): this;
|
|
11
|
+
toJSON(): RESTAPIPollCreate;
|
|
12
|
+
private resolvedPollMedia;
|
|
13
|
+
}
|
|
14
|
+
export type PollMedia = Omit<APIPollMedia, 'emoji'> & {
|
|
15
|
+
emoji?: EmojiResolvable;
|
|
16
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PollBuilder = void 0;
|
|
4
|
+
const v10_1 = require("discord-api-types/v10");
|
|
5
|
+
const __1 = require("..");
|
|
6
|
+
const functions_1 = require("../structures/extra/functions");
|
|
7
|
+
class PollBuilder {
|
|
8
|
+
data;
|
|
9
|
+
constructor(data = {}) {
|
|
10
|
+
this.data = data;
|
|
11
|
+
this.data.layout_type = v10_1.PollLayoutType.Default;
|
|
12
|
+
}
|
|
13
|
+
addAnswers(...answers) {
|
|
14
|
+
this.data.answers = (this.data.answers ?? []).concat(answers.flat().map(x => ({ poll_media: this.resolvedPollMedia(x) })));
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
setAnswers(...answers) {
|
|
18
|
+
this.data.answers = answers.flat().map(x => ({ poll_media: this.resolvedPollMedia(x) }));
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
setQuestion(data) {
|
|
22
|
+
this.data.question ??= {};
|
|
23
|
+
const { emoji, text } = this.resolvedPollMedia(data);
|
|
24
|
+
this.data.question.text = text;
|
|
25
|
+
this.data.question.emoji = emoji;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
setDuration(hours) {
|
|
29
|
+
this.data.duration = hours;
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
allowMultiselect(value = true) {
|
|
33
|
+
this.data.allow_multiselect = value;
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
toJSON() {
|
|
37
|
+
return { ...this.data };
|
|
38
|
+
}
|
|
39
|
+
resolvedPollMedia(data) {
|
|
40
|
+
if (!data.emoji)
|
|
41
|
+
return { text: data.text };
|
|
42
|
+
const resolve = (0, functions_1.resolvePartialEmoji)(data.emoji);
|
|
43
|
+
if (!resolve)
|
|
44
|
+
return (0, __1.throwError)('Invalid Emoji');
|
|
45
|
+
return { text: data.text, emoji: resolve };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.PollBuilder = PollBuilder;
|
package/lib/builders/index.d.ts
CHANGED
|
@@ -8,5 +8,6 @@ export * from './Button';
|
|
|
8
8
|
export * from './Embed';
|
|
9
9
|
export * from './Modal';
|
|
10
10
|
export * from './SelectMenu';
|
|
11
|
+
export * from './Poll';
|
|
11
12
|
export * from './types';
|
|
12
13
|
export declare function fromComponent(data: BuilderComponents | APIActionRowComponentTypes | APIActionRowComponent<APIActionRowComponentTypes> | ActionRow<BuilderComponents>): BuilderComponents | ActionRow<BuilderComponents>;
|
package/lib/builders/index.js
CHANGED
|
@@ -27,6 +27,7 @@ __exportStar(require("./Button"), exports);
|
|
|
27
27
|
__exportStar(require("./Embed"), exports);
|
|
28
28
|
__exportStar(require("./Modal"), exports);
|
|
29
29
|
__exportStar(require("./SelectMenu"), exports);
|
|
30
|
+
__exportStar(require("./Poll"), exports);
|
|
30
31
|
__exportStar(require("./types"), exports);
|
|
31
32
|
function fromComponent(data) {
|
|
32
33
|
if ('toJSON' in data) {
|
|
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./default"), exports);
|
|
18
|
+
__exportStar(require("./limited"), exports);
|
|
18
19
|
__exportStar(require("./redis"), exports);
|
|
19
20
|
__exportStar(require("./types"), exports);
|
|
20
21
|
__exportStar(require("./workeradapter"), exports);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { LimitedCollection } from '../..';
|
|
2
|
+
import { type MakeRequired } from '../../common';
|
|
3
|
+
import type { Adapter } from './types';
|
|
4
|
+
export interface ResourceLimitedMemoryAdapter {
|
|
5
|
+
expire?: number;
|
|
6
|
+
limit?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface LimitedMemoryAdapterOptions {
|
|
9
|
+
default?: ResourceLimitedMemoryAdapter;
|
|
10
|
+
guild?: ResourceLimitedMemoryAdapter;
|
|
11
|
+
user?: ResourceLimitedMemoryAdapter;
|
|
12
|
+
member?: ResourceLimitedMemoryAdapter;
|
|
13
|
+
voice_state?: ResourceLimitedMemoryAdapter;
|
|
14
|
+
channel?: ResourceLimitedMemoryAdapter;
|
|
15
|
+
emoji?: ResourceLimitedMemoryAdapter;
|
|
16
|
+
overwrite?: ResourceLimitedMemoryAdapter;
|
|
17
|
+
presence?: ResourceLimitedMemoryAdapter;
|
|
18
|
+
role?: ResourceLimitedMemoryAdapter;
|
|
19
|
+
stage_instance?: ResourceLimitedMemoryAdapter;
|
|
20
|
+
sticker?: ResourceLimitedMemoryAdapter;
|
|
21
|
+
thread?: ResourceLimitedMemoryAdapter;
|
|
22
|
+
}
|
|
23
|
+
export declare class LimitedMemoryAdapter implements Adapter {
|
|
24
|
+
isAsync: boolean;
|
|
25
|
+
readonly storage: Map<string, LimitedCollection<string, string>>;
|
|
26
|
+
readonly relationships: Map<string, Map<string, string[]>>;
|
|
27
|
+
options: MakeRequired<LimitedMemoryAdapterOptions, 'default'>;
|
|
28
|
+
constructor(options: LimitedMemoryAdapterOptions);
|
|
29
|
+
scan(query: string, keys?: false): any[];
|
|
30
|
+
scan(query: string, keys: true): string[];
|
|
31
|
+
get(keys: string): any;
|
|
32
|
+
get(keys: string[]): any[];
|
|
33
|
+
private __set;
|
|
34
|
+
set(keys: string, data: any): void;
|
|
35
|
+
set(keys: [string, any][]): void;
|
|
36
|
+
patch(updateOnly: boolean, keys: string, data: any): void;
|
|
37
|
+
patch(updateOnly: boolean, keys: [string, any][]): void;
|
|
38
|
+
values(to: string): any[];
|
|
39
|
+
keys(to: string): string[];
|
|
40
|
+
count(to: string): number;
|
|
41
|
+
remove(keys: string): void;
|
|
42
|
+
remove(keys: string[]): void;
|
|
43
|
+
flush(): void;
|
|
44
|
+
contains(to: string, keys: string): boolean;
|
|
45
|
+
getToRelationship(to: string): string[];
|
|
46
|
+
bulkAddToRelationShip(data: Record<string, string[]>): void;
|
|
47
|
+
addToRelationship(to: string, keys: string | string[]): void;
|
|
48
|
+
removeToRelationship(to: string, keys: string | string[]): void;
|
|
49
|
+
removeRelationship(to: string | string[]): void;
|
|
50
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LimitedMemoryAdapter = void 0;
|
|
4
|
+
const __1 = require("../..");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
class LimitedMemoryAdapter {
|
|
7
|
+
isAsync = false;
|
|
8
|
+
storage = new Map();
|
|
9
|
+
relationships = new Map();
|
|
10
|
+
options;
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this.options = (0, common_1.MergeOptions)({
|
|
13
|
+
default: {
|
|
14
|
+
expire: undefined,
|
|
15
|
+
limit: Number.POSITIVE_INFINITY,
|
|
16
|
+
},
|
|
17
|
+
}, options);
|
|
18
|
+
}
|
|
19
|
+
scan(query, keys = false) {
|
|
20
|
+
const values = [];
|
|
21
|
+
const sq = query.split('.');
|
|
22
|
+
for (const iterator of [...this.storage.values()].flatMap(x => x.entries()))
|
|
23
|
+
for (const [key, value] of iterator) {
|
|
24
|
+
if (key.split('.').every((value, i) => (sq[i] === '*' ? !!value : sq[i] === value))) {
|
|
25
|
+
values.push(keys ? key : JSON.parse(value.value));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return values;
|
|
29
|
+
}
|
|
30
|
+
get(keys) {
|
|
31
|
+
if (!Array.isArray(keys)) {
|
|
32
|
+
const data = [...this.storage.values()].find(x => x.has(keys))?.get(keys);
|
|
33
|
+
return data ? JSON.parse(data) : null;
|
|
34
|
+
}
|
|
35
|
+
const iterator = [...this.storage.values()];
|
|
36
|
+
return keys
|
|
37
|
+
.map(key => {
|
|
38
|
+
const data = iterator.find(x => x.has(key))?.get(key);
|
|
39
|
+
return data ? JSON.parse(data) : null;
|
|
40
|
+
})
|
|
41
|
+
.filter(x => x);
|
|
42
|
+
}
|
|
43
|
+
__set(key, data) {
|
|
44
|
+
const __guildId = Array.isArray(data) ? data[0].guild_id : data.guild_id;
|
|
45
|
+
const namespace = `${key.split('.')[0]}${__guildId ? `.${__guildId}` : ''}`;
|
|
46
|
+
const self = this;
|
|
47
|
+
if (!this.storage.has(namespace)) {
|
|
48
|
+
this.storage.set(namespace, new __1.LimitedCollection({
|
|
49
|
+
expire: this.options[key.split('.')[0]]?.expire ?? this.options.default.expire,
|
|
50
|
+
limit: this.options[key.split('.')[0]]?.limit ?? this.options.default.limit,
|
|
51
|
+
resetOnDemand: true,
|
|
52
|
+
onDelete(k) {
|
|
53
|
+
const relationshipNamespace = key.split('.')[0];
|
|
54
|
+
const relation = self.relationships.get(relationshipNamespace);
|
|
55
|
+
if (relation) {
|
|
56
|
+
switch (relationshipNamespace) {
|
|
57
|
+
case 'guild':
|
|
58
|
+
case 'user':
|
|
59
|
+
self.removeToRelationship(namespace, k.split('.')[1]);
|
|
60
|
+
break;
|
|
61
|
+
case 'member':
|
|
62
|
+
case 'voice_state':
|
|
63
|
+
{
|
|
64
|
+
const split = k.split('.');
|
|
65
|
+
self.removeToRelationship(`${namespace}.${split[1]}`, split[2]);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
case 'channel':
|
|
69
|
+
case 'emoji':
|
|
70
|
+
case 'presence':
|
|
71
|
+
case 'role':
|
|
72
|
+
case 'stage_instance':
|
|
73
|
+
case 'sticker':
|
|
74
|
+
case 'thread':
|
|
75
|
+
case 'overwrite':
|
|
76
|
+
case 'message':
|
|
77
|
+
self.removeToRelationship(namespace, k.split('.')[1]);
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
this.storage.get(namespace).set(key, JSON.stringify(data));
|
|
85
|
+
}
|
|
86
|
+
set(keys, data) {
|
|
87
|
+
if (Array.isArray(keys)) {
|
|
88
|
+
for (const [key, value] of keys) {
|
|
89
|
+
this.__set(key, value);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
this.__set(keys, data);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
patch(updateOnly, keys, data) {
|
|
97
|
+
if (Array.isArray(keys)) {
|
|
98
|
+
for (const [key, value] of keys) {
|
|
99
|
+
const oldData = this.get(key);
|
|
100
|
+
if (updateOnly && !oldData) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
this.__set(key, Array.isArray(value) ? value : { ...(oldData ?? {}), ...value });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
const oldData = this.get(keys);
|
|
108
|
+
if (updateOnly && !oldData) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.__set(keys, Array.isArray(data) ? data : { ...(oldData ?? {}), ...data });
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
values(to) {
|
|
115
|
+
const array = [];
|
|
116
|
+
const data = this.keys(to);
|
|
117
|
+
for (const key of data) {
|
|
118
|
+
const content = this.get(key);
|
|
119
|
+
if (content) {
|
|
120
|
+
array.push(content);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return array;
|
|
124
|
+
}
|
|
125
|
+
keys(to) {
|
|
126
|
+
return this.getToRelationship(to).map(id => `${to}.${id}`);
|
|
127
|
+
}
|
|
128
|
+
count(to) {
|
|
129
|
+
return this.getToRelationship(to).length;
|
|
130
|
+
}
|
|
131
|
+
remove(keys) {
|
|
132
|
+
for (const i of Array.isArray(keys) ? keys : [keys]) {
|
|
133
|
+
this.storage.get(i.split('.')[0])?.delete(i);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
flush() {
|
|
137
|
+
this.storage.clear();
|
|
138
|
+
this.relationships.clear();
|
|
139
|
+
}
|
|
140
|
+
contains(to, keys) {
|
|
141
|
+
return this.getToRelationship(to).includes(keys);
|
|
142
|
+
}
|
|
143
|
+
getToRelationship(to) {
|
|
144
|
+
const key = to.split('.')[0];
|
|
145
|
+
if (!this.relationships.has(key))
|
|
146
|
+
this.relationships.set(key, new Map());
|
|
147
|
+
const relation = this.relationships.get(key);
|
|
148
|
+
const subrelationKey = to.split('.')[1] ?? '*';
|
|
149
|
+
if (!relation.has(subrelationKey)) {
|
|
150
|
+
relation.set(subrelationKey, []);
|
|
151
|
+
}
|
|
152
|
+
return relation.get(subrelationKey);
|
|
153
|
+
}
|
|
154
|
+
bulkAddToRelationShip(data) {
|
|
155
|
+
for (const i in data) {
|
|
156
|
+
this.addToRelationship(i, data[i]);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
addToRelationship(to, keys) {
|
|
160
|
+
const key = to.split('.')[0];
|
|
161
|
+
if (!this.relationships.has(key)) {
|
|
162
|
+
this.relationships.set(key, new Map());
|
|
163
|
+
}
|
|
164
|
+
const data = this.getToRelationship(to);
|
|
165
|
+
for (const key of Array.isArray(keys) ? keys : [keys]) {
|
|
166
|
+
if (!data.includes(key)) {
|
|
167
|
+
data.push(key);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
removeToRelationship(to, keys) {
|
|
172
|
+
const data = this.getToRelationship(to);
|
|
173
|
+
if (data) {
|
|
174
|
+
for (const key of Array.isArray(keys) ? keys : [keys]) {
|
|
175
|
+
const idx = data.indexOf(key);
|
|
176
|
+
if (idx !== -1) {
|
|
177
|
+
data.splice(idx, 1);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
removeRelationship(to) {
|
|
183
|
+
for (const i of Array.isArray(to) ? to : [to]) {
|
|
184
|
+
this.relationships.delete(i);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.LimitedMemoryAdapter = LimitedMemoryAdapter;
|
package/lib/cache/index.d.ts
CHANGED
|
@@ -14,12 +14,13 @@ import { VoiceStates } from './resources/voice-states';
|
|
|
14
14
|
import { GatewayIntentBits, type GatewayDispatchPayload } from 'discord-api-types/v10';
|
|
15
15
|
import type { InternalOptions, UsingClient } from '../commands';
|
|
16
16
|
import { Overwrites } from './resources/overwrites';
|
|
17
|
+
import { Messages } from './resources/messages';
|
|
17
18
|
export type InferAsyncCache = InternalOptions extends {
|
|
18
19
|
asyncCache: infer P;
|
|
19
20
|
} ? P : false;
|
|
20
21
|
export type ReturnCache<T> = If<InferAsyncCache, Promise<T>, T>;
|
|
21
22
|
export type GuildBased = 'members' | 'voiceStates';
|
|
22
|
-
export type GuildRelated = 'emojis' | 'roles' | 'threads' | 'channels' | 'stickers' | 'presences' | 'stageInstances' | 'overwrites';
|
|
23
|
+
export type GuildRelated = 'emojis' | 'roles' | 'threads' | 'channels' | 'stickers' | 'presences' | 'stageInstances' | 'overwrites' | 'messages';
|
|
23
24
|
export type NonGuildBased = 'users' | 'guilds';
|
|
24
25
|
export * from './adapters/index';
|
|
25
26
|
export type CachedEvents = 'READY' | 'GUILD_CREATE' | 'GUILD_UPDATE' | 'GUILD_DELETE' | 'CHANNEL_CREATE' | 'CHANNEL_UPDATE' | 'CHANNEL_DELETE' | 'GUILD_ROLE_CREATE' | 'GUILD_ROLE_UPDATE' | 'GUILD_ROLE_DELETE' | 'GUILD_EMOJIS_UPDATE' | 'GUILD_STICKERS_UPDATE' | 'GUILD_MEMBER_ADD' | 'GUILD_MEMBER_UPDATE' | 'GUILD_MEMBER_REMOVE' | 'MESSAGE_CREATE' | 'PRESENCE_UPDATE' | 'THREAD_DELETE' | 'THREAD_CREATE' | 'THREAD_UPDATE' | 'USER_UPDATE' | 'VOICE_STATE_UPDATE' | 'STAGE_INSTANCE_CREATE' | 'STAGE_INSTANCE_UPDATE' | 'STAGE_INSTANCE_DELETE';
|
|
@@ -39,6 +40,7 @@ export declare class Cache {
|
|
|
39
40
|
stickers?: Stickers;
|
|
40
41
|
presences?: Presences;
|
|
41
42
|
stageInstances?: StageInstances;
|
|
43
|
+
messages?: Messages;
|
|
42
44
|
constructor(intents: number, adapter: Adapter, disabledCache?: (NonGuildBased | GuildBased | GuildRelated)[], client?: UsingClient);
|
|
43
45
|
flush(): ReturnCache<void>;
|
|
44
46
|
hasIntent(intent: keyof typeof GatewayIntentBits): boolean;
|
|
@@ -65,12 +67,13 @@ export declare class Cache {
|
|
|
65
67
|
channels: NonNullable<ReturnCache<import("..").AllChannels | undefined>>[];
|
|
66
68
|
members: import("..").GuildMember[];
|
|
67
69
|
users: import("..").User[];
|
|
68
|
-
|
|
70
|
+
messages: import("..").Message[];
|
|
69
71
|
presences: (Omit<import("discord-api-types/v10").GatewayPresenceUpdate, "user"> & {
|
|
70
72
|
id: string;
|
|
71
73
|
} & {
|
|
72
74
|
guild_id: string;
|
|
73
75
|
})[];
|
|
76
|
+
threads: import("..").ThreadChannel[];
|
|
74
77
|
voiceStates: import("..").VoiceState[];
|
|
75
78
|
stageInstances: (import("discord-api-types/v10").APIStageInstance & {
|
|
76
79
|
guild_id: string;
|
package/lib/cache/index.js
CHANGED
|
@@ -28,6 +28,7 @@ const threads_1 = require("./resources/threads");
|
|
|
28
28
|
const voice_states_1 = require("./resources/voice-states");
|
|
29
29
|
const v10_1 = require("discord-api-types/v10");
|
|
30
30
|
const overwrites_1 = require("./resources/overwrites");
|
|
31
|
+
const messages_1 = require("./resources/messages");
|
|
31
32
|
__exportStar(require("./adapters/index"), exports);
|
|
32
33
|
class Cache {
|
|
33
34
|
intents;
|
|
@@ -48,6 +49,7 @@ class Cache {
|
|
|
48
49
|
stickers;
|
|
49
50
|
presences;
|
|
50
51
|
stageInstances;
|
|
52
|
+
messages;
|
|
51
53
|
constructor(intents, adapter, disabledCache = [], client) {
|
|
52
54
|
this.intents = intents;
|
|
53
55
|
this.adapter = adapter;
|
|
@@ -91,6 +93,9 @@ class Cache {
|
|
|
91
93
|
if (!this.disabledCache.includes('stageInstances')) {
|
|
92
94
|
this.stageInstances = new stage_instances_1.StageInstances(this, client);
|
|
93
95
|
}
|
|
96
|
+
if (!this.disabledCache.includes('messages')) {
|
|
97
|
+
this.messages = new messages_1.Messages(this, client);
|
|
98
|
+
}
|
|
94
99
|
}
|
|
95
100
|
/** @internal */
|
|
96
101
|
__setClient(client) {
|
|
@@ -106,6 +111,7 @@ class Cache {
|
|
|
106
111
|
this.presences?.__setClient(client);
|
|
107
112
|
this.threads?.__setClient(client);
|
|
108
113
|
this.stageInstances?.__setClient(client);
|
|
114
|
+
this.messages?.__setClient(client);
|
|
109
115
|
}
|
|
110
116
|
flush() {
|
|
111
117
|
return this.adapter.flush();
|
|
@@ -161,6 +167,7 @@ class Cache {
|
|
|
161
167
|
case 'users':
|
|
162
168
|
case 'guilds':
|
|
163
169
|
case 'overwrites':
|
|
170
|
+
case 'messages':
|
|
164
171
|
{
|
|
165
172
|
if (!allData[type]) {
|
|
166
173
|
allData[type] = [];
|
|
@@ -200,7 +207,10 @@ class Cache {
|
|
|
200
207
|
case 'stageInstances':
|
|
201
208
|
case 'emojis':
|
|
202
209
|
case 'overwrites':
|
|
210
|
+
case 'messages':
|
|
203
211
|
{
|
|
212
|
+
if (!this[type]?.filter(data, id, guildId))
|
|
213
|
+
continue;
|
|
204
214
|
const hashId = this[type]?.hashId(guildId);
|
|
205
215
|
if (!hashId) {
|
|
206
216
|
continue;
|
|
@@ -218,6 +228,8 @@ class Cache {
|
|
|
218
228
|
case 'voiceStates':
|
|
219
229
|
case 'members':
|
|
220
230
|
{
|
|
231
|
+
if (!this[type]?.filter(data, id, guildId))
|
|
232
|
+
continue;
|
|
221
233
|
const hashId = this[type]?.hashId(guildId);
|
|
222
234
|
if (!hashId) {
|
|
223
235
|
continue;
|
|
@@ -233,6 +245,8 @@ class Cache {
|
|
|
233
245
|
case 'users':
|
|
234
246
|
case 'guilds':
|
|
235
247
|
{
|
|
248
|
+
if (!this[type]?.filter(data, id))
|
|
249
|
+
continue;
|
|
236
250
|
const hashId = this[type]?.namespace;
|
|
237
251
|
if (!hashId) {
|
|
238
252
|
continue;
|
|
@@ -248,8 +262,8 @@ class Cache {
|
|
|
248
262
|
throw new Error(`Invalid type ${type}`);
|
|
249
263
|
}
|
|
250
264
|
}
|
|
251
|
-
await this.adapter.patch(false, allData);
|
|
252
265
|
await this.adapter.bulkAddToRelationShip(relationshipsData);
|
|
266
|
+
await this.adapter.patch(false, allData);
|
|
253
267
|
}
|
|
254
268
|
async bulkSet(keys) {
|
|
255
269
|
const allData = [];
|
|
@@ -264,7 +278,10 @@ class Cache {
|
|
|
264
278
|
case 'stageInstances':
|
|
265
279
|
case 'emojis':
|
|
266
280
|
case 'overwrites':
|
|
281
|
+
case 'messages':
|
|
267
282
|
{
|
|
283
|
+
if (!this[type]?.filter(data, id, guildId))
|
|
284
|
+
continue;
|
|
268
285
|
const hashId = this[type]?.hashId(guildId);
|
|
269
286
|
if (!hashId) {
|
|
270
287
|
continue;
|
|
@@ -282,6 +299,8 @@ class Cache {
|
|
|
282
299
|
case 'voiceStates':
|
|
283
300
|
case 'members':
|
|
284
301
|
{
|
|
302
|
+
if (!this[type]?.filter(data, id, guildId))
|
|
303
|
+
continue;
|
|
285
304
|
const hashId = this[type]?.hashId(guildId);
|
|
286
305
|
if (!hashId) {
|
|
287
306
|
continue;
|
|
@@ -297,6 +316,8 @@ class Cache {
|
|
|
297
316
|
case 'users':
|
|
298
317
|
case 'guilds':
|
|
299
318
|
{
|
|
319
|
+
if (!this[type]?.filter(data, id))
|
|
320
|
+
continue;
|
|
300
321
|
const hashId = this[type]?.namespace;
|
|
301
322
|
if (!hashId) {
|
|
302
323
|
continue;
|
|
@@ -312,16 +333,13 @@ class Cache {
|
|
|
312
333
|
throw new Error(`Invalid type ${type}`);
|
|
313
334
|
}
|
|
314
335
|
}
|
|
315
|
-
await this.adapter.set(allData);
|
|
316
336
|
await this.adapter.bulkAddToRelationShip(relationshipsData);
|
|
337
|
+
await this.adapter.set(allData);
|
|
317
338
|
}
|
|
318
339
|
async onPacket(event) {
|
|
319
340
|
switch (event.t) {
|
|
320
341
|
case 'READY':
|
|
321
|
-
|
|
322
|
-
const data = event.d;
|
|
323
|
-
await this.users?.set(data.user.id, data.user);
|
|
324
|
-
}
|
|
342
|
+
await this.users?.set(event.d.user.id, event.d.user);
|
|
325
343
|
break;
|
|
326
344
|
case 'GUILD_CREATE':
|
|
327
345
|
case 'GUILD_UPDATE':
|
|
@@ -380,7 +398,8 @@ class Cache {
|
|
|
380
398
|
break;
|
|
381
399
|
case 'THREAD_CREATE':
|
|
382
400
|
case 'THREAD_UPDATE':
|
|
383
|
-
|
|
401
|
+
if (event.d.guild_id)
|
|
402
|
+
await this.threads?.set(event.d.id, event.d.guild_id, event.d);
|
|
384
403
|
break;
|
|
385
404
|
case 'THREAD_DELETE':
|
|
386
405
|
await this.threads?.remove(event.d.id, event.d.guild_id);
|
|
@@ -406,6 +425,18 @@ class Cache {
|
|
|
406
425
|
case 'STAGE_INSTANCE_DELETE':
|
|
407
426
|
await this.stageInstances?.remove(event.d.id, event.d.guild_id);
|
|
408
427
|
break;
|
|
428
|
+
case 'MESSAGE_CREATE':
|
|
429
|
+
await this.messages?.set(event.d.id, event.d.channel_id, event.d);
|
|
430
|
+
break;
|
|
431
|
+
case 'MESSAGE_UPDATE':
|
|
432
|
+
await this.messages?.patch(event.d.id, event.d.channel_id, event.d);
|
|
433
|
+
break;
|
|
434
|
+
case 'MESSAGE_DELETE':
|
|
435
|
+
await this.messages?.remove(event.d.id, event.d.channel_id);
|
|
436
|
+
break;
|
|
437
|
+
case 'MESSAGE_DELETE_BULK':
|
|
438
|
+
await this.messages?.remove(event.d.ids, event.d.channel_id);
|
|
439
|
+
break;
|
|
409
440
|
}
|
|
410
441
|
}
|
|
411
442
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import type { APIChannel } from 'discord-api-types/v10';
|
|
1
2
|
import type { AllChannels } from '../../structures';
|
|
2
3
|
import channelFrom from '../../structures/channels';
|
|
3
4
|
import type { ReturnCache } from '../index';
|
|
4
5
|
import { GuildRelatedResource } from './default/guild-related';
|
|
5
6
|
export declare class Channels extends GuildRelatedResource {
|
|
6
7
|
namespace: string;
|
|
7
|
-
parse(data:
|
|
8
|
+
parse(data: APIChannel, id: string, guild_id: string): any;
|
|
8
9
|
get(id: string): ReturnCache<AllChannels | undefined>;
|
|
9
10
|
bulk(ids: string[]): ReturnCache<ReturnType<typeof channelFrom>[]>;
|
|
10
11
|
values(guild: string): ReturnCache<ReturnType<typeof channelFrom>[]>;
|
|
@@ -7,14 +7,14 @@ export declare class BaseResource<T = any> {
|
|
|
7
7
|
client: BaseClient;
|
|
8
8
|
namespace: string;
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
|
-
|
|
10
|
+
filter(data: any, id: string): boolean;
|
|
11
11
|
get adapter(): import("../../index").Adapter;
|
|
12
12
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string): import("../../../common").Awaitable<void>;
|
|
13
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: any):
|
|
13
|
+
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, data: any): import("../../../common").Awaitable<void>;
|
|
14
14
|
get(id: string): ReturnCache<T | undefined>;
|
|
15
15
|
bulk(ids: string[]): ReturnCache<T[]>;
|
|
16
16
|
set(id: string, data: any): import("../../../common").Awaitable<void>;
|
|
17
|
-
patch
|
|
17
|
+
patch(id: string, data: any): import("../../../common").Awaitable<void>;
|
|
18
18
|
remove(id: string): import("../../../common").Awaitable<void>;
|
|
19
19
|
keys(): ReturnCache<string[]>;
|
|
20
20
|
values(): ReturnCache<T[]>;
|