seyfert 2.1.0 → 2.1.1-dev-11316886063.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/Router.d.ts +2 -2
- package/lib/api/Router.js +2 -1
- package/lib/api/Routes/applications.d.ts +29 -30
- package/lib/api/Routes/cdn.d.ts +6 -1
- package/lib/api/Routes/channels.d.ts +44 -45
- package/lib/api/Routes/gateway.d.ts +3 -4
- package/lib/api/Routes/guilds.d.ts +81 -80
- package/lib/api/Routes/index.d.ts +3 -1
- package/lib/api/Routes/interactions.d.ts +6 -6
- package/lib/api/Routes/invites.d.ts +3 -4
- package/lib/api/Routes/skus.d.ts +4 -5
- package/lib/api/Routes/soundboard.d.ts +23 -0
- package/lib/api/Routes/soundboard.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +5 -6
- package/lib/api/Routes/stickers.d.ts +3 -4
- package/lib/api/Routes/users.d.ts +11 -12
- package/lib/api/Routes/voice.d.ts +2 -3
- package/lib/api/Routes/webhooks.d.ts +16 -15
- package/lib/api/api.d.ts +17 -11
- package/lib/api/api.js +12 -10
- package/lib/api/shared.d.ts +1 -1
- package/lib/api/utils/constants.d.ts +2 -0
- package/lib/api/utils/constants.js +2 -1
- package/lib/builders/ActionRow.d.ts +1 -1
- package/lib/builders/Attachment.d.ts +2 -2
- package/lib/builders/Attachment.js +1 -1
- package/lib/builders/Button.d.ts +1 -1
- package/lib/builders/Button.js +1 -1
- package/lib/builders/Embed.d.ts +1 -1
- package/lib/builders/Embed.js +2 -2
- package/lib/builders/Modal.d.ts +1 -1
- package/lib/builders/Poll.d.ts +1 -1
- package/lib/builders/Poll.js +1 -1
- package/lib/builders/SelectMenu.d.ts +1 -1
- package/lib/builders/SelectMenu.js +1 -1
- package/lib/builders/types.d.ts +2 -1
- package/lib/cache/adapters/default.js +5 -3
- package/lib/cache/adapters/limited.d.ts +1 -2
- package/lib/cache/adapters/limited.js +34 -30
- package/lib/cache/adapters/workeradapter.js +3 -1
- package/lib/cache/index.d.ts +8 -11
- package/lib/cache/index.js +38 -37
- package/lib/cache/resources/bans.d.ts +2 -2
- package/lib/cache/resources/bans.js +1 -1
- package/lib/cache/resources/channels.d.ts +1 -1
- package/lib/cache/resources/default/guild-related.d.ts +1 -2
- package/lib/cache/resources/emojis.d.ts +2 -2
- package/lib/cache/resources/emojis.js +1 -1
- package/lib/cache/resources/guilds.d.ts +2 -2
- package/lib/cache/resources/guilds.js +7 -11
- package/lib/cache/resources/members.d.ts +2 -2
- package/lib/cache/resources/members.js +1 -1
- package/lib/cache/resources/messages.d.ts +2 -2
- package/lib/cache/resources/messages.js +3 -3
- package/lib/cache/resources/overwrites.d.ts +1 -1
- package/lib/cache/resources/roles.d.ts +2 -2
- package/lib/cache/resources/roles.js +1 -1
- package/lib/cache/resources/stickers.d.ts +2 -2
- package/lib/cache/resources/stickers.js +1 -1
- package/lib/cache/resources/users.d.ts +2 -2
- package/lib/cache/resources/users.js +1 -1
- package/lib/cache/resources/voice-states.d.ts +2 -2
- package/lib/cache/resources/voice-states.js +1 -1
- package/lib/client/base.d.ts +9 -14
- package/lib/client/base.js +43 -44
- package/lib/client/client.d.ts +3 -7
- package/lib/client/client.js +24 -41
- package/lib/client/collectors.js +1 -1
- package/lib/client/httpclient.d.ts +1 -1
- package/lib/client/transformers.d.ts +37 -34
- package/lib/client/transformers.js +66 -63
- package/lib/client/workerclient.d.ts +10 -11
- package/lib/client/workerclient.js +180 -75
- package/lib/collection.d.ts +3 -3
- package/lib/commands/applications/chat.d.ts +12 -32
- package/lib/commands/applications/chat.js +5 -6
- package/lib/commands/applications/chatcontext.d.ts +6 -6
- package/lib/commands/applications/chatcontext.js +16 -8
- package/lib/commands/applications/entryPoint.d.ts +1 -1
- package/lib/commands/applications/entrycontext.d.ts +6 -6
- package/lib/commands/applications/entrycontext.js +4 -4
- package/lib/commands/applications/menu.d.ts +1 -1
- package/lib/commands/applications/menucontext.d.ts +5 -5
- package/lib/commands/applications/menucontext.js +6 -6
- package/lib/commands/applications/options.d.ts +104 -28
- package/lib/commands/applications/options.js +4 -4
- package/lib/commands/applications/shared.d.ts +5 -2
- package/lib/commands/basecontext.d.ts +1 -1
- package/lib/commands/decorators.d.ts +10 -10
- package/lib/commands/decorators.js +5 -4
- package/lib/commands/handle.d.ts +9 -9
- package/lib/commands/handle.js +94 -68
- package/lib/commands/handler.d.ts +5 -5
- package/lib/commands/handler.js +21 -17
- package/lib/commands/optionresolver.d.ts +4 -4
- package/lib/commands/optionresolver.js +3 -3
- package/lib/common/it/formatter.d.ts +21 -21
- package/lib/common/it/formatter.js +40 -41
- package/lib/common/it/logger.js +1 -1
- package/lib/common/it/utils.d.ts +4 -3
- package/lib/common/it/utils.js +52 -27
- package/lib/common/shorters/application.d.ts +2 -3
- package/lib/common/shorters/application.js +3 -3
- package/lib/common/shorters/bans.js +1 -1
- package/lib/common/shorters/channels.d.ts +3 -3
- package/lib/common/shorters/channels.js +3 -3
- package/lib/common/shorters/emojis.js +4 -4
- package/lib/common/shorters/guilds.d.ts +3 -3
- package/lib/common/shorters/guilds.js +5 -9
- package/lib/common/shorters/interaction.d.ts +3 -3
- package/lib/common/shorters/interaction.js +6 -5
- package/lib/common/shorters/members.d.ts +4 -5
- package/lib/common/shorters/members.js +6 -7
- package/lib/common/shorters/messages.d.ts +1 -1
- package/lib/common/shorters/messages.js +4 -4
- package/lib/common/shorters/reactions.d.ts +1 -1
- package/lib/common/shorters/reactions.js +1 -1
- package/lib/common/shorters/roles.js +1 -1
- package/lib/common/shorters/templates.js +2 -2
- package/lib/common/shorters/threads.d.ts +1 -1
- package/lib/common/shorters/threads.js +17 -11
- package/lib/common/shorters/webhook.d.ts +1 -1
- package/lib/common/shorters/webhook.js +4 -4
- package/lib/common/types/options.d.ts +2 -2
- package/lib/common/types/resolvables.d.ts +1 -1
- package/lib/common/types/util.d.ts +4 -1
- package/lib/common/types/write.d.ts +1 -1
- package/lib/components/BaseComponent.js +1 -1
- package/lib/components/ButtonComponent.d.ts +1 -1
- package/lib/components/componentcommand.d.ts +1 -1
- package/lib/components/componentcontext.d.ts +4 -4
- package/lib/components/componentcontext.js +1 -1
- package/lib/components/handler.d.ts +10 -8
- package/lib/components/handler.js +16 -13
- package/lib/components/index.js +2 -1
- package/lib/components/modalcontext.d.ts +2 -2
- package/lib/components/modalcontext.js +1 -1
- package/lib/deps/mixer.d.ts +1 -1
- package/lib/events/handler.d.ts +5 -5
- package/lib/events/handler.js +66 -16
- package/lib/events/hooks/application_command.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.d.ts +1 -1
- package/lib/events/hooks/auto_moderation.js +1 -1
- package/lib/events/hooks/channel.d.ts +1 -1
- package/lib/events/hooks/dispatch.d.ts +1 -1
- package/lib/events/hooks/entitlement.d.ts +4 -5
- package/lib/events/hooks/entitlement.js +4 -4
- package/lib/events/hooks/guild.d.ts +3 -3
- package/lib/events/hooks/guild.js +1 -1
- package/lib/events/hooks/index.d.ts +1 -0
- package/lib/events/hooks/index.js +1 -0
- package/lib/events/hooks/integration.d.ts +1 -1
- package/lib/events/hooks/integration.js +1 -1
- package/lib/events/hooks/interactions.d.ts +3 -3
- package/lib/events/hooks/invite.d.ts +1 -1
- package/lib/events/hooks/message.d.ts +3 -3
- package/lib/events/hooks/message.js +1 -1
- package/lib/events/hooks/presence.d.ts +2 -2
- package/lib/events/hooks/soundboard.d.ts +155 -0
- package/lib/events/hooks/soundboard.js +28 -0
- package/lib/events/hooks/stage.d.ts +2 -2
- package/lib/events/hooks/thread.d.ts +2 -2
- package/lib/events/hooks/thread.js +2 -2
- package/lib/events/hooks/typing.d.ts +1 -1
- package/lib/events/hooks/typing.js +1 -1
- package/lib/events/hooks/user.d.ts +2 -2
- package/lib/events/hooks/voice.d.ts +2 -2
- package/lib/events/hooks/voice.js +1 -1
- package/lib/events/hooks/webhook.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +3 -5
- package/lib/langs/handler.d.ts +2 -2
- package/lib/structures/Guild.d.ts +7 -4
- package/lib/structures/Guild.js +1 -1
- package/lib/structures/GuildBan.d.ts +1 -1
- package/lib/structures/GuildMember.d.ts +7 -5
- package/lib/structures/GuildMember.js +5 -3
- package/lib/structures/GuildRole.d.ts +1 -1
- package/lib/structures/GuildTemplate.d.ts +1 -1
- package/lib/structures/Interaction.d.ts +17 -14
- package/lib/structures/Interaction.js +28 -21
- package/lib/structures/Message.d.ts +4 -7
- package/lib/structures/Message.js +5 -5
- package/lib/structures/Poll.d.ts +3 -3
- package/lib/structures/Sticker.d.ts +2 -2
- package/lib/structures/Sticker.js +1 -1
- package/lib/structures/VoiceState.d.ts +2 -1
- package/lib/structures/VoiceState.js +1 -1
- package/lib/structures/Webhook.d.ts +3 -3
- package/lib/structures/Webhook.js +1 -1
- package/lib/structures/channels.d.ts +4 -4
- package/lib/structures/channels.js +6 -5
- package/lib/structures/extra/BitField.d.ts +3 -3
- package/lib/structures/extra/BitField.js +34 -33
- package/lib/structures/extra/DiscordBase.js +1 -1
- package/lib/structures/extra/Permissions.d.ts +2 -0
- package/lib/structures/extra/Permissions.js +21 -0
- package/lib/types/gateway.d.ts +53 -5
- package/lib/types/payloads/_interactions/base.d.ts +1 -1
- package/lib/types/payloads/channel.d.ts +2 -2
- package/lib/types/payloads/guild.d.ts +9 -1
- package/lib/types/payloads/guild.js +8 -0
- package/lib/types/payloads/index.d.ts +1 -0
- package/lib/types/payloads/index.js +1 -0
- package/lib/types/payloads/soundboard.d.ts +23 -0
- package/lib/types/payloads/soundboard.js +5 -0
- package/lib/types/payloads/user.js +0 -1
- package/lib/types/rest/application.d.ts +3 -3
- package/lib/types/rest/auditLog.d.ts +1 -1
- package/lib/types/rest/channel.d.ts +2 -2
- package/lib/types/rest/guild.d.ts +2 -2
- package/lib/types/rest/guildScheduledEvent.d.ts +1 -1
- package/lib/types/rest/index.d.ts +1 -0
- package/lib/types/rest/index.js +1 -0
- package/lib/types/rest/oauth2.d.ts +1 -1
- package/lib/types/rest/poll.d.ts +1 -1
- package/lib/types/rest/soundboard.d.ts +64 -0
- package/lib/types/rest/soundboard.js +2 -0
- package/lib/types/rest/stageInstance.d.ts +1 -1
- package/lib/types/rest/template.d.ts +1 -1
- package/lib/types/rest/user.d.ts +1 -1
- package/lib/types/rest/webhook.d.ts +1 -1
- package/lib/types/utils/index.d.ts +11 -2
- package/lib/types/utils/index.js +10 -2
- package/lib/websocket/SharedTypes.d.ts +11 -2
- package/lib/websocket/constants/index.js +0 -10
- package/lib/websocket/discord/basesocket.d.ts +1 -1
- package/lib/websocket/discord/shard.d.ts +1 -1
- package/lib/websocket/discord/shard.js +25 -16
- package/lib/websocket/discord/sharder.d.ts +9 -6
- package/lib/websocket/discord/sharder.js +91 -74
- package/lib/websocket/discord/shared.d.ts +3 -14
- package/lib/websocket/discord/socket/custom.js +19 -6
- package/lib/websocket/discord/worker.d.ts +8 -2
- package/lib/websocket/discord/workermanager.d.ts +42 -17
- package/lib/websocket/discord/workermanager.js +144 -37
- package/lib/websocket/structures/timeout.d.ts +4 -5
- package/lib/websocket/structures/timeout.js +23 -24
- package/package.json +72 -70
- package/lib/cache/resources/threads.d.ts +0 -14
- package/lib/cache/resources/threads.js +0 -32
package/lib/client/base.js
CHANGED
|
@@ -7,11 +7,11 @@ const cache_1 = require("../cache");
|
|
|
7
7
|
const shared_1 = require("../commands/applications/shared");
|
|
8
8
|
const handler_1 = require("../commands/handler");
|
|
9
9
|
const common_1 = require("../common");
|
|
10
|
-
const handler_2 = require("../components/handler");
|
|
11
|
-
const handler_3 = require("../langs/handler");
|
|
12
10
|
const node_fs_1 = require("node:fs");
|
|
13
|
-
const bans_1 = require("../common/shorters/bans");
|
|
14
11
|
const handle_1 = require("../commands/handle");
|
|
12
|
+
const bans_1 = require("../common/shorters/bans");
|
|
13
|
+
const handler_2 = require("../components/handler");
|
|
14
|
+
const handler_3 = require("../langs/handler");
|
|
15
15
|
class BaseClient {
|
|
16
16
|
rest;
|
|
17
17
|
cache;
|
|
@@ -103,6 +103,9 @@ class BaseClient {
|
|
|
103
103
|
},
|
|
104
104
|
}, options);
|
|
105
105
|
}
|
|
106
|
+
get proxy() {
|
|
107
|
+
return this.rest.proxy;
|
|
108
|
+
}
|
|
106
109
|
set botId(id) {
|
|
107
110
|
this._botId = id;
|
|
108
111
|
}
|
|
@@ -115,57 +118,48 @@ class BaseClient {
|
|
|
115
118
|
get applicationId() {
|
|
116
119
|
return this._applicationId ?? this.botId;
|
|
117
120
|
}
|
|
118
|
-
|
|
119
|
-
return new api_1.Router(this.rest).createProxy();
|
|
120
|
-
}
|
|
121
|
-
setServices({ rest, cache, langs, middlewares, handlers, handleCommand }) {
|
|
121
|
+
setServices({ rest, cache, langs, middlewares, handleCommand }) {
|
|
122
122
|
if (rest) {
|
|
123
123
|
this.rest = rest;
|
|
124
124
|
}
|
|
125
125
|
if (cache) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
126
|
+
const caches = [
|
|
127
|
+
'bans',
|
|
128
|
+
'channels',
|
|
129
|
+
'emojis',
|
|
130
|
+
'guilds',
|
|
131
|
+
'members',
|
|
132
|
+
'messages',
|
|
133
|
+
'onPacket',
|
|
134
|
+
'overwrites',
|
|
135
|
+
'presences',
|
|
136
|
+
'roles',
|
|
137
|
+
'stageInstances',
|
|
138
|
+
'stickers',
|
|
139
|
+
'users',
|
|
140
|
+
'voiceStates',
|
|
141
|
+
];
|
|
142
|
+
let disabledCache = this.cache?.disabledCache ?? {};
|
|
143
|
+
if (typeof cache.disabledCache === 'boolean') {
|
|
144
|
+
for (const i of caches) {
|
|
145
|
+
disabledCache[i] = cache.disabledCache;
|
|
143
146
|
}
|
|
144
147
|
}
|
|
145
|
-
if ('
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
else if (typeof handlers.commands === 'object') {
|
|
150
|
-
this.commands ??= new handler_1.CommandHandler(this.logger, this);
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
this.commands = handlers.commands;
|
|
148
|
+
else if (typeof cache.disabledCache === 'function') {
|
|
149
|
+
for (const i of caches) {
|
|
150
|
+
disabledCache[i] = cache.disabledCache(i);
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
|
-
if ('
|
|
157
|
-
|
|
158
|
-
this.langs = undefined;
|
|
159
|
-
}
|
|
160
|
-
else if (typeof handlers.langs === 'function') {
|
|
161
|
-
this.langs ??= new handler_3.LangsHandler(this.logger);
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
this.langs = handlers.langs;
|
|
165
|
-
}
|
|
153
|
+
else if (typeof cache.disabledCache === 'object') {
|
|
154
|
+
disabledCache = cache.disabledCache;
|
|
166
155
|
}
|
|
156
|
+
this.cache = new cache_1.Cache(this.cache?.intents ?? 0, cache?.adapter ?? this.cache?.adapter ?? new cache_1.MemoryAdapter(), disabledCache, this);
|
|
157
|
+
}
|
|
158
|
+
if (middlewares) {
|
|
159
|
+
this.middlewares = middlewares;
|
|
167
160
|
}
|
|
168
161
|
if (langs) {
|
|
162
|
+
this.langs ??= new handler_3.LangsHandler(this.logger);
|
|
169
163
|
if (langs.default)
|
|
170
164
|
this.langs.defaultLang = langs.default;
|
|
171
165
|
if (langs.aliases)
|
|
@@ -292,7 +286,12 @@ class BaseClient {
|
|
|
292
286
|
async getRC() {
|
|
293
287
|
const seyfertConfig = (BaseClient._seyfertCfWorkerConfig ||
|
|
294
288
|
(await this.options?.getRC?.()) ||
|
|
295
|
-
(await Promise.any(['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'].map(ext => (0, common_1.magicImport)((0, node_path_1.join)(process.cwd(), `seyfert.config${ext}`)).then(x => x.default ?? x))))
|
|
289
|
+
(await Promise.any(['.js', '.mjs', '.cjs', '.ts', '.mts', '.cts'].map(ext => (0, common_1.magicImport)((0, node_path_1.join)(process.cwd(), `seyfert.config${ext}`)).then(x => x.default ?? x))).catch((e) => {
|
|
290
|
+
if (e.errors.every((err) => err.stack?.includes('ERR_MODULE_NOT_FOUND'))) {
|
|
291
|
+
throw new Error('No seyfert.config file found');
|
|
292
|
+
}
|
|
293
|
+
throw e.errors.find((err) => !err.stack?.includes('ERR_MODULE_NOT_FOUND')) ?? e.errors[0];
|
|
294
|
+
})));
|
|
296
295
|
const { locations, debug, ...env } = seyfertConfig;
|
|
297
296
|
const obj = {
|
|
298
297
|
debug: !!debug,
|
package/lib/client/client.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from '../types';
|
|
2
1
|
import type { CommandContext, Message } from '..';
|
|
3
2
|
import { type Awaitable, type DeepPartial, type If } from '../common';
|
|
4
3
|
import { EventHandler } from '../events';
|
|
4
|
+
import { type GatewayDispatchPayload, type GatewayPresenceUpdateData } from '../types';
|
|
5
5
|
import { ShardManager, type ShardManagerOptions } from '../websocket';
|
|
6
6
|
import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
|
|
7
7
|
import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
|
|
@@ -23,9 +23,6 @@ export declare class Client<Ready extends boolean = boolean> extends BaseClient
|
|
|
23
23
|
constructor(options?: ClientOptions);
|
|
24
24
|
setServices({ gateway, ...rest }: ServicesOptions & {
|
|
25
25
|
gateway?: ShardManager;
|
|
26
|
-
handlers?: ServicesOptions['handlers'] & {
|
|
27
|
-
events?: EventHandler['callback'];
|
|
28
|
-
};
|
|
29
26
|
}): void;
|
|
30
27
|
loadEvents(dir?: string): Promise<void>;
|
|
31
28
|
protected execute(options?: {
|
|
@@ -52,8 +49,7 @@ export interface ClientOptions extends BaseClientOptions {
|
|
|
52
49
|
reply?: (ctx: CommandContext) => boolean;
|
|
53
50
|
};
|
|
54
51
|
handlePayload?: ShardManagerOptions['handlePayload'];
|
|
55
|
-
resharding?: {
|
|
56
|
-
|
|
57
|
-
percentage: number;
|
|
52
|
+
resharding?: Omit<NonNullable<ShardManagerOptions['resharding']>, 'getInfo'> & {
|
|
53
|
+
getInfo?: NonNullable<ShardManagerOptions['resharding']>['getInfo'];
|
|
58
54
|
};
|
|
59
55
|
}
|
package/lib/client/client.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Client = void 0;
|
|
4
|
-
const types_1 = require("../types");
|
|
5
4
|
const common_1 = require("../common");
|
|
6
5
|
const events_1 = require("../events");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
7
|
const websocket_1 = require("../websocket");
|
|
8
8
|
const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
|
|
9
9
|
const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
|
|
@@ -33,17 +33,6 @@ class Client extends base_1.BaseClient {
|
|
|
33
33
|
};
|
|
34
34
|
this.gateway = gateway;
|
|
35
35
|
}
|
|
36
|
-
if (rest.handlers && 'events' in rest.handlers) {
|
|
37
|
-
if (!rest.handlers.events) {
|
|
38
|
-
this.events = undefined;
|
|
39
|
-
}
|
|
40
|
-
else if (typeof rest.handlers.events === 'function') {
|
|
41
|
-
this.events = new events_1.EventHandler(this);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
this.events = rest.handlers.events;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
36
|
}
|
|
48
37
|
async loadEvents(dir) {
|
|
49
38
|
dir ??= await this.getRC().then(x => x.events);
|
|
@@ -101,22 +90,9 @@ class Client extends base_1.BaseClient {
|
|
|
101
90
|
},
|
|
102
91
|
compress: this.options?.gateway?.compress,
|
|
103
92
|
resharding: {
|
|
104
|
-
getInfo: () => this.proxy.gateway.bot.get(),
|
|
105
|
-
interval: this.options?.resharding?.interval
|
|
106
|
-
percentage: this.options?.resharding?.percentage
|
|
107
|
-
reloadGuilds: ids => {
|
|
108
|
-
this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids;
|
|
109
|
-
},
|
|
110
|
-
onGuild: id => {
|
|
111
|
-
if (this.__handleGuilds) {
|
|
112
|
-
const index = this.__handleGuilds.indexOf(id);
|
|
113
|
-
if (index === -1)
|
|
114
|
-
return false;
|
|
115
|
-
this.__handleGuilds.splice(index, 1);
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
return false;
|
|
119
|
-
},
|
|
93
|
+
getInfo: this.options.resharding?.getInfo ?? (() => this.proxy.gateway.bot.get()),
|
|
94
|
+
interval: this.options?.resharding?.interval,
|
|
95
|
+
percentage: this.options?.resharding?.percentage,
|
|
120
96
|
},
|
|
121
97
|
});
|
|
122
98
|
}
|
|
@@ -134,18 +110,22 @@ class Client extends base_1.BaseClient {
|
|
|
134
110
|
this.collectors.run('RAW', packet, this),
|
|
135
111
|
]); //ignore promise
|
|
136
112
|
switch (packet.t) {
|
|
137
|
-
|
|
113
|
+
// Cases where we must obtain the old data before updating
|
|
138
114
|
case 'GUILD_MEMBER_UPDATE':
|
|
139
|
-
|
|
140
|
-
|
|
115
|
+
{
|
|
116
|
+
if (!this.memberUpdateHandler.check(packet.d)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
141
120
|
}
|
|
142
|
-
await this.events?.execute(packet.t, packet, this, shardId);
|
|
143
121
|
break;
|
|
144
122
|
case 'PRESENCE_UPDATE':
|
|
145
|
-
|
|
146
|
-
|
|
123
|
+
{
|
|
124
|
+
if (!this.presenceUpdateHandler.check(packet.d)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
147
128
|
}
|
|
148
|
-
await this.events?.execute(packet.t, packet, this, shardId);
|
|
149
129
|
break;
|
|
150
130
|
case 'GUILD_DELETE':
|
|
151
131
|
case 'GUILD_CREATE': {
|
|
@@ -167,12 +147,16 @@ class Client extends base_1.BaseClient {
|
|
|
167
147
|
default: {
|
|
168
148
|
switch (packet.t) {
|
|
169
149
|
case 'INTERACTION_CREATE':
|
|
170
|
-
|
|
171
|
-
|
|
150
|
+
{
|
|
151
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
152
|
+
await this.handleCommand.interaction(packet.d, shardId);
|
|
153
|
+
}
|
|
172
154
|
break;
|
|
173
155
|
case 'MESSAGE_CREATE':
|
|
174
|
-
|
|
175
|
-
|
|
156
|
+
{
|
|
157
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
158
|
+
await this.handleCommand.message(packet.d, shardId);
|
|
159
|
+
}
|
|
176
160
|
break;
|
|
177
161
|
case 'READY': {
|
|
178
162
|
const ids = packet.d.guilds.map(x => x.id);
|
|
@@ -180,8 +164,7 @@ class Client extends base_1.BaseClient {
|
|
|
180
164
|
this.botId = packet.d.user.id;
|
|
181
165
|
this.applicationId = packet.d.application.id;
|
|
182
166
|
this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
|
|
183
|
-
if (!(this.
|
|
184
|
-
(this.gateway.options.intents & types_1.GatewayIntentBits.Guilds) === types_1.GatewayIntentBits.Guilds)) {
|
|
167
|
+
if (!(0, common_1.hasIntent)(this.gateway.options.intents, types_1.GatewayIntentBits.Guilds)) {
|
|
185
168
|
if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
186
169
|
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
|
187
170
|
}
|
package/lib/client/collectors.js
CHANGED
|
@@ -24,8 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Collectors = void 0;
|
|
27
|
-
const node_crypto_1 = require("node:crypto");
|
|
28
27
|
const node_console_1 = require("node:console");
|
|
28
|
+
const node_crypto_1 = require("node:crypto");
|
|
29
29
|
const RawEvents = __importStar(require("../events/hooks"));
|
|
30
30
|
class Collectors {
|
|
31
31
|
values = new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { APIInteractionResponse, APIInteraction } from '../types';
|
|
2
1
|
import type { DeepPartial } from '../common';
|
|
2
|
+
import type { APIInteraction, APIInteractionResponse } from '../types';
|
|
3
3
|
import type { BaseClientOptions, StartOptions } from './base';
|
|
4
4
|
import { BaseClient } from './base';
|
|
5
5
|
export declare class HttpClient extends BaseClient {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { ChannelType } from '../types';
|
|
2
1
|
import { type CustomStructures, OptionResolver } from '../commands';
|
|
3
|
-
import { AnonymousGuild, AutoModerationRule, BaseChannel, BaseGuildChannel, CategoryChannel, ClientUser, DMChannel, DirectoryChannel, ForumChannel, Guild, GuildEmoji, GuildMember, GuildRole, GuildTemplate, InteractionGuildMember, MediaChannel, Message, NewsChannel, Poll, StageChannel, Sticker, TextGuildChannel, ThreadChannel, User, VoiceChannel, VoiceState, Webhook, WebhookMessage } from '../structures';
|
|
4
2
|
import type { StructStates } from '../common/';
|
|
3
|
+
import { AnonymousGuild, AutoModerationRule, BaseChannel, BaseGuildChannel, CategoryChannel, ClientUser, DMChannel, DirectoryChannel, ForumChannel, Guild, GuildEmoji, GuildMember, GuildRole, GuildTemplate, InteractionGuildMember, MediaChannel, Message, NewsChannel, Poll, StageChannel, Sticker, TextGuildChannel, ThreadChannel, User, VoiceChannel, VoiceState, Webhook, WebhookMessage } from '../structures';
|
|
4
|
+
import { Entitlement } from '../structures/Entitlement';
|
|
5
5
|
import { GuildBan } from '../structures/GuildBan';
|
|
6
|
+
import type { ChannelType } from '../types';
|
|
6
7
|
export type PollStructure = InferCustomStructure<Poll, 'Poll'>;
|
|
7
8
|
export type ClientUserStructure = InferCustomStructure<ClientUser, 'ClientUser'>;
|
|
8
9
|
export type AnonymousGuildStructure = InferCustomStructure<AnonymousGuild, 'AnonymousGuild'>;
|
|
@@ -33,36 +34,38 @@ export type UserStructure = InferCustomStructure<User, 'User'>;
|
|
|
33
34
|
export type VoiceStateStructure = InferCustomStructure<VoiceState, 'VoiceState'>;
|
|
34
35
|
export type WebhookStructure = InferCustomStructure<Webhook, 'Webhook'>;
|
|
35
36
|
export type OptionResolverStructure = InferCustomStructure<OptionResolver, 'OptionResolver'>;
|
|
36
|
-
export
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
37
|
+
export type EntitlementStructure = InferCustomStructure<Entitlement, 'Entitlement'>;
|
|
38
|
+
export declare const Transformers: {
|
|
39
|
+
AnonymousGuild(client: import("../commands").UsingClient, data: import("../types").APIPartialGuild): AnonymousGuildStructure;
|
|
40
|
+
AutoModerationRule(client: import("../commands").UsingClient, data: import("../types").APIAutoModerationRule): AutoModerationRuleStructure;
|
|
41
|
+
BaseChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): BaseChannelStructure;
|
|
42
|
+
BaseGuildChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): BaseGuildChannelStructure;
|
|
43
|
+
TextGuildChannel(client: import("../commands").UsingClient, data: import("../types").APIGuildChannel<ChannelType>): TextGuildChannelStructure;
|
|
44
|
+
DMChannel(...args: ConstructorParameters<typeof DMChannel>): DMChannelStructure;
|
|
45
|
+
VoiceChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): VoiceChannelStructure;
|
|
46
|
+
StageChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): StageChannelStructure;
|
|
47
|
+
MediaChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): MediaChannelStructure;
|
|
48
|
+
ForumChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): ForumChannelStructure;
|
|
49
|
+
ThreadChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): ThreadChannelStructure;
|
|
50
|
+
CategoryChannel(...args: ConstructorParameters<typeof CategoryChannel>): CategoryChannelStructure;
|
|
51
|
+
NewsChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): NewsChannelStructure;
|
|
52
|
+
DirectoryChannel(client: import("../commands").UsingClient, data: import("../types").APIChannelBase<ChannelType>): DirectoryChannelStructure;
|
|
53
|
+
ClientUser(client: import("../commands").UsingClient, data: import("../types").APIUser, application: Pick<import("../types").APIApplication, "id" | "flags">): ClientUserStructure;
|
|
54
|
+
Guild<State extends StructStates = "api">(client: import("../commands").UsingClient, data: import("../types").APIGuild | import("../types").GatewayGuildCreateDispatchData): GuildStructure<State>;
|
|
55
|
+
GuildBan(client: import("../commands").UsingClient, data: import("../types").APIBan, guildId: string): GuildBanStructure;
|
|
56
|
+
GuildEmoji(client: import("../commands").UsingClient, data: import("../types").APIEmoji, guildId: string): GuildEmojiStructure;
|
|
57
|
+
GuildMember(client: import("../commands").UsingClient, data: import("../structures").GuildMemberData, user: import("../types").APIUser, guildId: string): GuildMemberStructure;
|
|
58
|
+
InteractionGuildMember(client: import("../commands").UsingClient, data: import("../types").APIInteractionDataResolvedGuildMember, user: import("../types").APIUser, guildId: string): InteractionGuildMemberStructure;
|
|
59
|
+
GuildRole(client: import("../commands").UsingClient, data: import("../types").APIRole, guildId: string): GuildRoleStructure;
|
|
60
|
+
GuildTemplate(client: import("../commands").UsingClient, data: import("../types").APITemplate): GuildTemplateStructure;
|
|
61
|
+
Message(client: import("../commands").UsingClient, data: import("../structures").MessageData): MessageStructure;
|
|
62
|
+
WebhookMessage(client: import("../commands").UsingClient, data: import("../structures").MessageData, webhookId: string, webhookToken: string): WebhookMessageStructure;
|
|
63
|
+
Poll(client: import("../commands").UsingClient, data: import("../types").APIPoll, channelId: string, messageId: string): PollStructure;
|
|
64
|
+
Sticker(client: import("../commands").UsingClient, data: import("../types").APISticker): StickerStructure;
|
|
65
|
+
User(client: import("../commands").UsingClient, data: import("../types").APIUser): UserStructure;
|
|
66
|
+
VoiceState(client: import("../commands").UsingClient, data: import("../types").APIVoiceState): VoiceStateStructure;
|
|
67
|
+
Webhook(client: import("../commands").UsingClient, data: import("../types").APIWebhook): WebhookStructure;
|
|
68
|
+
OptionResolver(client: import("../commands").UsingClient, options: import("../types").APIApplicationCommandInteractionDataOption[], parent?: import("../commands").Command | undefined, guildId?: string | undefined, resolved?: import("../commands").ContextOptionsResolved | undefined): OptionResolverStructure;
|
|
69
|
+
Entitlement(client: import("../commands").UsingClient, data: import("../types").APIEntitlement): EntitlementStructure;
|
|
70
|
+
};
|
|
68
71
|
export type InferCustomStructure<T, N extends string> = CustomStructures extends Record<N, infer P> ? P : T;
|
|
@@ -3,97 +3,100 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Transformers = void 0;
|
|
4
4
|
const commands_1 = require("../commands");
|
|
5
5
|
const structures_1 = require("../structures");
|
|
6
|
+
const Entitlement_1 = require("../structures/Entitlement");
|
|
6
7
|
const GuildBan_1 = require("../structures/GuildBan");
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
exports.Transformers = {
|
|
9
|
+
AnonymousGuild(...args) {
|
|
9
10
|
return new structures_1.AnonymousGuild(...args);
|
|
10
|
-
}
|
|
11
|
-
|
|
11
|
+
},
|
|
12
|
+
AutoModerationRule(...args) {
|
|
12
13
|
return new structures_1.AutoModerationRule(...args);
|
|
13
|
-
}
|
|
14
|
-
|
|
14
|
+
},
|
|
15
|
+
BaseChannel(...args) {
|
|
15
16
|
return new structures_1.BaseChannel(...args);
|
|
16
|
-
}
|
|
17
|
-
|
|
17
|
+
},
|
|
18
|
+
BaseGuildChannel(...args) {
|
|
18
19
|
return new structures_1.BaseGuildChannel(...args);
|
|
19
|
-
}
|
|
20
|
-
|
|
20
|
+
},
|
|
21
|
+
TextGuildChannel(...args) {
|
|
21
22
|
return new structures_1.TextGuildChannel(...args);
|
|
22
|
-
}
|
|
23
|
-
|
|
23
|
+
},
|
|
24
|
+
DMChannel(...args) {
|
|
24
25
|
return new structures_1.DMChannel(...args);
|
|
25
|
-
}
|
|
26
|
-
|
|
26
|
+
},
|
|
27
|
+
VoiceChannel(...args) {
|
|
27
28
|
return new structures_1.VoiceChannel(...args);
|
|
28
|
-
}
|
|
29
|
-
|
|
29
|
+
},
|
|
30
|
+
StageChannel(...args) {
|
|
30
31
|
return new structures_1.StageChannel(...args);
|
|
31
|
-
}
|
|
32
|
-
|
|
32
|
+
},
|
|
33
|
+
MediaChannel(...args) {
|
|
33
34
|
return new structures_1.MediaChannel(...args);
|
|
34
|
-
}
|
|
35
|
-
|
|
35
|
+
},
|
|
36
|
+
ForumChannel(...args) {
|
|
36
37
|
return new structures_1.ForumChannel(...args);
|
|
37
|
-
}
|
|
38
|
-
|
|
38
|
+
},
|
|
39
|
+
ThreadChannel(...args) {
|
|
39
40
|
return new structures_1.ThreadChannel(...args);
|
|
40
|
-
}
|
|
41
|
-
|
|
41
|
+
},
|
|
42
|
+
CategoryChannel(...args) {
|
|
42
43
|
return new structures_1.CategoryChannel(...args);
|
|
43
|
-
}
|
|
44
|
-
|
|
44
|
+
},
|
|
45
|
+
NewsChannel(...args) {
|
|
45
46
|
return new structures_1.NewsChannel(...args);
|
|
46
|
-
}
|
|
47
|
-
|
|
47
|
+
},
|
|
48
|
+
DirectoryChannel(...args) {
|
|
48
49
|
return new structures_1.DirectoryChannel(...args);
|
|
49
|
-
}
|
|
50
|
-
|
|
50
|
+
},
|
|
51
|
+
ClientUser(...args) {
|
|
51
52
|
return new structures_1.ClientUser(...args);
|
|
52
|
-
}
|
|
53
|
-
|
|
53
|
+
},
|
|
54
|
+
Guild(...args) {
|
|
54
55
|
return new structures_1.Guild(...args);
|
|
55
|
-
}
|
|
56
|
-
|
|
56
|
+
},
|
|
57
|
+
GuildBan(...args) {
|
|
57
58
|
return new GuildBan_1.GuildBan(...args);
|
|
58
|
-
}
|
|
59
|
-
|
|
59
|
+
},
|
|
60
|
+
GuildEmoji(...args) {
|
|
60
61
|
return new structures_1.GuildEmoji(...args);
|
|
61
|
-
}
|
|
62
|
-
|
|
62
|
+
},
|
|
63
|
+
GuildMember(...args) {
|
|
63
64
|
return new structures_1.GuildMember(...args);
|
|
64
|
-
}
|
|
65
|
-
|
|
65
|
+
},
|
|
66
|
+
InteractionGuildMember(...args) {
|
|
66
67
|
return new structures_1.InteractionGuildMember(...args);
|
|
67
|
-
}
|
|
68
|
-
|
|
68
|
+
},
|
|
69
|
+
GuildRole(...args) {
|
|
69
70
|
return new structures_1.GuildRole(...args);
|
|
70
|
-
}
|
|
71
|
-
|
|
71
|
+
},
|
|
72
|
+
GuildTemplate(...args) {
|
|
72
73
|
return new structures_1.GuildTemplate(...args);
|
|
73
|
-
}
|
|
74
|
-
|
|
74
|
+
},
|
|
75
|
+
Message(...args) {
|
|
75
76
|
return new structures_1.Message(...args);
|
|
76
|
-
}
|
|
77
|
-
|
|
77
|
+
},
|
|
78
|
+
WebhookMessage(...args) {
|
|
78
79
|
return new structures_1.WebhookMessage(...args);
|
|
79
|
-
}
|
|
80
|
-
|
|
80
|
+
},
|
|
81
|
+
Poll(...args) {
|
|
81
82
|
return new structures_1.Poll(...args);
|
|
82
|
-
}
|
|
83
|
-
|
|
83
|
+
},
|
|
84
|
+
Sticker(...args) {
|
|
84
85
|
return new structures_1.Sticker(...args);
|
|
85
|
-
}
|
|
86
|
-
|
|
86
|
+
},
|
|
87
|
+
User(...args) {
|
|
87
88
|
return new structures_1.User(...args);
|
|
88
|
-
}
|
|
89
|
-
|
|
89
|
+
},
|
|
90
|
+
VoiceState(...args) {
|
|
90
91
|
return new structures_1.VoiceState(...args);
|
|
91
|
-
}
|
|
92
|
-
|
|
92
|
+
},
|
|
93
|
+
Webhook(...args) {
|
|
93
94
|
return new structures_1.Webhook(...args);
|
|
94
|
-
}
|
|
95
|
-
|
|
95
|
+
},
|
|
96
|
+
OptionResolver(...args) {
|
|
96
97
|
return new commands_1.OptionResolver(...args);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
},
|
|
99
|
+
Entitlement(...args) {
|
|
100
|
+
return new Entitlement_1.Entitlement(...args);
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { type GatewayDispatchPayload } from '../types';
|
|
2
1
|
import { type DeepPartial, type When } from '../common';
|
|
3
2
|
import { EventHandler } from '../events';
|
|
3
|
+
import { type GatewayDispatchPayload } from '../types';
|
|
4
4
|
import { Shard, type ShardManagerOptions, type WorkerData } from '../websocket';
|
|
5
|
-
import type { WorkerShardInfo } from '../websocket/discord/worker';
|
|
5
|
+
import type { WorkerMessage, WorkerShardInfo } from '../websocket/discord/worker';
|
|
6
6
|
import type { ManagerMessages } from '../websocket/discord/workermanager';
|
|
7
7
|
import type { BaseClientOptions, ServicesOptions, StartOptions } from './base';
|
|
8
8
|
import { BaseClient } from './base';
|
|
9
9
|
import type { Client, ClientOptions } from './client';
|
|
10
|
-
import { Collectors } from './collectors';
|
|
11
|
-
import { type ClientUserStructure } from './transformers';
|
|
12
10
|
import { MemberUpdateHandler } from '../websocket/discord/events/memberUpdate';
|
|
13
11
|
import { PresenceUpdateHandler } from '../websocket/discord/events/presenceUpdate';
|
|
12
|
+
import { Collectors } from './collectors';
|
|
13
|
+
import { type ClientUserStructure } from './transformers';
|
|
14
14
|
export declare class WorkerClient<Ready extends boolean = boolean> extends BaseClient {
|
|
15
15
|
private __handleGuilds?;
|
|
16
|
+
private __handleGuildsResharding?;
|
|
16
17
|
memberUpdateHandler: MemberUpdateHandler;
|
|
17
18
|
presenceUpdateHandler: PresenceUpdateHandler;
|
|
18
19
|
collectors: Collectors;
|
|
@@ -23,25 +24,23 @@ export declare class WorkerClient<Ready extends boolean = boolean> extends BaseC
|
|
|
23
24
|
timeout: NodeJS.Timeout;
|
|
24
25
|
}>;
|
|
25
26
|
shards: Map<number, Shard>;
|
|
27
|
+
resharding: Map<number, Shard>;
|
|
28
|
+
private _ready?;
|
|
26
29
|
private __setServicesCache?;
|
|
27
30
|
options: WorkerClientOptions;
|
|
28
31
|
constructor(options?: WorkerClientOptions);
|
|
29
32
|
get workerId(): number;
|
|
30
33
|
get latency(): number;
|
|
31
|
-
setServices(
|
|
32
|
-
handlers?: ServicesOptions['handlers'] & {
|
|
33
|
-
events?: EventHandler['callback'];
|
|
34
|
-
};
|
|
35
|
-
}): void;
|
|
34
|
+
setServices(rest: ServicesOptions): void;
|
|
36
35
|
setWorkerData(data: WorkerData): void;
|
|
37
36
|
get workerData(): WorkerData;
|
|
38
37
|
start(options?: Omit<DeepPartial<StartOptions>, 'httpConnection' | 'token' | 'connection'>): Promise<void>;
|
|
39
38
|
loadEvents(dir?: string): Promise<void>;
|
|
40
|
-
postMessage(body:
|
|
39
|
+
postMessage(body: WorkerMessage): unknown;
|
|
41
40
|
handleManagerMessages(data: ManagerMessages): Promise<any>;
|
|
42
41
|
private generateNonce;
|
|
43
42
|
private generateSendPromise;
|
|
44
|
-
tellWorker(workerId: number, func: (_: this) =>
|
|
43
|
+
tellWorker(workerId: number, func: (_: this) => any): Promise<unknown>;
|
|
45
44
|
protected onPacket(packet: GatewayDispatchPayload, shardId: number): Promise<void>;
|
|
46
45
|
}
|
|
47
46
|
export declare function generateShardInfo(shard: Shard): WorkerShardInfo;
|