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
|
@@ -16,8 +16,9 @@ class BaseResource {
|
|
|
16
16
|
__setClient(client) {
|
|
17
17
|
this.client = client;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
//@ts-expect-error
|
|
20
|
+
filter(data, id) {
|
|
21
|
+
return true;
|
|
21
22
|
}
|
|
22
23
|
get adapter() {
|
|
23
24
|
return this.cache.adapter;
|
|
@@ -30,7 +31,7 @@ class BaseResource {
|
|
|
30
31
|
}
|
|
31
32
|
setIfNI(intent, id, data) {
|
|
32
33
|
if (!this.cache.hasIntent(intent)) {
|
|
33
|
-
return
|
|
34
|
+
return this.set(id, data);
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
get(id) {
|
|
@@ -40,9 +41,13 @@ class BaseResource {
|
|
|
40
41
|
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashId(id)))).then(x => x.filter(y => y));
|
|
41
42
|
}
|
|
42
43
|
set(id, data) {
|
|
44
|
+
if (!this.filter(data, id))
|
|
45
|
+
return;
|
|
43
46
|
return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.set(this.hashId(id), data));
|
|
44
47
|
}
|
|
45
48
|
patch(id, data) {
|
|
49
|
+
if (!this.filter(data, id))
|
|
50
|
+
return;
|
|
46
51
|
return (0, common_1.fakePromise)(this.addToRelationship(id)).then(() => this.adapter.patch(false, this.hashId(id), data));
|
|
47
52
|
}
|
|
48
53
|
remove(id) {
|
|
@@ -7,10 +7,11 @@ export declare class GuildBasedResource<T = any> {
|
|
|
7
7
|
client: BaseClient;
|
|
8
8
|
namespace: string;
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
|
+
filter(data: any, id: string, guild_id: string): boolean;
|
|
10
11
|
parse(data: any, id: string, guild_id: string): any;
|
|
11
12
|
get adapter(): import("../../index").Adapter;
|
|
12
13
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
|
|
13
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any):
|
|
14
|
+
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): void;
|
|
14
15
|
get(id: string, guild: string): ReturnCache<(T & {
|
|
15
16
|
guild_id: string;
|
|
16
17
|
}) | undefined>;
|
|
@@ -16,6 +16,10 @@ class GuildBasedResource {
|
|
|
16
16
|
__setClient(client) {
|
|
17
17
|
this.client = client;
|
|
18
18
|
}
|
|
19
|
+
//@ts-expect-error
|
|
20
|
+
filter(data, id, guild_id) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
19
23
|
parse(data, id, guild_id) {
|
|
20
24
|
if (!data.id)
|
|
21
25
|
data.id = id;
|
|
@@ -33,7 +37,7 @@ class GuildBasedResource {
|
|
|
33
37
|
}
|
|
34
38
|
setIfNI(intent, id, guildId, data) {
|
|
35
39
|
if (!this.cache.hasIntent(intent)) {
|
|
36
|
-
return
|
|
40
|
+
return this.set(id, guildId, data);
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
get(id, guild) {
|
|
@@ -43,13 +47,13 @@ class GuildBasedResource {
|
|
|
43
47
|
return (0, common_1.fakePromise)(this.adapter.get(ids.map(id => this.hashGuildId(guild, id)))).then(x => x.filter(y => y));
|
|
44
48
|
}
|
|
45
49
|
set(__keys, guild, data) {
|
|
46
|
-
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
50
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
47
51
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
48
52
|
return [this.hashGuildId(guild, key), this.parse(value, key, guild)];
|
|
49
53
|
})));
|
|
50
54
|
}
|
|
51
55
|
patch(__keys, guild, data) {
|
|
52
|
-
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
56
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
53
57
|
return (0, common_1.fakePromise)(this.adapter.get(keys.map(([key]) => this.hashGuildId(guild, key)))).then(oldDatas => (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
54
58
|
const oldData = oldDatas.find(x => x.id === key) ?? {};
|
|
55
59
|
return [this.hashGuildId(guild, key), this.parse({ ...oldData, ...value }, key, guild)];
|
|
@@ -7,10 +7,11 @@ export declare class GuildRelatedResource<T = any> {
|
|
|
7
7
|
client: BaseClient;
|
|
8
8
|
namespace: string;
|
|
9
9
|
constructor(cache: Cache, client?: UsingClient);
|
|
10
|
+
filter(data: any, id: string, guild_id?: string): boolean;
|
|
10
11
|
parse(data: any, id: string, guild_id: string): any;
|
|
11
12
|
get adapter(): import("../../index").Adapter;
|
|
12
13
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../../common").Awaitable<void>;
|
|
13
|
-
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any):
|
|
14
|
+
setIfNI(intent: keyof typeof GatewayIntentBits, id: string, guildId: string, data: any): void;
|
|
14
15
|
get(id: string): ReturnCache<(T & {
|
|
15
16
|
guild_id: string;
|
|
16
17
|
}) | undefined>;
|
|
@@ -16,6 +16,10 @@ class GuildRelatedResource {
|
|
|
16
16
|
__setClient(client) {
|
|
17
17
|
this.client = client;
|
|
18
18
|
}
|
|
19
|
+
//@ts-expect-error
|
|
20
|
+
filter(data, id, guild_id) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
19
23
|
parse(data, id, guild_id) {
|
|
20
24
|
if (!data.id)
|
|
21
25
|
data.id = id;
|
|
@@ -32,7 +36,7 @@ class GuildRelatedResource {
|
|
|
32
36
|
}
|
|
33
37
|
setIfNI(intent, id, guildId, data) {
|
|
34
38
|
if (!this.cache.hasIntent(intent)) {
|
|
35
|
-
return
|
|
39
|
+
return this.set(id, guildId, data);
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
get(id) {
|
|
@@ -42,13 +46,13 @@ class GuildRelatedResource {
|
|
|
42
46
|
return (0, common_1.fakePromise)(this.adapter.get(ids.map(x => this.hashId(x)))).then(x => x.filter(y => y));
|
|
43
47
|
}
|
|
44
48
|
set(__keys, guild, data) {
|
|
45
|
-
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
49
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
46
50
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.set(keys.map(([key, value]) => {
|
|
47
51
|
return [this.hashId(key), this.parse(value, key, guild)];
|
|
48
52
|
})));
|
|
49
53
|
}
|
|
50
54
|
patch(__keys, guild, data) {
|
|
51
|
-
const keys = Array.isArray(__keys) ? __keys : [[__keys, data]];
|
|
55
|
+
const keys = (Array.isArray(__keys) ? __keys : [[__keys, data]]).filter(x => this.filter(x[1], x[0], guild));
|
|
52
56
|
if (guild) {
|
|
53
57
|
return (0, common_1.fakePromise)(this.addToRelationship(keys.map(x => x[0]), guild)).then(() => this.adapter.patch(false, keys.map(([key, value]) => {
|
|
54
58
|
return [this.hashId(key), this.parse(value, key, guild)];
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIEmoji } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { GuildEmoji } from '../../structures';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Emojis extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIEmoji, id: string, guild_id?: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<GuildEmoji | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<GuildEmoji[]>;
|
|
8
10
|
values(guild: string): ReturnCache<GuildEmoji[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Emojis extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'emoji';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawEmoji => rawEmoji ? new structures_1.GuildEmoji(this.client, rawEmoji, rawEmoji.guild_id) : undefined);
|
|
11
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIGuild } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '..';
|
|
2
3
|
import { Guild } from '../../structures';
|
|
3
4
|
import { BaseResource } from './default/base';
|
|
4
5
|
export declare class Guilds extends BaseResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIGuild, id: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<Guild<'cached'> | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<Guild<'cached'>[]>;
|
|
8
10
|
values(): ReturnCache<Guild<'cached'>[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const base_1 = require("./default/base");
|
|
7
7
|
class Guilds extends base_1.BaseResource {
|
|
8
8
|
namespace = 'guild';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(guild => (guild ? new structures_1.Guild(this.client, guild) : undefined));
|
|
11
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIGuildMember } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { GuildMember } from '../../structures';
|
|
3
4
|
import { GuildBasedResource } from './default/guild-based';
|
|
4
5
|
export declare class Members extends GuildBasedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIGuildMember, id: string, guild_id: string): boolean;
|
|
6
8
|
parse(data: any, key: string, guild_id: string): any;
|
|
7
9
|
get(id: string, guild: string): ReturnCache<GuildMember | undefined>;
|
|
8
10
|
bulk(ids: string[], guild: string): ReturnCache<GuildMember[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_based_1 = require("./default/guild-based");
|
|
7
7
|
class Members extends guild_based_1.GuildBasedResource {
|
|
8
8
|
namespace = 'member';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
parse(data, key, guild_id) {
|
|
10
14
|
const { user, ...rest } = super.parse(data, data.user?.id ?? key, guild_id);
|
|
11
15
|
return rest;
|
|
@@ -25,7 +29,7 @@ class Members extends guild_based_1.GuildBasedResource {
|
|
|
25
29
|
return (0, common_1.fakePromise)(super.values(guild)).then(members => (0, common_1.fakePromise)(this.client.cache.users?.values() ?? []).then(users => members
|
|
26
30
|
.map(rawMember => {
|
|
27
31
|
const user = users.find(x => x.id === rawMember.id);
|
|
28
|
-
return user ? new structures_1.GuildMember(this.client, rawMember, user,
|
|
32
|
+
return user ? new structures_1.GuildMember(this.client, rawMember, user, rawMember.guild_id) : undefined;
|
|
29
33
|
})
|
|
30
34
|
.filter(Boolean)));
|
|
31
35
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { APIMessage } from 'discord-api-types/v10';
|
|
2
|
+
import { GuildRelatedResource } from './default/guild-related';
|
|
3
|
+
import type { MessageData, ReturnCache } from '../..';
|
|
4
|
+
import { Message } from '../../structures';
|
|
5
|
+
export declare class Messages extends GuildRelatedResource {
|
|
6
|
+
namespace: string;
|
|
7
|
+
filter(data: MessageData, id: string, channel_id?: string): boolean;
|
|
8
|
+
parse(data: any, _key: string, _channel_id: string): any;
|
|
9
|
+
get(id: string): ReturnCache<Message | undefined>;
|
|
10
|
+
bulk(ids: string[]): ReturnCache<Message[]>;
|
|
11
|
+
values(guild: string): ReturnCache<Message[]>;
|
|
12
|
+
}
|
|
13
|
+
export type APIMessageResource = Omit<APIMessage, 'author'> & {
|
|
14
|
+
user_id?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Messages = void 0;
|
|
4
|
+
const guild_related_1 = require("./default/guild-related");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const structures_1 = require("../../structures");
|
|
7
|
+
class Messages extends guild_related_1.GuildRelatedResource {
|
|
8
|
+
namespace = 'message';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, channel_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
parse(data, _key, _channel_id) {
|
|
14
|
+
const { author, member, ...rest } = data;
|
|
15
|
+
if (author?.id)
|
|
16
|
+
rest.user_id = author.id;
|
|
17
|
+
return rest;
|
|
18
|
+
}
|
|
19
|
+
get(id) {
|
|
20
|
+
return (0, common_1.fakePromise)(super.get(id)).then(rawMessage => {
|
|
21
|
+
const user = this.cache.users && rawMessage?.user_id
|
|
22
|
+
? this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id))
|
|
23
|
+
: undefined;
|
|
24
|
+
return user ? new structures_1.Message(this.client, { ...rawMessage, author: user }) : undefined;
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
bulk(ids) {
|
|
28
|
+
return (0, common_1.fakePromise)(super.bulk(ids)).then(messages => messages
|
|
29
|
+
.map(rawMessage => {
|
|
30
|
+
const user = this.cache.users && rawMessage.user_id
|
|
31
|
+
? this.cache.adapter.get(this.cache.users.hashId(rawMessage.user_id))
|
|
32
|
+
: undefined;
|
|
33
|
+
return user ? new structures_1.Message(this.client, { ...rawMessage, author: user }) : undefined;
|
|
34
|
+
})
|
|
35
|
+
.filter(Boolean));
|
|
36
|
+
}
|
|
37
|
+
values(guild) {
|
|
38
|
+
return (0, common_1.fakePromise)(super.values(guild)).then(messages => {
|
|
39
|
+
const hashes = this.cache.users
|
|
40
|
+
? messages.map(x => (x.user_id ? this.cache.users.hashId(x.user_id) : undefined))
|
|
41
|
+
: [];
|
|
42
|
+
return (0, common_1.fakePromise)(this.cache.adapter.get(hashes.filter(Boolean))).then(users => {
|
|
43
|
+
return messages
|
|
44
|
+
.map(message => {
|
|
45
|
+
const user = users.find(user => user.id === message.user_id);
|
|
46
|
+
return user ? new structures_1.Message(this.client, { ...message, author: user }) : undefined;
|
|
47
|
+
})
|
|
48
|
+
.filter(Boolean);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.Messages = Messages;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIOverwrite } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { PermissionsBitField } from '../../structures/extra/Permissions';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Overwrites extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIOverwrite[], id: string, guild_id?: string): boolean;
|
|
6
8
|
parse(data: any[], _id: string, guild_id: string): any[];
|
|
7
9
|
get(id: string): ReturnCache<{
|
|
8
10
|
type: number;
|
|
@@ -6,6 +6,10 @@ const Permissions_1 = require("../../structures/extra/Permissions");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'overwrite';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
parse(data, _id, guild_id) {
|
|
10
14
|
data.forEach(x => {
|
|
11
15
|
x.guild_id = guild_id;
|
|
@@ -2,6 +2,7 @@ import type { GatewayPresenceUpdate } from 'discord-api-types/v10';
|
|
|
2
2
|
import { GuildRelatedResource } from './default/guild-related';
|
|
3
3
|
export declare class Presences extends GuildRelatedResource<PresenceResource> {
|
|
4
4
|
namespace: string;
|
|
5
|
+
filter(data: GatewayPresenceUpdate, id: string, guild_id?: string): boolean;
|
|
5
6
|
parse(data: any, key: string, guild_id: string): PresenceResource;
|
|
6
7
|
}
|
|
7
8
|
export type PresenceResource = Omit<GatewayPresenceUpdate, 'user'> & {
|
|
@@ -4,6 +4,10 @@ exports.Presences = void 0;
|
|
|
4
4
|
const guild_related_1 = require("./default/guild-related");
|
|
5
5
|
class Presences extends guild_related_1.GuildRelatedResource {
|
|
6
6
|
namespace = 'presence';
|
|
7
|
+
//@ts-expect-error
|
|
8
|
+
filter(data, id, guild_id) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
7
11
|
parse(data, key, guild_id) {
|
|
8
12
|
const { user, ...rest } = super.parse(data, key, guild_id);
|
|
9
13
|
rest.user_id ??= key;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIRole } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { GuildRole } from '../../structures';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Roles extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIRole, id: string, guild_id?: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<GuildRole | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<GuildRole[]>;
|
|
8
10
|
values(guild: string): ReturnCache<GuildRole[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Roles extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'role';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawRole => rawRole ? new structures_1.GuildRole(this.client, rawRole, rawRole.guild_id) : undefined);
|
|
11
15
|
}
|
|
@@ -2,4 +2,5 @@ import type { APIStageInstance } from 'discord-api-types/v10';
|
|
|
2
2
|
import { GuildRelatedResource } from './default/guild-related';
|
|
3
3
|
export declare class StageInstances extends GuildRelatedResource<APIStageInstance> {
|
|
4
4
|
namespace: string;
|
|
5
|
+
filter(data: APIStageInstance, id: string, guild_id?: string): boolean;
|
|
5
6
|
}
|
|
@@ -3,6 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.StageInstances = void 0;
|
|
4
4
|
const guild_related_1 = require("./default/guild-related");
|
|
5
5
|
class StageInstances extends guild_related_1.GuildRelatedResource {
|
|
6
|
-
namespace = '
|
|
6
|
+
namespace = 'stage_instance';
|
|
7
|
+
//@ts-expect-error
|
|
8
|
+
filter(data, id, guild_id) {
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
7
11
|
}
|
|
8
12
|
exports.StageInstances = StageInstances;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APISticker } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { Sticker } from '../../structures';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Stickers extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APISticker, id: string, guild_id?: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<Sticker | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<Sticker[]>;
|
|
8
10
|
values(guild: string): ReturnCache<Sticker[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Stickers extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'sticker';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawSticker => rawSticker ? new structures_1.Sticker(this.client, rawSticker) : undefined);
|
|
11
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIThreadChannel } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { ThreadChannel } from '../../structures';
|
|
3
4
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
5
|
export declare class Threads extends GuildRelatedResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIThreadChannel, id: string, guild_id?: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<ThreadChannel | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<ThreadChannel[]>;
|
|
8
10
|
values(guild: string): ReturnCache<ThreadChannel[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_related_1 = require("./default/guild-related");
|
|
7
7
|
class Threads extends guild_related_1.GuildRelatedResource {
|
|
8
8
|
namespace = 'thread';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawThread => rawThread ? new structures_1.ThreadChannel(this.client, rawThread) : undefined);
|
|
11
15
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { APIUser } from 'discord-api-types/v10';
|
|
1
2
|
import type { ReturnCache } from '../..';
|
|
2
3
|
import { User } from '../../structures';
|
|
3
4
|
import { BaseResource } from './default/base';
|
|
4
5
|
export declare class Users extends BaseResource {
|
|
5
6
|
namespace: string;
|
|
7
|
+
filter(data: APIUser, id: string): boolean;
|
|
6
8
|
get(id: string): ReturnCache<User | undefined>;
|
|
7
9
|
bulk(ids: string[]): ReturnCache<User[]>;
|
|
8
10
|
values(): ReturnCache<User[]>;
|
|
@@ -6,6 +6,10 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const base_1 = require("./default/base");
|
|
7
7
|
class Users extends base_1.BaseResource {
|
|
8
8
|
namespace = 'user';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
9
13
|
get(id) {
|
|
10
14
|
return (0, common_1.fakePromise)(super.get(id)).then(rawUser => (rawUser ? new structures_1.User(this.client, rawUser) : undefined));
|
|
11
15
|
}
|
|
@@ -4,10 +4,11 @@ import { VoiceState } from '../../structures';
|
|
|
4
4
|
import { GuildBasedResource } from './default/guild-based';
|
|
5
5
|
export declare class VoiceStates extends GuildBasedResource {
|
|
6
6
|
namespace: string;
|
|
7
|
+
filter(data: GatewayVoiceState, id: string, guild_id: string): boolean;
|
|
8
|
+
parse(data: any, id: string, guild_id: string): any;
|
|
7
9
|
get(memberId: string, guildId: string): ReturnCache<VoiceState | undefined>;
|
|
8
10
|
bulk(ids: string[], guild: string): ReturnCache<VoiceState[]>;
|
|
9
11
|
values(guildId: string): ReturnCache<VoiceState[]>;
|
|
10
|
-
parse(data: any, id: string, guild_id: string): any;
|
|
11
12
|
}
|
|
12
13
|
export type VoiceStateResource = Omit<GatewayVoiceState, 'member'> & {
|
|
13
14
|
guild_id: string;
|
|
@@ -6,6 +6,14 @@ const structures_1 = require("../../structures");
|
|
|
6
6
|
const guild_based_1 = require("./default/guild-based");
|
|
7
7
|
class VoiceStates extends guild_based_1.GuildBasedResource {
|
|
8
8
|
namespace = 'voice_state';
|
|
9
|
+
//@ts-expect-error
|
|
10
|
+
filter(data, id, guild_id) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
parse(data, id, guild_id) {
|
|
14
|
+
const { member, ...rest } = super.parse(data, id, guild_id);
|
|
15
|
+
return rest;
|
|
16
|
+
}
|
|
9
17
|
get(memberId, guildId) {
|
|
10
18
|
return (0, common_1.fakePromise)(super.get(memberId, guildId)).then(state => state ? new structures_1.VoiceState(this.client, state) : undefined);
|
|
11
19
|
}
|
|
@@ -15,9 +23,5 @@ class VoiceStates extends guild_based_1.GuildBasedResource {
|
|
|
15
23
|
values(guildId) {
|
|
16
24
|
return (0, common_1.fakePromise)(super.values(guildId)).then(states => states.map(state => new structures_1.VoiceState(this.client, state)));
|
|
17
25
|
}
|
|
18
|
-
parse(data, id, guild_id) {
|
|
19
|
-
const { member, ...rest } = super.parse(data, id, guild_id);
|
|
20
|
-
return rest;
|
|
21
|
-
}
|
|
22
26
|
}
|
|
23
27
|
exports.VoiceStates = VoiceStates;
|
package/lib/client/base.d.ts
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { ApiHandler } from '../api';
|
|
2
2
|
import type { Adapter } from '../cache';
|
|
3
3
|
import { Cache } from '../cache';
|
|
4
|
-
import type { Command,
|
|
4
|
+
import type { Command, RegisteredMiddlewares } from '../commands';
|
|
5
5
|
import { type InferWithPrefix, type MiddlewareContext } from '../commands/applications/shared';
|
|
6
|
-
import {
|
|
7
|
-
import { ChannelShorter, EmojiShorter, GuildShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, UsersShorter, WebhookShorter, type MakeRequired } from '../common';
|
|
6
|
+
import { CommandHandler } from '../commands/handler';
|
|
7
|
+
import { ChannelShorter, EmojiShorter, GuildShorter, InteractionShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, ThreadShorter, UsersShorter, WebhookShorter, type MakeRequired } from '../common';
|
|
8
8
|
import type { LocaleString } from 'discord-api-types/rest/v10';
|
|
9
9
|
import type { DeepPartial, IntentStrings, OmitInsert, When } from '../common/types/util';
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import { type LangsHandlerLike } from '../langs/handler';
|
|
10
|
+
import { ComponentHandler } from '../components/handler';
|
|
11
|
+
import { LangsHandler } from '../langs/handler';
|
|
13
12
|
import type { ChatInputCommandInteraction, ComponentInteraction, Message, MessageCommandInteraction, UserCommandInteraction } from '../structures';
|
|
14
13
|
export declare class BaseClient {
|
|
15
14
|
rest: ApiHandler;
|
|
@@ -24,11 +23,13 @@ export declare class BaseClient {
|
|
|
24
23
|
roles: RoleShorter;
|
|
25
24
|
reactions: ReactionShorter;
|
|
26
25
|
emojis: EmojiShorter;
|
|
26
|
+
threads: ThreadShorter;
|
|
27
|
+
interactions: InteractionShorter;
|
|
27
28
|
debugger?: Logger;
|
|
28
29
|
logger: Logger;
|
|
29
|
-
langs?:
|
|
30
|
-
commands?:
|
|
31
|
-
components?:
|
|
30
|
+
langs?: LangsHandler | undefined;
|
|
31
|
+
commands?: CommandHandler | undefined;
|
|
32
|
+
components?: ComponentHandler | undefined;
|
|
32
33
|
private _applicationId?;
|
|
33
34
|
private _botId?;
|
|
34
35
|
middlewares?: Record<string, MiddlewareContext>;
|
|
@@ -54,7 +55,7 @@ export declare class BaseClient {
|
|
|
54
55
|
};
|
|
55
56
|
getRC<T extends InternalRuntimeConfigHTTP | InternalRuntimeConfig = InternalRuntimeConfigHTTP | InternalRuntimeConfig>(): Promise<{
|
|
56
57
|
debug: boolean;
|
|
57
|
-
} & Omit<T, "
|
|
58
|
+
} & Omit<T, "locations" | "debug"> & {
|
|
58
59
|
templates: string | undefined;
|
|
59
60
|
langs: string | undefined;
|
|
60
61
|
events: string | undefined;
|
|
@@ -67,6 +68,17 @@ export declare class BaseClient {
|
|
|
67
68
|
export interface BaseClientOptions {
|
|
68
69
|
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | ComponentInteraction | When<InferWithPrefix, Message, never>) => {};
|
|
69
70
|
globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
|
|
71
|
+
commands?: {
|
|
72
|
+
defaults?: {
|
|
73
|
+
onRunError?: Command['onRunError'];
|
|
74
|
+
onPermissionsFail?: Command['onPermissionsFail'];
|
|
75
|
+
onBotPermissionsFail?: Command['onBotPermissionsFail'];
|
|
76
|
+
onInternalError?: Command['onInternalError'];
|
|
77
|
+
onMiddlewaresError?: Command['onMiddlewaresError'];
|
|
78
|
+
onOptionsError?: Command['onOptionsError'];
|
|
79
|
+
onAfterRun?: Command['onAfterRun'];
|
|
80
|
+
};
|
|
81
|
+
};
|
|
70
82
|
}
|
|
71
83
|
export interface StartOptions {
|
|
72
84
|
eventsDir: string;
|
|
@@ -123,9 +135,9 @@ export interface ServicesOptions {
|
|
|
123
135
|
};
|
|
124
136
|
middlewares?: Record<string, MiddlewareContext>;
|
|
125
137
|
handlers?: {
|
|
126
|
-
components?:
|
|
127
|
-
commands?:
|
|
128
|
-
langs?:
|
|
138
|
+
components?: ComponentHandler | ComponentHandler['callback'];
|
|
139
|
+
commands?: CommandHandler | Parameters<CommandHandler['setHandlers']>[0];
|
|
140
|
+
langs?: LangsHandler | LangsHandler['callback'];
|
|
129
141
|
};
|
|
130
142
|
}
|
|
131
143
|
export {};
|
package/lib/client/base.js
CHANGED
|
@@ -22,6 +22,8 @@ class BaseClient {
|
|
|
22
22
|
roles = new common_1.RoleShorter(this);
|
|
23
23
|
reactions = new common_1.ReactionShorter(this);
|
|
24
24
|
emojis = new common_1.EmojiShorter(this);
|
|
25
|
+
threads = new common_1.ThreadShorter(this);
|
|
26
|
+
interactions = new common_1.InteractionShorter(this);
|
|
25
27
|
debugger;
|
|
26
28
|
logger = new common_1.Logger({
|
|
27
29
|
name: '[Seyfert]',
|
|
@@ -42,7 +44,30 @@ class BaseClient {
|
|
|
42
44
|
}
|
|
43
45
|
options;
|
|
44
46
|
constructor(options) {
|
|
45
|
-
this.options =
|
|
47
|
+
this.options = (0, common_1.MergeOptions)({
|
|
48
|
+
commands: {
|
|
49
|
+
defaults: {
|
|
50
|
+
onRunError(context, error) {
|
|
51
|
+
context.client.logger.fatal(`${context.command.name}.<onRunError>`, context.author.id, error);
|
|
52
|
+
},
|
|
53
|
+
onOptionsError(context, metadata) {
|
|
54
|
+
context.client.logger.fatal(`${context.command.name}.<onOptionsError>`, context.author.id, metadata);
|
|
55
|
+
},
|
|
56
|
+
onMiddlewaresError(context, error) {
|
|
57
|
+
context.client.logger.fatal(`${context.command.name}.<onMiddlewaresError>`, context.author.id, error);
|
|
58
|
+
},
|
|
59
|
+
onBotPermissionsFail(context, permissions) {
|
|
60
|
+
context.client.logger.fatal(`${context.command.name}.<onBotPermissionsFail>`, context.author.id, permissions);
|
|
61
|
+
},
|
|
62
|
+
onPermissionsFail(context, permissions) {
|
|
63
|
+
context.client.logger.fatal(`${context.command.name}.<onPermissionsFail>`, context.author.id, permissions);
|
|
64
|
+
},
|
|
65
|
+
onInternalError(client, command, error) {
|
|
66
|
+
client.logger.fatal(`${command.name}.<onInternalError>`, error);
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}, options);
|
|
46
71
|
}
|
|
47
72
|
set botId(id) {
|
|
48
73
|
this._botId = id;
|
|
@@ -75,8 +100,8 @@ class BaseClient {
|
|
|
75
100
|
this.components = undefined;
|
|
76
101
|
}
|
|
77
102
|
else if (typeof handlers.components === 'function') {
|
|
78
|
-
this.components
|
|
79
|
-
this.components.
|
|
103
|
+
this.components ??= new handler_2.ComponentHandler(this.logger, this);
|
|
104
|
+
this.components.setHandlers({ callback: handlers.components });
|
|
80
105
|
}
|
|
81
106
|
else {
|
|
82
107
|
this.components = handlers.components;
|
|
@@ -86,9 +111,9 @@ class BaseClient {
|
|
|
86
111
|
if (!handlers.commands) {
|
|
87
112
|
this.commands = undefined;
|
|
88
113
|
}
|
|
89
|
-
else if (typeof handlers.commands === '
|
|
90
|
-
this.commands
|
|
91
|
-
this.commands.
|
|
114
|
+
else if (typeof handlers.commands === 'object') {
|
|
115
|
+
this.commands ??= new handler_1.CommandHandler(this.logger, this);
|
|
116
|
+
this.commands.setHandlers(handlers.commands);
|
|
92
117
|
}
|
|
93
118
|
else {
|
|
94
119
|
this.commands = handlers.commands;
|
|
@@ -99,8 +124,8 @@ class BaseClient {
|
|
|
99
124
|
this.langs = undefined;
|
|
100
125
|
}
|
|
101
126
|
else if (typeof handlers.langs === 'function') {
|
|
102
|
-
this.langs
|
|
103
|
-
this.langs.
|
|
127
|
+
this.langs ??= new handler_3.LangsHandler(this.logger);
|
|
128
|
+
this.langs.setHandlers({ callback: handlers.langs });
|
|
104
129
|
}
|
|
105
130
|
else {
|
|
106
131
|
this.langs = handlers.langs;
|