seyfert 1.0.0 → 1.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/lib/api/CDN.d.ts +1 -1
- package/lib/api/CDN.js +0 -2
- package/lib/api/Router.js +2 -2
- package/lib/api/Routes/applications.d.ts +29 -33
- package/lib/api/Routes/channels.d.ts +11 -17
- package/lib/api/Routes/interactions.d.ts +3 -7
- package/lib/api/Routes/webhooks.d.ts +4 -6
- package/lib/api/api.d.ts +5 -0
- package/lib/api/api.js +36 -0
- package/lib/api/shared.d.ts +5 -3
- package/lib/builders/Attachment.d.ts +2 -3
- package/lib/builders/Button.d.ts +2 -2
- package/lib/cache/adapters/default.d.ts +1 -0
- package/lib/cache/adapters/default.js +1 -0
- package/lib/cache/adapters/redis.d.ts +1 -0
- package/lib/cache/adapters/redis.js +7 -0
- package/lib/cache/adapters/types.d.ts +1 -0
- package/lib/cache/adapters/workeradapter.d.ts +5 -4
- package/lib/cache/adapters/workeradapter.js +11 -5
- package/lib/cache/index.d.ts +4 -6
- package/lib/cache/index.js +5 -6
- package/lib/cache/resources/default/base.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.d.ts +2 -1
- package/lib/cache/resources/default/guild-based.js +6 -6
- package/lib/cache/resources/default/guild-related.d.ts +2 -1
- package/lib/cache/resources/default/guild-related.js +1 -1
- package/lib/cache/resources/guilds.js +2 -1
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/overwrites.js +7 -1
- package/lib/client/base.d.ts +18 -171
- package/lib/client/base.js +12 -15
- package/lib/client/client.d.ts +6 -1
- package/lib/client/client.js +13 -12
- package/lib/client/oninteractioncreate.js +4 -4
- package/lib/client/onmessagecreate.js +188 -152
- package/lib/client/workerclient.d.ts +15 -1
- package/lib/client/workerclient.js +135 -27
- package/lib/collection.js +2 -2
- package/lib/commands/applications/chat.d.ts +15 -7
- package/lib/commands/applications/chat.js +7 -7
- package/lib/commands/applications/chatcontext.d.ts +6 -4
- package/lib/commands/applications/chatcontext.js +12 -7
- package/lib/commands/applications/menu.d.ts +5 -1
- package/lib/commands/applications/menu.js +4 -0
- package/lib/commands/applications/menucontext.d.ts +5 -3
- package/lib/commands/applications/menucontext.js +9 -4
- package/lib/commands/applications/options.d.ts +1 -2
- package/lib/commands/decorators.d.ts +17 -5
- package/lib/commands/decorators.js +17 -7
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +40 -36
- package/lib/commands/optionresolver.d.ts +11 -4
- package/lib/commands/optionresolver.js +6 -4
- package/lib/common/index.d.ts +7 -0
- package/lib/common/index.js +7 -0
- package/lib/common/it/utils.js +2 -0
- package/lib/common/shorters/channels.d.ts +67 -129
- package/lib/common/shorters/channels.js +119 -135
- package/lib/common/shorters/emojis.d.ts +47 -0
- package/lib/common/shorters/emojis.js +80 -0
- package/lib/common/shorters/guilds.d.ts +22 -249
- package/lib/common/shorters/guilds.js +51 -140
- package/lib/common/shorters/members.d.ts +82 -108
- package/lib/common/shorters/members.js +151 -166
- package/lib/common/shorters/messages.d.ts +11 -23
- package/lib/common/shorters/messages.js +58 -104
- package/lib/common/shorters/reactions.d.ts +10 -0
- package/lib/common/shorters/reactions.js +45 -0
- package/lib/common/shorters/roles.d.ts +39 -7
- package/lib/common/shorters/roles.js +74 -42
- package/lib/common/shorters/templates.d.ts +6 -8
- package/lib/common/shorters/templates.js +17 -21
- package/lib/common/shorters/users.d.ts +4 -0
- package/lib/common/shorters/users.js +30 -0
- package/lib/common/shorters/webhook.d.ts +62 -26
- package/lib/common/shorters/webhook.js +113 -58
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/util.d.ts +1 -1
- package/lib/components/handler.d.ts +11 -8
- package/lib/components/handler.js +34 -22
- package/lib/index.d.ts +4 -2
- package/lib/langs/handler.js +7 -2
- package/lib/structures/AutoModerationRule.d.ts +2 -2
- package/lib/structures/ClientUser.d.ts +2 -2
- package/lib/structures/Guild.d.ts +2 -2
- package/lib/structures/GuildEmoji.d.ts +4 -4
- package/lib/structures/GuildEmoji.js +7 -7
- package/lib/structures/GuildMember.d.ts +6 -6
- package/lib/structures/GuildMember.js +2 -2
- package/lib/structures/GuildPreview.d.ts +2 -2
- package/lib/structures/GuildRole.d.ts +2 -2
- package/lib/structures/GuildTemplate.d.ts +2 -2
- package/lib/structures/Interaction.d.ts +7 -8
- package/lib/structures/Interaction.js +1 -1
- package/lib/structures/Message.d.ts +7 -6
- package/lib/structures/Message.js +7 -4
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Webhook.d.ts +2 -2
- package/lib/structures/Webhook.js +3 -3
- package/lib/structures/channels.d.ts +19 -20
- package/lib/structures/channels.js +13 -25
- package/lib/structures/extra/Base.d.ts +1 -2
- package/lib/structures/extra/DiscordBase.d.ts +2 -2
- package/lib/websocket/constants/index.js +2 -3
- package/lib/websocket/discord/shard.js +4 -2
- package/lib/websocket/discord/sharder.d.ts +3 -0
- package/lib/websocket/discord/sharder.js +12 -5
- package/lib/websocket/discord/shared.d.ts +3 -0
- package/lib/websocket/discord/worker.d.ts +24 -7
- package/lib/websocket/discord/workermanager.d.ts +30 -6
- package/lib/websocket/discord/workermanager.js +160 -51
- package/package.json +8 -5
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { BaseClient } from '../../../client/base';
|
|
2
|
+
import type { UsingClient } from '../../../commands';
|
|
2
3
|
import { type GatewayIntentBits } from '../../../common';
|
|
3
4
|
import type { Cache, ReturnCache } from '../../index';
|
|
4
5
|
export declare class GuildRelatedResource<T = any> {
|
|
5
6
|
protected cache: Cache;
|
|
6
7
|
client: BaseClient;
|
|
7
8
|
namespace: string;
|
|
8
|
-
constructor(cache: Cache, client?:
|
|
9
|
+
constructor(cache: Cache, client?: UsingClient);
|
|
9
10
|
parse(data: any, id: string, guild_id: string): any;
|
|
10
11
|
get adapter(): import("../../index").Adapter;
|
|
11
12
|
removeIfNI(intent: keyof typeof GatewayIntentBits, id: string | string[], guildId: string): import("../../index").RPV<void>;
|
|
@@ -72,7 +72,7 @@ class GuildRelatedResource {
|
|
|
72
72
|
: (0, common_1.fakePromise)(this.adapter.getToRelationship(this.hashId(guild))).then(keys => this.adapter.get(keys.map(x => `${this.namespace}.${x}`)));
|
|
73
73
|
}
|
|
74
74
|
count(to) {
|
|
75
|
-
return this.adapter.count(this.hashId(to));
|
|
75
|
+
return to === '*' ? (0, common_1.fakePromise)(this.keys(to)).then(x => x.length) : this.adapter.count(this.hashId(to));
|
|
76
76
|
}
|
|
77
77
|
contains(id, guild) {
|
|
78
78
|
return this.adapter.contains(this.hashId(guild), id);
|
|
@@ -95,8 +95,9 @@ class Guilds extends base_1.BaseResource {
|
|
|
95
95
|
bulkData.push(['channels', channel, channel.id, id]);
|
|
96
96
|
}
|
|
97
97
|
for (const channel of data.channels ?? []) {
|
|
98
|
-
if (channel.permission_overwrites?.length)
|
|
98
|
+
if (channel.permission_overwrites?.length) {
|
|
99
99
|
bulkData.push(['overwrites', channel.permission_overwrites, channel.id, id]);
|
|
100
|
+
}
|
|
100
101
|
}
|
|
101
102
|
for (const emoji of data.emojis ?? []) {
|
|
102
103
|
bulkData.push(['emojis', emoji, emoji.id, id]);
|
|
@@ -3,7 +3,7 @@ import { PermissionsBitField } from '../../structures/extra/Permissions';
|
|
|
3
3
|
import { GuildRelatedResource } from './default/guild-related';
|
|
4
4
|
export declare class Overwrites extends GuildRelatedResource {
|
|
5
5
|
namespace: string;
|
|
6
|
-
parse(data: any, _id: string,
|
|
6
|
+
parse(data: any[], _id: string, guild_id: string): any[];
|
|
7
7
|
get(id: string): ReturnCache<{
|
|
8
8
|
type: number;
|
|
9
9
|
id: string;
|
|
@@ -6,7 +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
|
-
parse(data, _id,
|
|
9
|
+
parse(data, _id, guild_id) {
|
|
10
|
+
data.forEach(x => {
|
|
11
|
+
x.guild_id = guild_id;
|
|
12
|
+
});
|
|
10
13
|
return data;
|
|
11
14
|
}
|
|
12
15
|
get(id) {
|
|
@@ -16,6 +19,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
|
16
19
|
deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
|
|
17
20
|
id: rawOverwrite.id,
|
|
18
21
|
type: rawOverwrite.type,
|
|
22
|
+
guildId: rawOverwrite.guild_id,
|
|
19
23
|
}))
|
|
20
24
|
: undefined);
|
|
21
25
|
}
|
|
@@ -25,6 +29,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
|
25
29
|
deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
|
|
26
30
|
id: rawOverwrite.id,
|
|
27
31
|
type: rawOverwrite.type,
|
|
32
|
+
guildId: rawOverwrite.guild_id,
|
|
28
33
|
}))));
|
|
29
34
|
}
|
|
30
35
|
bulk(ids) {
|
|
@@ -33,6 +38,7 @@ class Overwrites extends guild_related_1.GuildRelatedResource {
|
|
|
33
38
|
deny: new Permissions_1.PermissionsBitField(BigInt(rawOverwrite.deny)),
|
|
34
39
|
id: rawOverwrite.id,
|
|
35
40
|
type: rawOverwrite.type,
|
|
41
|
+
guildId: rawOverwrite.guild_id,
|
|
36
42
|
}))));
|
|
37
43
|
}
|
|
38
44
|
}
|
package/lib/client/base.d.ts
CHANGED
|
@@ -2,178 +2,26 @@ import { ApiHandler } from '../api';
|
|
|
2
2
|
import type { Adapter } from '../cache';
|
|
3
3
|
import { Cache } from '../cache';
|
|
4
4
|
import type { RegisteredMiddlewares } from '../commands';
|
|
5
|
-
import type { MiddlewareContext } from '../commands/applications/shared';
|
|
5
|
+
import type { InferWithPrefix, MiddlewareContext } from '../commands/applications/shared';
|
|
6
6
|
import { CommandHandler } from '../commands/handler';
|
|
7
|
-
import { Logger, type LocaleString, type MakeRequired } from '../common';
|
|
8
|
-
import type { DeepPartial, IntentStrings, OmitInsert } from '../common/types/util';
|
|
7
|
+
import { ChannelShorter, EmojiShorter, GuildShorter, Logger, MemberShorter, MessageShorter, ReactionShorter, RoleShorter, TemplateShorter, UsersShorter, WebhookShorter, type LocaleString, type MakeRequired } from '../common';
|
|
8
|
+
import type { DeepPartial, IntentStrings, OmitInsert, When } from '../common/types/util';
|
|
9
9
|
import { ComponentHandler } from '../components/handler';
|
|
10
10
|
import { LangsHandler } from '../langs/handler';
|
|
11
|
-
import type { ChatInputCommandInteraction, MessageCommandInteraction, UserCommandInteraction } from '../structures';
|
|
11
|
+
import type { ChatInputCommandInteraction, Message, MessageCommandInteraction, UserCommandInteraction } from '../structures';
|
|
12
12
|
export declare class BaseClient {
|
|
13
13
|
rest: ApiHandler;
|
|
14
14
|
cache: Cache;
|
|
15
|
-
users:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
reason: string;
|
|
26
|
-
}>) => Promise<import("../structures").AllChannels>;
|
|
27
|
-
edit: (id: string, body: import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelJSONBody, optional?: Partial<{
|
|
28
|
-
guildId: string;
|
|
29
|
-
reason: string;
|
|
30
|
-
}>) => Promise<import("../structures").AllChannels>;
|
|
31
|
-
typing: (id: string) => Promise<never>;
|
|
32
|
-
pins: {
|
|
33
|
-
fetch: (channelId: string) => Promise<import("../structures").Message[]>;
|
|
34
|
-
set: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
|
|
35
|
-
delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<never>;
|
|
36
|
-
};
|
|
37
|
-
overwrites: {
|
|
38
|
-
memberPermissions: (channelId: string, member: import("../structures").GuildMember, checkAdmin?: boolean) => Promise<import("../structures/extra/Permissions").PermissionsBitField>;
|
|
39
|
-
overwritesFor: (channelId: string, member: import("../structures").GuildMember) => Promise<{
|
|
40
|
-
everyone: {
|
|
41
|
-
type: number;
|
|
42
|
-
id: string;
|
|
43
|
-
deny: import("../structures/extra/Permissions").PermissionsBitField;
|
|
44
|
-
allow: import("../structures/extra/Permissions").PermissionsBitField;
|
|
45
|
-
} | undefined;
|
|
46
|
-
roles: {
|
|
47
|
-
type: number;
|
|
48
|
-
id: string;
|
|
49
|
-
deny: import("../structures/extra/Permissions").PermissionsBitField;
|
|
50
|
-
allow: import("../structures/extra/Permissions").PermissionsBitField;
|
|
51
|
-
}[];
|
|
52
|
-
member: {
|
|
53
|
-
type: number;
|
|
54
|
-
id: string;
|
|
55
|
-
deny: import("../structures/extra/Permissions").PermissionsBitField;
|
|
56
|
-
allow: import("../structures/extra/Permissions").PermissionsBitField;
|
|
57
|
-
} | undefined;
|
|
58
|
-
}>;
|
|
59
|
-
rolePermissions: (channelId: string, role: import("../structures").GuildRole, checkAdmin?: boolean) => Promise<import("../structures/extra/Permissions").PermissionsBitField>;
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
guilds: {
|
|
63
|
-
create: (body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildsJSONBody) => Promise<import("../structures").Guild<"api">>;
|
|
64
|
-
fetch: (id: string, force?: boolean) => Promise<import("../structures").Guild<"cached"> | import("../structures").Guild<"api">>;
|
|
65
|
-
widgetURL: (id: string, style?: import("discord-api-types/payloads/v10/guild").GuildWidgetStyle | undefined) => Promise<import("discord-api-types/payloads/v10/guild").APIGuildWidgetSettings>;
|
|
66
|
-
list: (query?: import("discord-api-types/rest/v10/user").RESTGetAPICurrentUserGuildsQuery | undefined) => Promise<import("../structures").AnonymousGuild[]>;
|
|
67
|
-
fetchSelf: (id: string) => Promise<import("../structures").GuildMember>;
|
|
68
|
-
leave: (id: string) => Promise<void | undefined>;
|
|
69
|
-
channels: {
|
|
70
|
-
list: (guildId: string, force?: boolean) => Promise<import("../structures").AllChannels[]>;
|
|
71
|
-
fetch: (guildId: string, channelId: string, force?: boolean | undefined) => Promise<import("../structures").AllChannels>;
|
|
72
|
-
create: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildChannelJSONBody) => Promise<import("../structures").AllChannels>;
|
|
73
|
-
delete: (guildId: string, channelId: string, reason?: string | undefined) => Promise<import("../structures").AllChannels>;
|
|
74
|
-
edit: (guildchannelId: string, channelId: string, body: import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelJSONBody, reason?: string | undefined) => Promise<import("../structures").AllChannels>;
|
|
75
|
-
editPositions: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildChannelPositionsJSONBody) => Promise<never>;
|
|
76
|
-
};
|
|
77
|
-
moderation: {
|
|
78
|
-
list: (guildId: string) => Promise<import("discord-api-types/rest/v10/autoModeration").RESTGetAPIAutoModerationRulesResult>;
|
|
79
|
-
create: (guildId: string, body: import("discord-api-types/rest/v10/autoModeration").RESTPostAPIAutoModerationRuleJSONBody) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
|
|
80
|
-
delete: (guildId: string, ruleId: string, reason?: string | undefined) => Promise<never>;
|
|
81
|
-
fetch: (guildId: string, ruleId: string) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
|
|
82
|
-
edit: (guildId: string, ruleId: string, body: {
|
|
83
|
-
name?: string | undefined;
|
|
84
|
-
eventType?: import("discord-api-types/payloads/v10/autoModeration").AutoModerationRuleEventType | undefined;
|
|
85
|
-
triggerMetadata?: import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRuleTriggerMetadata | undefined;
|
|
86
|
-
actions?: import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationAction[] | undefined;
|
|
87
|
-
enabled?: boolean | undefined;
|
|
88
|
-
exemptRoles?: string[] | undefined;
|
|
89
|
-
exemptChannels?: string[] | undefined;
|
|
90
|
-
}, reason?: string | undefined) => Promise<import("discord-api-types/payloads/v10/autoModeration").APIAutoModerationRule>;
|
|
91
|
-
};
|
|
92
|
-
stickers: {
|
|
93
|
-
list: (guildId: string) => Promise<import("../structures").Sticker[]>;
|
|
94
|
-
create: (guildId: string, { file, ...json }: import("../structures").CreateStickerBodyRequest, reason?: string | undefined) => Promise<import("../structures").Sticker>;
|
|
95
|
-
edit: (guildId: string, stickerId: string, body: import("discord-api-types/rest/v10/sticker").RESTPatchAPIGuildStickerJSONBody, reason?: string | undefined) => Promise<import("../structures").Sticker>;
|
|
96
|
-
fetch: (guildId: string, stickerId: string, force?: boolean) => Promise<import("../structures").Sticker>;
|
|
97
|
-
delete: (guildId: string, stickerId: string, reason?: string | undefined) => Promise<void>;
|
|
98
|
-
};
|
|
99
|
-
emojis: {
|
|
100
|
-
list: (guildId: string, force?: boolean) => Promise<import("../structures").GuildEmoji[]>;
|
|
101
|
-
create: (guildId: string, body: Omit<import("discord-api-types/rest/v10/emoji").RESTPostAPIGuildEmojiJSONBody, "image"> & {
|
|
102
|
-
image: import("../common").ImageResolvable;
|
|
103
|
-
}) => Promise<void>;
|
|
104
|
-
fetch: (guildId: string, emojiId: string, force?: boolean) => Promise<import("../structures").GuildEmoji>;
|
|
105
|
-
delete: (guildId: string, emojiId: string, reason?: string | undefined) => Promise<void>;
|
|
106
|
-
edit: (guildId: string, emojiId: string, body: import("discord-api-types/rest/v10/emoji").RESTPatchAPIGuildEmojiJSONBody, reason?: string | undefined) => Promise<import("../structures").GuildEmoji>;
|
|
107
|
-
};
|
|
108
|
-
};
|
|
109
|
-
messages: {
|
|
110
|
-
write: (channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPostAPIChannelMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
|
|
111
|
-
edit: (messageId: string, channelId: string, { files, ...body }: Omit<import("discord-api-types/rest/v10/channel").RESTPatchAPIChannelMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps) => Promise<import("../structures").Message>;
|
|
112
|
-
crosspost: (messageId: string, channelId: string, reason?: string | undefined) => Promise<import("../structures").Message>;
|
|
113
|
-
delete: (messageId: string, channelId: string, reason?: string | undefined) => Promise<void>;
|
|
114
|
-
fetch: (messageId: string, channelId: string) => Promise<import("../structures").Message>;
|
|
115
|
-
purge: (messages: string[], channelId: string, reason?: string | undefined) => Promise<never>;
|
|
116
|
-
reactions: {
|
|
117
|
-
add: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable) => Promise<never>;
|
|
118
|
-
delete: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable, userId?: string) => Promise<never>;
|
|
119
|
-
fetch: (messageId: string, channelId: string, emoji: import("../common").EmojiResolvable, query?: import("discord-api-types/rest/v10/channel").RESTGetAPIChannelMessageReactionUsersQuery | undefined) => Promise<import("../structures").User[]>;
|
|
120
|
-
purge: (messageId: string, channelId: string, emoji?: import("../common").EmojiResolvable | undefined) => Promise<never>;
|
|
121
|
-
};
|
|
122
|
-
};
|
|
123
|
-
members: {
|
|
124
|
-
resolve: (guildId: string, resolve: import("../common").GuildMemberResolvable) => Promise<import("../structures").GuildMember | undefined>;
|
|
125
|
-
search: (guildId: string, query?: import("discord-api-types/rest/v10/guild").RESTGetAPIGuildMembersSearchQuery | undefined) => Promise<import("../structures").GuildMember[]>;
|
|
126
|
-
unban: (guildId: string, memberId: string, body?: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildBanJSONBody | undefined, reason?: string | undefined) => Promise<void>;
|
|
127
|
-
ban: (guildId: string, memberId: string, body?: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildBanJSONBody | undefined, reason?: string | undefined) => Promise<void>;
|
|
128
|
-
kick: (guildId: string, memberId: string, reason?: string | undefined) => Promise<void>;
|
|
129
|
-
edit: (guildId: string, memberId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildMemberJSONBody, reason?: string | undefined) => Promise<import("../structures").GuildMember>;
|
|
130
|
-
add: (guildId: string, memberId: string, body: import("discord-api-types/rest/v10/guild").RESTPutAPIGuildMemberJSONBody) => Promise<import("../structures").GuildMember | undefined>;
|
|
131
|
-
fetch: (guildId: string, memberId: string, force?: boolean) => Promise<import("../structures").GuildMember>;
|
|
132
|
-
list: (guildId: string, query?: import("discord-api-types/rest/v10/guild").RESTGetAPIGuildMembersQuery | undefined, force?: boolean) => Promise<import("../structures").GuildMember[]>;
|
|
133
|
-
roles: {
|
|
134
|
-
add: (guildId: string, memberId: string, id: string) => Promise<void>;
|
|
135
|
-
remove: (guildId: string, memberId: string, id: string) => Promise<void>;
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
webhooks: {
|
|
139
|
-
delete: (webhookId: string, { token, reason }: Partial<{
|
|
140
|
-
token: string;
|
|
141
|
-
reason: string;
|
|
142
|
-
}>) => Promise<never>;
|
|
143
|
-
edit: (webhookId: string, body: import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookJSONBody | import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenJSONBody, { token, reason }: Partial<{
|
|
144
|
-
token: string;
|
|
145
|
-
reason: string;
|
|
146
|
-
}>) => Promise<import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenResult>;
|
|
147
|
-
fetch: (webhookId: string, token?: string | undefined) => Promise<import("../structures").Webhook>;
|
|
148
|
-
messages: {
|
|
149
|
-
write: (webhookId: string, token: string, { body: data, ...payload }: {
|
|
150
|
-
body: Omit<import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenJSONBody, "components" | "embeds"> & import("../common").ResolverProps;
|
|
151
|
-
query?: import("discord-api-types/rest/v10/webhook").RESTPostAPIWebhookWithTokenQuery | undefined;
|
|
152
|
-
}) => Promise<import("../structures").WebhookMessage | null>;
|
|
153
|
-
edit: (webhookId: string, token: string, { messageId, body: data, ...json }: {
|
|
154
|
-
body: Omit<import("discord-api-types/rest/v10/webhook").RESTPatchAPIWebhookWithTokenMessageJSONBody, "components" | "embeds"> & import("../common").ResolverProps;
|
|
155
|
-
messageId: string;
|
|
156
|
-
query?: import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenMessageQuery | undefined;
|
|
157
|
-
}) => Promise<import("../structures").WebhookMessage>;
|
|
158
|
-
delete: (webhookId: string, token: string, messageId: string, reason?: string | undefined) => Promise<never>;
|
|
159
|
-
fetch: (webhookId: string, token: string, messageId: string, threadId?: string | undefined) => Promise<import("../structures").WebhookMessage | undefined>;
|
|
160
|
-
};
|
|
161
|
-
};
|
|
162
|
-
templates: {
|
|
163
|
-
fetch: (code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
164
|
-
list: (guildId: string) => Promise<import("discord-api-types/rest/v10/template").RESTGetAPIGuildTemplatesResult>;
|
|
165
|
-
create: (guildId: string, body: import("discord-api-types/rest/v10/template").RESTPostAPIGuildTemplatesJSONBody) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
166
|
-
sync: (guildId: string, code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
167
|
-
edit: (guildId: string, code: string, body: import("discord-api-types/utils/internals").AddUndefinedToPossiblyUndefinedPropertiesOfInterface<Partial<import("discord-api-types/rest/v10/template").RESTPostAPIGuildTemplatesJSONBody>>) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
168
|
-
delete: (guildId: string, code: string) => Promise<import("discord-api-types/payloads/v10/template").APITemplate>;
|
|
169
|
-
};
|
|
170
|
-
roles: {
|
|
171
|
-
create: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPostAPIGuildRoleJSONBody, reason?: string | undefined) => Promise<any>;
|
|
172
|
-
list: (guildId: string, force?: boolean) => Promise<import("../structures").GuildRole[]>;
|
|
173
|
-
edit: (guildId: string, roleId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildRoleJSONBody, reason?: string | undefined) => Promise<any>;
|
|
174
|
-
delete: (guildId: string, roleId: string, reason?: string | undefined) => Promise<void | undefined>;
|
|
175
|
-
editPositions: (guildId: string, body: import("discord-api-types/rest/v10/guild").RESTPatchAPIGuildRolePositionsJSONBody) => Promise<import("../structures").GuildRole[]>;
|
|
176
|
-
};
|
|
15
|
+
users: UsersShorter;
|
|
16
|
+
channels: ChannelShorter;
|
|
17
|
+
guilds: GuildShorter;
|
|
18
|
+
messages: MessageShorter;
|
|
19
|
+
members: MemberShorter;
|
|
20
|
+
webhooks: WebhookShorter;
|
|
21
|
+
templates: TemplateShorter;
|
|
22
|
+
roles: RoleShorter;
|
|
23
|
+
reactions: ReactionShorter;
|
|
24
|
+
emojis: EmojiShorter;
|
|
177
25
|
debugger?: Logger;
|
|
178
26
|
logger: Logger;
|
|
179
27
|
langs: LangsHandler;
|
|
@@ -215,7 +63,7 @@ export declare class BaseClient {
|
|
|
215
63
|
}>;
|
|
216
64
|
}
|
|
217
65
|
export interface BaseClientOptions {
|
|
218
|
-
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean>) => {};
|
|
66
|
+
context?: (interaction: ChatInputCommandInteraction<boolean> | UserCommandInteraction<boolean> | MessageCommandInteraction<boolean> | When<InferWithPrefix, Message, never>) => {};
|
|
219
67
|
globalMiddlewares?: readonly (keyof RegisteredMiddlewares)[];
|
|
220
68
|
}
|
|
221
69
|
export interface StartOptions {
|
|
@@ -261,17 +109,16 @@ export type InternalRuntimeConfig = Omit<MakeRequired<RC, 'intents'>, 'publicKey
|
|
|
261
109
|
export type RuntimeConfig = OmitInsert<InternalRuntimeConfig, 'intents', {
|
|
262
110
|
intents?: IntentStrings | number;
|
|
263
111
|
}>;
|
|
264
|
-
export
|
|
112
|
+
export interface ServicesOptions {
|
|
265
113
|
rest?: ApiHandler;
|
|
266
114
|
cache?: {
|
|
267
|
-
adapter
|
|
115
|
+
adapter?: Adapter;
|
|
268
116
|
disabledCache?: Cache['disabledCache'];
|
|
269
|
-
asyncCache?: boolean;
|
|
270
117
|
};
|
|
271
118
|
langs?: {
|
|
272
119
|
default?: string;
|
|
273
120
|
aliases?: Record<string, LocaleString[]>;
|
|
274
121
|
};
|
|
275
122
|
middlewares?: Record<string, MiddlewareContext>;
|
|
276
|
-
}
|
|
123
|
+
}
|
|
277
124
|
export {};
|
package/lib/client/base.js
CHANGED
|
@@ -6,24 +6,21 @@ const api_1 = require("../api");
|
|
|
6
6
|
const cache_1 = require("../cache");
|
|
7
7
|
const handler_1 = require("../commands/handler");
|
|
8
8
|
const common_1 = require("../common");
|
|
9
|
-
const members_1 = require("../common/shorters/members");
|
|
10
|
-
const messages_1 = require("../common/shorters/messages");
|
|
11
|
-
const roles_1 = require("../common/shorters/roles");
|
|
12
|
-
const templates_1 = require("../common/shorters/templates");
|
|
13
|
-
const webhook_1 = require("../common/shorters/webhook");
|
|
14
9
|
const handler_2 = require("../components/handler");
|
|
15
10
|
const handler_3 = require("../langs/handler");
|
|
16
11
|
class BaseClient {
|
|
17
12
|
rest;
|
|
18
13
|
cache;
|
|
19
|
-
users = new common_1.UsersShorter(this)
|
|
20
|
-
channels = new common_1.ChannelShorter(this)
|
|
21
|
-
guilds = new common_1.GuildShorter(this)
|
|
22
|
-
messages = new
|
|
23
|
-
members = new
|
|
24
|
-
webhooks = new
|
|
25
|
-
templates = new
|
|
26
|
-
roles = new
|
|
14
|
+
users = new common_1.UsersShorter(this);
|
|
15
|
+
channels = new common_1.ChannelShorter(this);
|
|
16
|
+
guilds = new common_1.GuildShorter(this);
|
|
17
|
+
messages = new common_1.MessageShorter(this);
|
|
18
|
+
members = new common_1.MemberShorter(this);
|
|
19
|
+
webhooks = new common_1.WebhookShorter(this);
|
|
20
|
+
templates = new common_1.TemplateShorter(this);
|
|
21
|
+
roles = new common_1.RoleShorter(this);
|
|
22
|
+
reactions = new common_1.ReactionShorter(this);
|
|
23
|
+
emojis = new common_1.EmojiShorter(this);
|
|
27
24
|
debugger;
|
|
28
25
|
logger = new common_1.Logger({
|
|
29
26
|
name: '[Seyfert]',
|
|
@@ -66,7 +63,7 @@ class BaseClient {
|
|
|
66
63
|
this.rest = rest;
|
|
67
64
|
}
|
|
68
65
|
if (cache) {
|
|
69
|
-
this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache
|
|
66
|
+
this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache?.adapter ?? this.cache?.adapter ?? new cache_1.MemoryAdapter(), cache.disabledCache ?? this.cache?.disabledCache ?? [], this);
|
|
70
67
|
}
|
|
71
68
|
if (langs) {
|
|
72
69
|
if (langs.default)
|
|
@@ -108,7 +105,7 @@ class BaseClient {
|
|
|
108
105
|
});
|
|
109
106
|
}
|
|
110
107
|
if (!this.cache) {
|
|
111
|
-
this.cache = new cache_1.Cache(0, new cache_1.MemoryAdapter(),
|
|
108
|
+
this.cache = new cache_1.Cache(0, new cache_1.MemoryAdapter(), [], this);
|
|
112
109
|
}
|
|
113
110
|
else {
|
|
114
111
|
this.cache.__setClient(this);
|
package/lib/client/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command, CommandContext, Message, SubCommand } from '..';
|
|
2
|
-
import type
|
|
2
|
+
import { type DeepPartial, type GatewayDispatchPayload, type GatewayPresenceUpdateData, type If } from '../common';
|
|
3
3
|
import { EventHandler } from '../events';
|
|
4
4
|
import { ClientUser } from '../structures';
|
|
5
5
|
import { ShardManager, type ShardManagerOptions } from '../websocket';
|
|
@@ -32,6 +32,11 @@ export interface ClientOptions extends BaseClientOptions {
|
|
|
32
32
|
shards?: {
|
|
33
33
|
start: number;
|
|
34
34
|
end: number;
|
|
35
|
+
total?: number;
|
|
36
|
+
};
|
|
37
|
+
gateway?: {
|
|
38
|
+
properties?: Partial<ShardManagerOptions['properties']>;
|
|
39
|
+
compress?: ShardManagerOptions['compress'];
|
|
35
40
|
};
|
|
36
41
|
commands?: {
|
|
37
42
|
prefix: (message: Message) => Promise<string[]> | string[];
|
package/lib/client/client.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Client = void 0;
|
|
4
4
|
const node_worker_threads_1 = require("node:worker_threads");
|
|
5
|
+
const common_1 = require("../common");
|
|
5
6
|
const events_1 = require("../events");
|
|
6
7
|
const structures_1 = require("../structures");
|
|
7
8
|
const websocket_1 = require("../websocket");
|
|
@@ -11,7 +12,7 @@ const base_1 = require("./base");
|
|
|
11
12
|
const oninteractioncreate_1 = require("./oninteractioncreate");
|
|
12
13
|
const onmessagecreate_1 = require("./onmessagecreate");
|
|
13
14
|
class Client extends base_1.BaseClient {
|
|
14
|
-
__handleGuilds;
|
|
15
|
+
__handleGuilds = new Set();
|
|
15
16
|
gateway;
|
|
16
17
|
events = new events_1.EventHandler(this.logger);
|
|
17
18
|
me;
|
|
@@ -21,7 +22,6 @@ class Client extends base_1.BaseClient {
|
|
|
21
22
|
super(options);
|
|
22
23
|
}
|
|
23
24
|
setServices({ gateway, ...rest }) {
|
|
24
|
-
this.__handleGuilds = new Set();
|
|
25
25
|
super.setServices(rest);
|
|
26
26
|
if (gateway) {
|
|
27
27
|
const onPacket = this.onPacket.bind(this);
|
|
@@ -77,7 +77,10 @@ class Client extends base_1.BaseClient {
|
|
|
77
77
|
presence: this.options?.presence,
|
|
78
78
|
debug: debugRC,
|
|
79
79
|
shardStart: this.options?.shards?.start,
|
|
80
|
-
shardEnd: this.options?.shards?.end,
|
|
80
|
+
shardEnd: this.options?.shards?.end ?? this.options?.shards?.total,
|
|
81
|
+
totalShards: this.options?.shards?.total ?? this.options?.shards?.end,
|
|
82
|
+
properties: { ...this.options?.gateway?.properties, ...websocket_1.properties },
|
|
83
|
+
compress: this.options?.gateway?.compress,
|
|
81
84
|
});
|
|
82
85
|
}
|
|
83
86
|
this.cache.intents = this.gateway.options.intents;
|
|
@@ -123,25 +126,23 @@ class Client extends base_1.BaseClient {
|
|
|
123
126
|
this.botId = packet.d.user.id;
|
|
124
127
|
this.applicationId = packet.d.application.id;
|
|
125
128
|
this.me = new structures_1.ClientUser(this, packet.d.user, packet.d.application);
|
|
126
|
-
if (!this.__handleGuilds?.size
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
(this.events.values.BOT_READY.fired ? !this.events.values.BOT_READY.data.once : true)) {
|
|
129
|
+
if (!this.__handleGuilds?.size ||
|
|
130
|
+
!((this.gateway.options.intents & common_1.GatewayIntentBits.Guilds) === common_1.GatewayIntentBits.Guilds)) {
|
|
131
|
+
if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
130
132
|
await this.events.runEvent('BOT_READY', this, this.me, -1);
|
|
131
|
-
delete this.__handleGuilds;
|
|
132
133
|
}
|
|
134
|
+
delete this.__handleGuilds;
|
|
133
135
|
}
|
|
134
136
|
this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
|
|
135
137
|
break;
|
|
136
138
|
case 'GUILD_CREATE': {
|
|
137
139
|
if (this.__handleGuilds?.has(packet.d.id)) {
|
|
138
140
|
this.__handleGuilds.delete(packet.d.id);
|
|
139
|
-
if (!this.__handleGuilds.size &&
|
|
140
|
-
[...this.gateway.values()].every(shard => shard.data.session_id) &&
|
|
141
|
-
this.events.values.BOT_READY &&
|
|
142
|
-
(this.events.values.BOT_READY.fired ? !this.events.values.BOT_READY.data.once : true)) {
|
|
141
|
+
if (!this.__handleGuilds.size && [...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
143
142
|
await this.events.runEvent('BOT_READY', this, this.me, -1);
|
|
144
143
|
}
|
|
144
|
+
if (!this.__handleGuilds.size)
|
|
145
|
+
delete this.__handleGuilds;
|
|
145
146
|
return;
|
|
146
147
|
}
|
|
147
148
|
break;
|
|
@@ -57,7 +57,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
57
57
|
// idc, is a YOU problem
|
|
58
58
|
if (!command?.run)
|
|
59
59
|
return self.logger.warn(`${command.name ?? 'Unknown'} command does not have 'run' callback`);
|
|
60
|
-
const context = new commands_1.MenuCommandContext(self, interaction, shardId);
|
|
60
|
+
const context = new commands_1.MenuCommandContext(self, interaction, shardId, command);
|
|
61
61
|
const extendContext = self.options?.context?.(interaction) ?? {};
|
|
62
62
|
Object.assign(context, extendContext);
|
|
63
63
|
try {
|
|
@@ -114,7 +114,7 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
114
114
|
const command = optionsResolver.getCommand();
|
|
115
115
|
if (!command?.run)
|
|
116
116
|
return self.logger.warn(`${optionsResolver.fullCommandName} command does not have 'run' callback`);
|
|
117
|
-
const context = new commands_1.CommandContext(self, interaction, optionsResolver, shardId);
|
|
117
|
+
const context = new commands_1.CommandContext(self, interaction, optionsResolver, shardId, command);
|
|
118
118
|
const extendContext = self.options?.context?.(interaction) ?? {};
|
|
119
119
|
Object.assign(context, extendContext);
|
|
120
120
|
try {
|
|
@@ -178,8 +178,8 @@ async function onInteractionCreate(self, body, shardId, __reply) {
|
|
|
178
178
|
case v10_1.InteractionType.MessageComponent:
|
|
179
179
|
{
|
|
180
180
|
const interaction = structures_1.BaseInteraction.from(self, body, __reply);
|
|
181
|
-
if (self.components.hasComponent(
|
|
182
|
-
await self.components.onComponent(
|
|
181
|
+
if (self.components.hasComponent(body.message.id, interaction.customId)) {
|
|
182
|
+
await self.components.onComponent(body.message.id, interaction);
|
|
183
183
|
}
|
|
184
184
|
else {
|
|
185
185
|
await self.components.executeComponent(interaction);
|