seyfert 2.1.0 → 2.1.1-dev-11310514874.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 +3 -3
- 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 +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
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WorkerClient = void 0;
|
|
4
4
|
exports.generateShardInfo = generateShardInfo;
|
|
5
|
-
const types_1 = require("../types");
|
|
6
5
|
const node_crypto_1 = require("node:crypto");
|
|
7
6
|
const __1 = require("..");
|
|
8
7
|
const cache_1 = require("../cache");
|
|
9
8
|
const common_1 = require("../common");
|
|
10
9
|
const events_1 = require("../events");
|
|
10
|
+
const types_1 = require("../types");
|
|
11
11
|
const websocket_1 = require("../websocket");
|
|
12
12
|
const base_1 = require("./base");
|
|
13
|
-
const collectors_1 = require("./collectors");
|
|
14
|
-
const transformers_1 = require("./transformers");
|
|
15
13
|
const memberUpdate_1 = require("../websocket/discord/events/memberUpdate");
|
|
16
14
|
const presenceUpdate_1 = require("../websocket/discord/events/presenceUpdate");
|
|
15
|
+
const collectors_1 = require("./collectors");
|
|
16
|
+
const transformers_1 = require("./transformers");
|
|
17
17
|
let workerData;
|
|
18
18
|
let manager;
|
|
19
19
|
try {
|
|
@@ -27,11 +27,15 @@ try {
|
|
|
27
27
|
workerProxy: process.env.SEYFERT_WORKER_WORKERPROXY === 'true',
|
|
28
28
|
totalShards: Number(process.env.SEYFERT_WORKER_TOTALSHARDS),
|
|
29
29
|
mode: process.env.SEYFERT_WORKER_MODE,
|
|
30
|
+
resharding: process.env.SEYFERT_WORKER_RESHARDING === 'true',
|
|
30
31
|
};
|
|
31
32
|
}
|
|
32
|
-
catch {
|
|
33
|
+
catch {
|
|
34
|
+
//
|
|
35
|
+
}
|
|
33
36
|
class WorkerClient extends base_1.BaseClient {
|
|
34
37
|
__handleGuilds = new Set();
|
|
38
|
+
__handleGuildsResharding;
|
|
35
39
|
memberUpdateHandler = new memberUpdate_1.MemberUpdateHandler();
|
|
36
40
|
presenceUpdateHandler = new presenceUpdate_1.PresenceUpdateHandler();
|
|
37
41
|
collectors = new collectors_1.Collectors();
|
|
@@ -39,6 +43,8 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
39
43
|
me;
|
|
40
44
|
promises = new Map();
|
|
41
45
|
shards = new Map();
|
|
46
|
+
resharding = new Map();
|
|
47
|
+
_ready;
|
|
42
48
|
__setServicesCache;
|
|
43
49
|
constructor(options) {
|
|
44
50
|
super(options);
|
|
@@ -54,22 +60,11 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
54
60
|
this.shards.forEach(s => (acc += s.latency));
|
|
55
61
|
return acc / this.shards.size;
|
|
56
62
|
}
|
|
57
|
-
setServices(
|
|
63
|
+
setServices(rest) {
|
|
58
64
|
super.setServices(rest);
|
|
59
65
|
if (rest.cache) {
|
|
60
66
|
this.__setServicesCache = true;
|
|
61
67
|
}
|
|
62
|
-
if (rest.handlers && 'events' in rest.handlers) {
|
|
63
|
-
if (!rest.handlers.events) {
|
|
64
|
-
this.events = undefined;
|
|
65
|
-
}
|
|
66
|
-
else if (typeof rest.handlers.events === 'function') {
|
|
67
|
-
this.events = new events_1.EventHandler(this);
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.events = rest.handlers.events;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
68
|
}
|
|
74
69
|
setWorkerData(data) {
|
|
75
70
|
workerData = data;
|
|
@@ -123,9 +118,12 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
123
118
|
});
|
|
124
119
|
}
|
|
125
120
|
this.postMessage({
|
|
126
|
-
type: 'WORKER_START',
|
|
121
|
+
type: workerData.resharding ? 'WORKER_START_RESHARDING' : 'WORKER_START',
|
|
127
122
|
workerId: workerData.workerId,
|
|
128
123
|
});
|
|
124
|
+
if (workerData.resharding) {
|
|
125
|
+
this.__handleGuildsResharding = new Set();
|
|
126
|
+
}
|
|
129
127
|
await super.start(options);
|
|
130
128
|
await this.loadEvents(options.eventsDir);
|
|
131
129
|
this.cache.intents = workerData.intents;
|
|
@@ -169,6 +167,17 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
169
167
|
});
|
|
170
168
|
}
|
|
171
169
|
break;
|
|
170
|
+
case 'ALLOW_CONNECT_RESHARDING':
|
|
171
|
+
{
|
|
172
|
+
const shard = this.resharding.get(data.shardId);
|
|
173
|
+
if (!shard) {
|
|
174
|
+
this.logger.fatal('Worker trying reshard non-existent shard');
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
shard.options.presence = data.presence;
|
|
178
|
+
await shard.connect();
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
172
181
|
case 'ALLOW_CONNECT':
|
|
173
182
|
{
|
|
174
183
|
const shard = this.shards.get(data.shardId);
|
|
@@ -180,39 +189,96 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
180
189
|
await shard.connect();
|
|
181
190
|
}
|
|
182
191
|
break;
|
|
183
|
-
case '
|
|
192
|
+
case 'SPAWN_SHARDS_RESHARDING':
|
|
184
193
|
{
|
|
185
|
-
|
|
186
|
-
const handlePayload = this.options?.handlePayload?.bind(this);
|
|
194
|
+
let shardsConnected = 0;
|
|
187
195
|
const self = this;
|
|
188
|
-
const { sendPayloadToParent } = this.options;
|
|
189
196
|
for (const id of workerData.shards) {
|
|
190
|
-
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
197
|
+
const existsShard = this.resharding.has(id);
|
|
198
|
+
if (existsShard) {
|
|
199
|
+
this.logger.warn(`Trying to re-spawn existing shard #${id}`);
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const shard = new websocket_1.Shard(id, {
|
|
203
|
+
token: workerData.token,
|
|
204
|
+
intents: workerData.intents,
|
|
205
|
+
info: data.info,
|
|
206
|
+
compress: data.compress,
|
|
207
|
+
debugger: this.debugger,
|
|
208
|
+
properties: {
|
|
209
|
+
...websocket_1.properties,
|
|
210
|
+
...this.options.gateway?.properties,
|
|
211
|
+
},
|
|
212
|
+
handlePayload(_, payload) {
|
|
213
|
+
if (payload.t === 'GUILD_CREATE' || payload.t === 'GUILD_DELETE') {
|
|
214
|
+
self.__handleGuildsResharding.delete(payload.d.id);
|
|
215
|
+
if (!self.__handleGuildsResharding?.size && shardsConnected === workerData.shards.length) {
|
|
216
|
+
delete self.__handleGuildsResharding;
|
|
206
217
|
self.postMessage({
|
|
218
|
+
type: 'WORKER_READY_RESHARDING',
|
|
207
219
|
workerId: workerData.workerId,
|
|
208
|
-
shardId,
|
|
209
|
-
type: 'RECEIVE_PAYLOAD',
|
|
210
|
-
payload,
|
|
211
220
|
});
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
if (payload.t !== 'READY')
|
|
224
|
+
return;
|
|
225
|
+
shardsConnected++;
|
|
226
|
+
for (const guild of payload.d.guilds) {
|
|
227
|
+
self.__handleGuildsResharding.add(guild.id);
|
|
228
|
+
}
|
|
229
|
+
if (shardsConnected === workerData.shards.length &&
|
|
230
|
+
!(0, common_1.hasIntent)(workerData.intents, types_1.GatewayIntentBits.Guilds)) {
|
|
231
|
+
delete self.__handleGuildsResharding;
|
|
232
|
+
self.postMessage({
|
|
233
|
+
type: 'WORKER_READY_RESHARDING',
|
|
234
|
+
workerId: workerData.workerId,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
});
|
|
239
|
+
this.resharding.set(id, shard);
|
|
240
|
+
this.postMessage({
|
|
241
|
+
type: 'CONNECT_QUEUE_RESHARDING',
|
|
242
|
+
shardId: id,
|
|
243
|
+
workerId: workerData.workerId,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
break;
|
|
248
|
+
case 'SPAWN_SHARDS':
|
|
249
|
+
{
|
|
250
|
+
const onPacket = this.onPacket.bind(this);
|
|
251
|
+
const handlePayload = this.options?.handlePayload?.bind(this);
|
|
252
|
+
const self = this;
|
|
253
|
+
for (const id of workerData.shards) {
|
|
254
|
+
const existsShard = this.shards.has(id);
|
|
255
|
+
if (existsShard) {
|
|
256
|
+
this.logger.warn(`Trying to spawn existing shard #${id}`);
|
|
257
|
+
continue;
|
|
215
258
|
}
|
|
259
|
+
const shard = new websocket_1.Shard(id, {
|
|
260
|
+
token: workerData.token,
|
|
261
|
+
intents: workerData.intents,
|
|
262
|
+
info: data.info,
|
|
263
|
+
compress: data.compress,
|
|
264
|
+
debugger: this.debugger,
|
|
265
|
+
properties: {
|
|
266
|
+
...websocket_1.properties,
|
|
267
|
+
...this.options.gateway?.properties,
|
|
268
|
+
},
|
|
269
|
+
async handlePayload(shardId, payload) {
|
|
270
|
+
await handlePayload?.(shardId, payload);
|
|
271
|
+
await onPacket(payload, shardId);
|
|
272
|
+
if (self.options.sendPayloadToParent)
|
|
273
|
+
self.postMessage({
|
|
274
|
+
workerId: workerData.workerId,
|
|
275
|
+
shardId,
|
|
276
|
+
type: 'RECEIVE_PAYLOAD',
|
|
277
|
+
payload,
|
|
278
|
+
});
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
this.shards.set(id, shard);
|
|
216
282
|
this.postMessage({
|
|
217
283
|
type: 'CONNECT_QUEUE',
|
|
218
284
|
shardId: id,
|
|
@@ -289,14 +355,47 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
289
355
|
evalResponse.resolve(data.response);
|
|
290
356
|
}
|
|
291
357
|
break;
|
|
358
|
+
case 'WORKER_ALREADY_EXISTS_RESHARDING':
|
|
359
|
+
{
|
|
360
|
+
this.__handleGuildsResharding = new Set();
|
|
361
|
+
this.postMessage({
|
|
362
|
+
type: 'WORKER_START_RESHARDING',
|
|
363
|
+
workerId: workerData.workerId,
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
break;
|
|
367
|
+
case 'DISCONNECT_ALL_SHARDS_RESHARDING':
|
|
368
|
+
{
|
|
369
|
+
for (const i of this.shards.values()) {
|
|
370
|
+
await i.disconnect();
|
|
371
|
+
}
|
|
372
|
+
this.postMessage({
|
|
373
|
+
type: 'DISCONNECTED_ALL_SHARDS_RESHARDING',
|
|
374
|
+
workerId: workerData.workerId,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
break;
|
|
378
|
+
case 'CONNECT_ALL_SHARDS_RESHARDING':
|
|
379
|
+
{
|
|
380
|
+
this.shards.clear();
|
|
381
|
+
const handlePayload = this.options?.handlePayload?.bind(this);
|
|
382
|
+
for (const [id, shard] of this.resharding) {
|
|
383
|
+
this.shards.set(id, shard);
|
|
384
|
+
shard.options.handlePayload = async (shardId, packet) => {
|
|
385
|
+
await handlePayload?.(shardId, packet);
|
|
386
|
+
return this.onPacket(packet, shardId);
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
this.resharding.clear();
|
|
390
|
+
}
|
|
391
|
+
break;
|
|
292
392
|
}
|
|
293
393
|
}
|
|
294
|
-
generateNonce(
|
|
394
|
+
generateNonce() {
|
|
295
395
|
const uuid = (0, node_crypto_1.randomUUID)();
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return nonce;
|
|
396
|
+
if (this.promises.has(uuid))
|
|
397
|
+
return this.generateNonce();
|
|
398
|
+
return uuid;
|
|
300
399
|
}
|
|
301
400
|
generateSendPromise(nonce, message = 'Timeout') {
|
|
302
401
|
return new Promise((res, rej) => {
|
|
@@ -364,42 +463,48 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
364
463
|
default: {
|
|
365
464
|
switch (packet.t) {
|
|
366
465
|
case 'INTERACTION_CREATE':
|
|
367
|
-
|
|
368
|
-
|
|
466
|
+
{
|
|
467
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
468
|
+
await this.handleCommand.interaction(packet.d, shardId);
|
|
469
|
+
}
|
|
369
470
|
break;
|
|
370
471
|
case 'MESSAGE_CREATE':
|
|
371
|
-
|
|
372
|
-
|
|
472
|
+
{
|
|
473
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
474
|
+
await this.handleCommand.message(packet.d, shardId);
|
|
475
|
+
}
|
|
373
476
|
break;
|
|
374
477
|
case 'READY':
|
|
375
|
-
|
|
376
|
-
this.__handleGuilds
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
this.
|
|
386
|
-
|
|
387
|
-
workerId: this.workerId,
|
|
388
|
-
});
|
|
389
|
-
await this.events?.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1);
|
|
390
|
-
}
|
|
391
|
-
if (!(this.__handleGuilds?.size &&
|
|
392
|
-
(workerData.intents & types_1.GatewayIntentBits.Guilds) === types_1.GatewayIntentBits.Guilds)) {
|
|
393
|
-
if ([...this.shards.values()].every(shard => shard.data.session_id)) {
|
|
478
|
+
{
|
|
479
|
+
if (!this.__handleGuilds)
|
|
480
|
+
this.__handleGuilds = new Set();
|
|
481
|
+
for (const g of packet.d.guilds) {
|
|
482
|
+
this.__handleGuilds?.add(g.id);
|
|
483
|
+
}
|
|
484
|
+
this.botId = packet.d.user.id;
|
|
485
|
+
this.applicationId = packet.d.application.id;
|
|
486
|
+
this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
|
|
487
|
+
await this.events?.execute(packet.t, packet, this, shardId);
|
|
488
|
+
if (!this._ready && [...this.shards.values()].every(shard => shard.data.session_id)) {
|
|
489
|
+
this._ready = true;
|
|
394
490
|
this.postMessage({
|
|
395
|
-
type: '
|
|
491
|
+
type: 'WORKER_SHARDS_CONNECTED',
|
|
396
492
|
workerId: this.workerId,
|
|
397
493
|
});
|
|
398
|
-
await this.events?.runEvent('
|
|
494
|
+
await this.events?.runEvent('WORKER_SHARDS_CONNECTED', this, this.me, -1);
|
|
495
|
+
}
|
|
496
|
+
if (!(0, common_1.hasIntent)(workerData.intents, types_1.GatewayIntentBits.Guilds)) {
|
|
497
|
+
if ([...this.shards.values()].every(shard => shard.data.session_id)) {
|
|
498
|
+
this.postMessage({
|
|
499
|
+
type: 'WORKER_READY',
|
|
500
|
+
workerId: this.workerId,
|
|
501
|
+
});
|
|
502
|
+
await this.events?.runEvent('WORKER_READY', this, this.me, -1);
|
|
503
|
+
}
|
|
504
|
+
delete this.__handleGuilds;
|
|
399
505
|
}
|
|
400
|
-
|
|
506
|
+
this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
|
|
401
507
|
}
|
|
402
|
-
this.debugger?.debug(`#${shardId}[${packet.d.user.username}](${this.botId}) is online...`);
|
|
403
508
|
break;
|
|
404
509
|
default:
|
|
405
510
|
await this.events?.execute(packet.t, packet, this, shardId);
|
package/lib/collection.d.ts
CHANGED
|
@@ -229,9 +229,9 @@ export declare class LimitedCollection<K, V> {
|
|
|
229
229
|
private resetTimeout;
|
|
230
230
|
private stopTimeout;
|
|
231
231
|
private startTimeout;
|
|
232
|
-
keys():
|
|
233
|
-
values():
|
|
234
|
-
entries():
|
|
232
|
+
keys(): MapIterator<K>;
|
|
233
|
+
values(): MapIterator<LimitedCollectionData<V>>;
|
|
234
|
+
entries(): MapIterator<[K, LimitedCollectionData<V>]>;
|
|
235
235
|
clear(): void;
|
|
236
236
|
private clearExpired;
|
|
237
237
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ApplicationCommandOptionType, ApplicationCommandType, type ApplicationIntegrationType, type InteractionContextType, type APIApplicationCommandBasicOption, type APIApplicationCommandOption, type LocaleString } from '../../types';
|
|
2
1
|
import type { PermissionStrings, SeyfertNumberOption, SeyfertStringOption } from '../..';
|
|
3
2
|
import type { Attachment } from '../../builders';
|
|
3
|
+
import type { GuildRoleStructure, InteractionGuildMemberStructure, UserStructure } from '../../client/transformers';
|
|
4
4
|
import { type Awaitable, type FlatObjectKeys } from '../../common';
|
|
5
5
|
import type { AllChannels, AutocompleteInteraction } from '../../structures';
|
|
6
|
+
import { type APIApplicationCommandBasicOption, type APIApplicationCommandOption, ApplicationCommandOptionType, ApplicationCommandType, type ApplicationIntegrationType, type InteractionContextType, type LocaleString } from '../../types';
|
|
6
7
|
import type { Groups, RegisteredMiddlewares } from '../decorators';
|
|
7
8
|
import type { CommandContext } from './chatcontext';
|
|
8
9
|
import type { DefaultLocale, ExtraProps, IgnoreCommand, OKFunction, OnOptionsReturnObject, StopFunction, UsingClient } from './shared';
|
|
9
|
-
import type { GuildRoleStructure, InteractionGuildMemberStructure, UserStructure } from '../../client/transformers';
|
|
10
10
|
export interface ReturnOptionsTypes {
|
|
11
11
|
1: never;
|
|
12
12
|
2: never;
|
|
@@ -150,6 +150,6 @@ export declare abstract class SubCommand extends BaseCommand {
|
|
|
150
150
|
contexts: BaseCommand["contexts"];
|
|
151
151
|
integration_types: BaseCommand["integrationTypes"];
|
|
152
152
|
};
|
|
153
|
-
abstract run(context: CommandContext
|
|
153
|
+
abstract run(context: CommandContext): any;
|
|
154
154
|
}
|
|
155
155
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SubCommand = exports.Command = exports.BaseCommand = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
|
-
const common_1 = require("../../common");
|
|
6
4
|
const node_util_1 = require("node:util");
|
|
5
|
+
const common_1 = require("../../common");
|
|
6
|
+
const types_1 = require("../../types");
|
|
7
7
|
class BaseCommand {
|
|
8
8
|
middlewares = [];
|
|
9
9
|
__filePath;
|
|
@@ -89,13 +89,12 @@ class BaseCommand {
|
|
|
89
89
|
running = false;
|
|
90
90
|
return res({ pass: true });
|
|
91
91
|
};
|
|
92
|
-
function next(
|
|
92
|
+
function next(...args) {
|
|
93
93
|
if (!running) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
|
|
96
|
+
if (args.length) {
|
|
97
|
+
context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = args[0];
|
|
99
98
|
}
|
|
100
99
|
if (++index >= middlewares.length) {
|
|
101
100
|
running = false;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { AllChannels, InferWithPrefix,
|
|
1
|
+
import type { AllChannels, InferWithPrefix, ReturnCache } from '../..';
|
|
2
|
+
import type { GuildMemberStructure, GuildStructure, InteractionGuildMemberStructure, MessageStructure, OptionResolverStructure, WebhookMessageStructure } from '../../client/transformers';
|
|
2
3
|
import type { If, UnionToTuple, When } from '../../common';
|
|
3
4
|
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest } from '../../common/types/write';
|
|
4
5
|
import { ChatInputCommandInteraction } from '../../structures';
|
|
@@ -6,7 +7,6 @@ import { BaseContext } from '../basecontext';
|
|
|
6
7
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
7
8
|
import type { Command, ContextOptions, OptionsRecord, SubCommand } from './chat';
|
|
8
9
|
import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
|
9
|
-
import type { GuildMemberStructure, GuildStructure, InteractionGuildMemberStructure, MessageStructure, OptionResolverStructure, WebhookMessageStructure } from '../../client/transformers';
|
|
10
10
|
export interface CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends BaseContext, ExtendContext {
|
|
11
11
|
}
|
|
12
12
|
export declare class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> extends BaseContext {
|
|
@@ -26,11 +26,11 @@ export declare class CommandContext<T extends OptionsRecord = {}, M extends keyo
|
|
|
26
26
|
get(locale?: string): import("./shared").DefaultLocale;
|
|
27
27
|
};
|
|
28
28
|
get fullCommandName(): string;
|
|
29
|
-
write<
|
|
30
|
-
deferReply(ephemeral?: boolean): Promise<
|
|
31
|
-
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<
|
|
29
|
+
write<WR extends boolean = false>(body: InteractionCreateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, void | WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>>>;
|
|
30
|
+
deferReply<WR extends boolean = false>(ephemeral?: boolean, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, When<InferWithPrefix, MessageStructure, never> | undefined>>;
|
|
31
|
+
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<When<InferWithPrefix, WebhookMessageStructure | MessageStructure, WebhookMessageStructure>>;
|
|
32
32
|
deleteResponse(): Promise<void>;
|
|
33
|
-
editOrReply<
|
|
33
|
+
editOrReply<WR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>, void | WebhookMessageStructure | When<InferWithPrefix, MessageStructure, never>>>;
|
|
34
34
|
fetchResponse(): Promise<If<InferWithPrefix, WebhookMessageStructure | MessageStructure | undefined, WebhookMessageStructure | undefined>>;
|
|
35
35
|
channel(mode?: 'rest' | 'flow'): Promise<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
|
|
36
36
|
channel(mode?: 'cache'): ReturnCache<If<InferWithPrefix, AllChannels | undefined, AllChannels>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommandContext = void 0;
|
|
4
|
-
const types_1 = require("../../types");
|
|
5
4
|
const structures_1 = require("../../structures");
|
|
5
|
+
const types_1 = require("../../types");
|
|
6
6
|
const basecontext_1 = require("../basecontext");
|
|
7
7
|
class CommandContext extends basecontext_1.BaseContext {
|
|
8
8
|
client;
|
|
@@ -37,21 +37,29 @@ class CommandContext extends basecontext_1.BaseContext {
|
|
|
37
37
|
get fullCommandName() {
|
|
38
38
|
return this.resolver.fullCommandName;
|
|
39
39
|
}
|
|
40
|
-
async write(body,
|
|
40
|
+
async write(body, withResponse) {
|
|
41
41
|
if (this.interaction)
|
|
42
|
-
return this.interaction.write(body,
|
|
42
|
+
return this.interaction.write(body, withResponse);
|
|
43
43
|
const options = this.client.options?.commands;
|
|
44
44
|
return (this.messageResponse = await this.message[!this.messageResponse && options?.reply?.(this) ? 'reply' : 'write'](body));
|
|
45
45
|
}
|
|
46
|
-
async deferReply(ephemeral = false) {
|
|
46
|
+
async deferReply(ephemeral = false, withResponse) {
|
|
47
47
|
if (this.interaction)
|
|
48
|
-
return this.interaction.deferReply(ephemeral ? types_1.MessageFlags.Ephemeral : undefined);
|
|
48
|
+
return this.interaction.deferReply(ephemeral ? types_1.MessageFlags.Ephemeral : undefined, withResponse);
|
|
49
|
+
this.__deferred = true;
|
|
49
50
|
const options = this.client.options?.commands;
|
|
50
51
|
return (this.messageResponse = await this.message[options?.reply?.(this) ? 'reply' : 'write'](options?.deferReplyResponse?.(this) ?? { content: 'Thinking...' }));
|
|
51
52
|
}
|
|
52
53
|
async editResponse(body) {
|
|
53
54
|
if (this.interaction)
|
|
54
55
|
return this.interaction.editResponse(body);
|
|
56
|
+
if (this.__deferred && !this.__edited) {
|
|
57
|
+
this.__edited = true;
|
|
58
|
+
if (this.messageResponse?.content)
|
|
59
|
+
body.content ??= '';
|
|
60
|
+
if (this.messageResponse?.embeds.length)
|
|
61
|
+
body.embeds ??= [];
|
|
62
|
+
}
|
|
55
63
|
return (this.messageResponse = await this.messageResponse.edit(body));
|
|
56
64
|
}
|
|
57
65
|
deleteResponse() {
|
|
@@ -59,13 +67,13 @@ class CommandContext extends basecontext_1.BaseContext {
|
|
|
59
67
|
return this.interaction.deleteResponse();
|
|
60
68
|
return this.messageResponse.delete();
|
|
61
69
|
}
|
|
62
|
-
editOrReply(body,
|
|
70
|
+
editOrReply(body, withResponse) {
|
|
63
71
|
if (this.interaction)
|
|
64
|
-
return this.interaction.editOrReply(body,
|
|
72
|
+
return this.interaction.editOrReply(body, withResponse);
|
|
65
73
|
if (this.messageResponse) {
|
|
66
74
|
return this.editResponse(body);
|
|
67
75
|
}
|
|
68
|
-
return this.write(body,
|
|
76
|
+
return this.write(body, withResponse);
|
|
69
77
|
}
|
|
70
78
|
async fetchResponse() {
|
|
71
79
|
if (this.interaction)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type PermissionStrings } from '../../common';
|
|
2
|
-
import { ApplicationCommandType, type
|
|
2
|
+
import { ApplicationCommandType, type ApplicationIntegrationType, type EntryPointCommandHandlerType, type InteractionContextType, type LocaleString } from '../../types';
|
|
3
3
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
4
4
|
import type { EntryPointContext } from './entrycontext';
|
|
5
5
|
import type { ExtraProps, UsingClient } from './shared';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { ReturnCache } from '../..';
|
|
2
|
+
import type { GuildMemberStructure, GuildStructure, MessageStructure, WebhookMessageStructure } from '../../client/transformers';
|
|
2
3
|
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, ModalCreateBodyRequest, UnionToTuple, When } from '../../common';
|
|
3
4
|
import type { AllChannels, EntryPointInteraction } from '../../structures';
|
|
4
5
|
import { BaseContext } from '../basecontext';
|
|
5
6
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
6
|
-
import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
|
7
|
-
import type { GuildMemberStructure, GuildStructure, MessageStructure, WebhookMessageStructure } from '../../client/transformers';
|
|
8
7
|
import type { EntryPointCommand } from './entryPoint';
|
|
8
|
+
import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
|
9
9
|
export interface EntryPointContext<M extends keyof RegisteredMiddlewares = never> extends BaseContext, ExtendContext {
|
|
10
10
|
}
|
|
11
11
|
export declare class EntryPointContext<M extends keyof RegisteredMiddlewares = never> extends BaseContext {
|
|
@@ -20,12 +20,12 @@ export declare class EntryPointContext<M extends keyof RegisteredMiddlewares = n
|
|
|
20
20
|
get(locale?: string): import("./shared").DefaultLocale;
|
|
21
21
|
};
|
|
22
22
|
get fullCommandName(): string;
|
|
23
|
-
write<
|
|
24
|
-
modal(body: ModalCreateBodyRequest): Promise<
|
|
25
|
-
deferReply(ephemeral?: boolean): Promise<
|
|
23
|
+
write<WR extends boolean = false>(body: InteractionCreateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure, void | WebhookMessageStructure>>;
|
|
24
|
+
modal(body: ModalCreateBodyRequest): Promise<undefined>;
|
|
25
|
+
deferReply<WR extends boolean = false>(ephemeral?: boolean): Promise<When<WR, WebhookMessageStructure, undefined>>;
|
|
26
26
|
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<import("../..").WebhookMessage>;
|
|
27
27
|
deleteResponse(): Promise<void | undefined>;
|
|
28
|
-
editOrReply<
|
|
28
|
+
editOrReply<WR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | MessageStructure, void | WebhookMessageStructure | MessageStructure>>;
|
|
29
29
|
fetchResponse(): Promise<import("../..").WebhookMessage | undefined>;
|
|
30
30
|
channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
|
|
31
31
|
channel(mode?: 'cache'): ReturnCache<AllChannels>;
|
|
@@ -23,8 +23,8 @@ class EntryPointContext extends basecontext_1.BaseContext {
|
|
|
23
23
|
get fullCommandName() {
|
|
24
24
|
return this.command.name;
|
|
25
25
|
}
|
|
26
|
-
write(body,
|
|
27
|
-
return this.interaction.write(body,
|
|
26
|
+
write(body, withResponse) {
|
|
27
|
+
return this.interaction.write(body, withResponse);
|
|
28
28
|
}
|
|
29
29
|
modal(body) {
|
|
30
30
|
return this.interaction.modal(body);
|
|
@@ -38,8 +38,8 @@ class EntryPointContext extends basecontext_1.BaseContext {
|
|
|
38
38
|
deleteResponse() {
|
|
39
39
|
return this.interaction.deleteResponse();
|
|
40
40
|
}
|
|
41
|
-
editOrReply(body,
|
|
42
|
-
return this.interaction.editOrReply(body,
|
|
41
|
+
editOrReply(body, withResponse) {
|
|
42
|
+
return this.interaction.editOrReply(body, withResponse);
|
|
43
43
|
}
|
|
44
44
|
fetchResponse() {
|
|
45
45
|
return this.interaction.fetchResponse();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ApplicationCommandType, ApplicationIntegrationType, InteractionContextType, LocaleString } from '../../types';
|
|
2
1
|
import { type PermissionStrings } from '../../common';
|
|
2
|
+
import type { ApplicationCommandType, ApplicationIntegrationType, InteractionContextType, LocaleString } from '../../types';
|
|
3
3
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
4
4
|
import type { MenuCommandContext } from './menucontext';
|
|
5
5
|
import type { ExtraProps, UsingClient } from './shared';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ContextMenuCommand, ReturnCache } from '../..';
|
|
2
|
+
import { type GuildMemberStructure, type GuildStructure, type MessageStructure, type UserStructure, type WebhookMessageStructure } from '../../client/transformers';
|
|
2
3
|
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type ModalCreateBodyRequest, type UnionToTuple, type When } from '../../common';
|
|
3
4
|
import type { AllChannels, MessageCommandInteraction, UserCommandInteraction } from '../../structures';
|
|
4
5
|
import { BaseContext } from '../basecontext';
|
|
5
6
|
import type { RegisteredMiddlewares } from '../decorators';
|
|
6
7
|
import type { CommandMetadata, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
|
7
|
-
import { type GuildMemberStructure, type GuildStructure, type MessageStructure, type UserStructure, type WebhookMessageStructure } from '../../client/transformers';
|
|
8
8
|
export type InteractionTarget<T> = T extends MessageCommandInteraction ? MessageStructure : UserStructure;
|
|
9
9
|
export interface MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> extends BaseContext, ExtendContext {
|
|
10
10
|
}
|
|
@@ -21,12 +21,12 @@ export declare class MenuCommandContext<T extends MessageCommandInteraction | Us
|
|
|
21
21
|
get(locale?: string): import("./shared").DefaultLocale;
|
|
22
22
|
};
|
|
23
23
|
get fullCommandName(): string;
|
|
24
|
-
write<
|
|
25
|
-
modal(body: ModalCreateBodyRequest): Promise<
|
|
26
|
-
deferReply(ephemeral?: boolean): Promise<
|
|
24
|
+
write<WR extends boolean = false>(body: InteractionCreateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure, void | WebhookMessageStructure>>;
|
|
25
|
+
modal(body: ModalCreateBodyRequest): Promise<undefined>;
|
|
26
|
+
deferReply<WR extends boolean = false>(ephemeral?: boolean): Promise<When<WR, WebhookMessageStructure, undefined>>;
|
|
27
27
|
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<import("../..").WebhookMessage>;
|
|
28
28
|
deleteResponse(): Promise<void | undefined>;
|
|
29
|
-
editOrReply<
|
|
29
|
+
editOrReply<WR extends boolean = false>(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest, withResponse?: WR): Promise<When<WR, WebhookMessageStructure | MessageStructure, void | WebhookMessageStructure | MessageStructure>>;
|
|
30
30
|
fetchResponse(): Promise<import("../..").WebhookMessage | undefined>;
|
|
31
31
|
channel(mode?: 'rest' | 'flow'): Promise<AllChannels>;
|
|
32
32
|
channel(mode?: 'cache'): ReturnCache<AllChannels>;
|