seyfert 4.5.0 → 4.6.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/Routes/guilds.d.ts +12 -1
- package/lib/api/Routes/index.d.ts +3 -1
- package/lib/api/Routes/invites.d.ts +1 -1
- package/lib/api/Routes/oauth2.d.ts +11 -0
- package/lib/api/Routes/oauth2.js +2 -0
- package/lib/api/Routes/skus.d.ts +11 -4
- package/lib/api/Routes/users.d.ts +2 -1
- package/lib/api/Routes/voice.d.ts +4 -0
- package/lib/api/Routes/webhooks.d.ts +1 -1
- package/lib/api/api.d.ts +15 -5
- package/lib/api/api.js +243 -114
- package/lib/api/bucket.js +13 -7
- package/lib/api/shared.d.ts +3 -1
- package/lib/api/utils/constants.d.ts +1 -1
- package/lib/api/utils/constants.js +1 -1
- package/lib/builders/Attachment.d.ts +6 -1
- package/lib/builders/Attachment.js +13 -9
- package/lib/builders/CheckboxGroup.js +1 -1
- package/lib/builders/FileUpload.d.ts +8 -1
- package/lib/builders/FileUpload.js +9 -0
- package/lib/builders/RadioGroup.js +1 -1
- package/lib/client/base.d.ts +3 -3
- package/lib/client/collectors.d.ts +10 -8
- package/lib/client/transformers.d.ts +5 -0
- package/lib/client/workerclient.d.ts +8 -1
- package/lib/client/workerclient.js +28 -9
- package/lib/commands/applications/chat.d.ts +6 -4
- package/lib/commands/applications/options.d.ts +6 -4
- package/lib/commands/applications/shared.d.ts +2 -2
- package/lib/commands/handle.d.ts +7 -3
- package/lib/commands/handle.js +36 -11
- package/lib/commands/handler.js +11 -0
- package/lib/commands/optionresolver.d.ts +6 -7
- package/lib/common/it/error.d.ts +13 -0
- package/lib/common/it/error.js +15 -1
- package/lib/common/it/logger.js +12 -9
- package/lib/common/shorters/application.d.ts +1 -1
- package/lib/common/shorters/application.js +1 -1
- package/lib/common/shorters/bans.js +1 -1
- package/lib/common/shorters/guilds.js +5 -1
- package/lib/common/shorters/interaction.js +7 -4
- package/lib/common/shorters/invites.d.ts +5 -0
- package/lib/common/shorters/members.js +2 -1
- package/lib/common/shorters/messages.js +2 -2
- package/lib/common/shorters/threads.js +1 -1
- package/lib/common/shorters/webhook.js +3 -3
- package/lib/common/types/util.d.ts +7 -0
- package/lib/components/componentcommand.js +2 -2
- package/lib/components/customId.d.ts +3 -0
- package/lib/components/customId.js +11 -0
- package/lib/components/handler.js +2 -3
- package/lib/components/modalcommand.js +2 -2
- package/lib/events/hooks/invite.d.ts +1 -0
- package/lib/events/hooks/presence.d.ts +1 -0
- package/lib/events/hooks/thread.d.ts +1 -0
- package/lib/structures/AnonymousGuild.d.ts +1 -1
- package/lib/structures/AnonymousGuild.js +1 -1
- package/lib/structures/Guild.d.ts +3 -0
- package/lib/structures/GuildMember.d.ts +2 -2
- package/lib/structures/GuildMember.js +22 -4
- package/lib/structures/GuildPreview.d.ts +1 -1
- package/lib/structures/GuildPreview.js +1 -1
- package/lib/structures/GuildRole.d.ts +13 -0
- package/lib/structures/GuildRole.js +21 -0
- package/lib/structures/GuildTemplate.js +1 -1
- package/lib/structures/Interaction.d.ts +7 -7
- package/lib/structures/Interaction.js +35 -21
- package/lib/structures/Message.d.ts +2 -1
- package/lib/structures/channels.d.ts +29 -16
- package/lib/structures/channels.js +59 -19
- package/lib/structures/extra/BaseGuild.d.ts +4 -4
- package/lib/structures/extra/BaseGuild.js +4 -4
- package/lib/types/gateway.d.ts +243 -239
- package/lib/types/index.d.ts +2 -2
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/attachment.d.ts +5 -2
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.d.ts +2 -2
- package/lib/types/payloads/_interactions/_applicationCommands/_chatInput/shared.js +1 -1
- package/lib/types/payloads/_interactions/_applicationCommands/chatInput.d.ts +7 -7
- package/lib/types/payloads/_interactions/_applicationCommands/contextMenu.d.ts +13 -13
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.d.ts +4 -4
- package/lib/types/payloads/_interactions/_applicationCommands/permissions.js +2 -2
- package/lib/types/payloads/_interactions/applicationCommands.d.ts +10 -10
- package/lib/types/payloads/_interactions/applicationCommands.js +4 -4
- package/lib/types/payloads/_interactions/autocomplete.d.ts +2 -2
- package/lib/types/payloads/_interactions/base.d.ts +13 -7
- package/lib/types/payloads/_interactions/modalSubmit.d.ts +4 -4
- package/lib/types/payloads/_interactions/responses.d.ts +10 -10
- package/lib/types/payloads/_interactions/responses.js +2 -2
- package/lib/types/payloads/application.d.ts +21 -15
- package/lib/types/payloads/application.js +7 -7
- package/lib/types/payloads/auditLog.d.ts +22 -17
- package/lib/types/payloads/auditLog.js +7 -2
- package/lib/types/payloads/autoModeration.d.ts +11 -11
- package/lib/types/payloads/autoModeration.js +5 -5
- package/lib/types/payloads/channel.d.ts +87 -78
- package/lib/types/payloads/channel.js +16 -11
- package/lib/types/payloads/components.d.ts +41 -31
- package/lib/types/payloads/components.js +9 -5
- package/lib/types/payloads/emoji.d.ts +2 -2
- package/lib/types/payloads/emoji.js +1 -1
- package/lib/types/payloads/gateway.d.ts +33 -29
- package/lib/types/payloads/gateway.js +5 -5
- package/lib/types/payloads/guild.d.ts +68 -68
- package/lib/types/payloads/guild.js +14 -14
- package/lib/types/payloads/guildScheduledEvent.d.ts +11 -11
- package/lib/types/payloads/guildScheduledEvent.js +3 -3
- package/lib/types/payloads/index.d.ts +2 -2
- package/lib/types/payloads/interactions.d.ts +3 -3
- package/lib/types/payloads/invite.d.ts +11 -11
- package/lib/types/payloads/invite.js +3 -3
- package/lib/types/payloads/monetization.d.ts +4 -4
- package/lib/types/payloads/monetization.js +2 -2
- package/lib/types/payloads/oauth2.d.ts +21 -17
- package/lib/types/payloads/oauth2.js +21 -17
- package/lib/types/payloads/permissions.d.ts +5 -5
- package/lib/types/payloads/permissions.js +2 -2
- package/lib/types/payloads/poll.d.ts +7 -7
- package/lib/types/payloads/poll.js +2 -2
- package/lib/types/payloads/soundboard.d.ts +2 -2
- package/lib/types/payloads/soundboard.js +1 -1
- package/lib/types/payloads/stageInstance.d.ts +5 -5
- package/lib/types/payloads/stageInstance.js +1 -1
- package/lib/types/payloads/sticker.d.ts +8 -8
- package/lib/types/payloads/sticker.js +3 -3
- package/lib/types/payloads/teams.d.ts +8 -8
- package/lib/types/payloads/teams.js +3 -3
- package/lib/types/payloads/template.d.ts +3 -3
- package/lib/types/payloads/template.js +1 -1
- package/lib/types/payloads/user.d.ts +24 -22
- package/lib/types/payloads/user.js +7 -5
- package/lib/types/payloads/voice.d.ts +4 -4
- package/lib/types/payloads/voice.js +1 -1
- package/lib/types/payloads/webhokEvents.d.ts +5 -5
- package/lib/types/payloads/webhokEvents.js +2 -2
- package/lib/types/payloads/webhook.d.ts +4 -4
- package/lib/types/payloads/webhook.js +1 -1
- package/lib/types/rest/application.d.ts +14 -14
- package/lib/types/rest/auditLog.d.ts +1 -1
- package/lib/types/rest/autoModeration.d.ts +7 -7
- package/lib/types/rest/channel.d.ts +79 -74
- package/lib/types/rest/channel.js +1 -1
- package/lib/types/rest/emoji.d.ts +8 -8
- package/lib/types/rest/gateway.d.ts +2 -2
- package/lib/types/rest/guild.d.ts +98 -98
- package/lib/types/rest/guild.js +5 -5
- package/lib/types/rest/guildScheduledEvent.d.ts +11 -11
- package/lib/types/rest/index.d.ts +34 -3
- package/lib/types/rest/index.js +33 -2
- package/lib/types/rest/interactions.d.ts +48 -48
- package/lib/types/rest/invite.d.ts +5 -5
- package/lib/types/rest/monetization.d.ts +9 -9
- package/lib/types/rest/monetization.js +1 -1
- package/lib/types/rest/oauth2.d.ts +22 -18
- package/lib/types/rest/poll.d.ts +4 -4
- package/lib/types/rest/soundboard.d.ts +8 -8
- package/lib/types/rest/stageInstance.d.ts +6 -6
- package/lib/types/rest/sticker.d.ts +10 -10
- package/lib/types/rest/template.d.ts +11 -11
- package/lib/types/rest/user.d.ts +18 -14
- package/lib/types/rest/voice.d.ts +5 -5
- package/lib/types/rest/webhook.d.ts +38 -38
- package/lib/types/utils/index.d.ts +19 -19
- package/lib/types/utils/index.js +19 -19
- package/lib/websocket/SharedTypes.d.ts +2 -2
- package/lib/websocket/constants/index.js +2 -2
- package/lib/websocket/discord/heartbeater.d.ts +1 -0
- package/lib/websocket/discord/heartbeater.js +8 -0
- package/lib/websocket/discord/shard.d.ts +19 -10
- package/lib/websocket/discord/shard.js +254 -121
- package/lib/websocket/discord/sharder.d.ts +2 -2
- package/lib/websocket/discord/sharder.js +1 -1
- package/lib/websocket/discord/shared.d.ts +7 -2
- package/lib/websocket/discord/workermanager.d.ts +3 -1
- package/lib/websocket/discord/workermanager.js +31 -24
- package/package.json +2 -2
|
@@ -85,9 +85,7 @@ class WorkerManager extends Map {
|
|
|
85
85
|
}
|
|
86
86
|
const id = workerId ?? this.calculateWorkerId(shardId);
|
|
87
87
|
if (!this.has(id)) {
|
|
88
|
-
throw
|
|
89
|
-
metadata: { ...{ workerId: id }, detail: `Worker #${id} doesn't exist` },
|
|
90
|
-
});
|
|
88
|
+
throw this.createWorkerNotFoundError(id);
|
|
91
89
|
}
|
|
92
90
|
const data = await this.getWorkerInfo(id);
|
|
93
91
|
return data.shards.reduce((acc, prv) => acc + prv.latency, 0) / data.shards.length;
|
|
@@ -95,22 +93,25 @@ class WorkerManager extends Map {
|
|
|
95
93
|
calculateShardId(guildId) {
|
|
96
94
|
return Number((BigInt(guildId) >> 22n) % BigInt(this.totalShards));
|
|
97
95
|
}
|
|
96
|
+
createWorkerNotFoundError(workerId) {
|
|
97
|
+
return new common_1.SeyfertError('WORKER_NOT_FOUND', {
|
|
98
|
+
metadata: { workerId, detail: `Worker #${workerId} doesn't exist` },
|
|
99
|
+
});
|
|
100
|
+
}
|
|
98
101
|
calculateWorkerId(shardId) {
|
|
99
|
-
const
|
|
100
|
-
|
|
102
|
+
const minimumShardId = this.shardStart;
|
|
103
|
+
const maximumShardId = this.shardEnd - 1;
|
|
104
|
+
if (shardId < minimumShardId || shardId > maximumShardId) {
|
|
101
105
|
throw new common_1.SeyfertError('INVALID_SHARD_ID', {
|
|
102
106
|
metadata: {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
totalWorkers: this.totalWorkers,
|
|
108
|
-
},
|
|
109
|
-
detail: 'Invalid shardId',
|
|
107
|
+
shardId,
|
|
108
|
+
minimumShardId,
|
|
109
|
+
maximumShardId,
|
|
110
|
+
detail: `Invalid shardId ${shardId}: expected ${minimumShardId}..${maximumShardId}.`,
|
|
110
111
|
},
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
|
-
return
|
|
114
|
+
return Math.floor((shardId - minimumShardId) / this.shardsPerWorker);
|
|
114
115
|
}
|
|
115
116
|
postMessage(id, body) {
|
|
116
117
|
const worker = this.get(id);
|
|
@@ -185,6 +186,7 @@ class WorkerManager extends Map {
|
|
|
185
186
|
metadata: { detail: 'Cannot create worker without worker_threads.' },
|
|
186
187
|
});
|
|
187
188
|
const env = {
|
|
189
|
+
...this.options.workerEnv,
|
|
188
190
|
SEYFERT_SPAWNING: 'true',
|
|
189
191
|
};
|
|
190
192
|
if (workerData.resharding)
|
|
@@ -196,7 +198,7 @@ class WorkerManager extends Map {
|
|
|
196
198
|
switch (this.options.mode) {
|
|
197
199
|
case 'threads': {
|
|
198
200
|
const worker = new worker_threads.Worker(workerData.path, {
|
|
199
|
-
env,
|
|
201
|
+
env: { ...process.env, ...env },
|
|
200
202
|
});
|
|
201
203
|
worker.on('message', data => this.handleWorkerMessage(data));
|
|
202
204
|
worker.on('error', err => {
|
|
@@ -413,9 +415,12 @@ class WorkerManager extends Map {
|
|
|
413
415
|
});
|
|
414
416
|
}
|
|
415
417
|
const response = await this.rest.request(message.method, message.url, message.requestOptions);
|
|
418
|
+
const encodedResponse = response instanceof ArrayBuffer ? Array.from(new Uint8Array(response)) : response;
|
|
419
|
+
const responseType = response instanceof ArrayBuffer ? 'arrayBuffer' : undefined;
|
|
416
420
|
this.postMessage(message.workerId, {
|
|
417
421
|
nonce: message.nonce,
|
|
418
|
-
response,
|
|
422
|
+
response: encodedResponse,
|
|
423
|
+
responseType,
|
|
419
424
|
type: 'API_RESPONSE',
|
|
420
425
|
});
|
|
421
426
|
}
|
|
@@ -442,7 +447,7 @@ class WorkerManager extends Map {
|
|
|
442
447
|
toWorkerId: message.toWorkerId,
|
|
443
448
|
vars: message.vars,
|
|
444
449
|
});
|
|
445
|
-
this.generateSendPromise(nonce, '
|
|
450
|
+
this.generateSendPromise(nonce, 'Worker evaluation').then(val => this.postMessage(message.workerId, {
|
|
446
451
|
nonce: message.nonce,
|
|
447
452
|
response: val,
|
|
448
453
|
type: 'EVAL_RESPONSE',
|
|
@@ -457,11 +462,13 @@ class WorkerManager extends Map {
|
|
|
457
462
|
return this.generateNonce();
|
|
458
463
|
return uuid;
|
|
459
464
|
}
|
|
460
|
-
generateSendPromise(nonce,
|
|
465
|
+
generateSendPromise(nonce, operation = 'Worker request') {
|
|
461
466
|
return new Promise((res, rej) => {
|
|
462
467
|
const timeout = setTimeout(() => {
|
|
463
468
|
this.promises.delete(nonce);
|
|
464
|
-
rej(new common_1.SeyfertError('WORKER_TIMEOUT', {
|
|
469
|
+
rej(new common_1.SeyfertError('WORKER_TIMEOUT', {
|
|
470
|
+
metadata: { nonce, operation, detail: `${operation} timed out (nonce: ${nonce}).` },
|
|
471
|
+
}));
|
|
465
472
|
}, 60e3);
|
|
466
473
|
this.promises.set(nonce, { resolve: res, timeout });
|
|
467
474
|
});
|
|
@@ -470,7 +477,7 @@ class WorkerManager extends Map {
|
|
|
470
477
|
const workerId = this.calculateWorkerId(shardId);
|
|
471
478
|
const worker = this.has(workerId);
|
|
472
479
|
if (!worker) {
|
|
473
|
-
throw
|
|
480
|
+
throw this.createWorkerNotFoundError(workerId);
|
|
474
481
|
}
|
|
475
482
|
const nonce = this.generateNonce();
|
|
476
483
|
this.postMessage(workerId, {
|
|
@@ -479,26 +486,26 @@ class WorkerManager extends Map {
|
|
|
479
486
|
nonce,
|
|
480
487
|
...data,
|
|
481
488
|
});
|
|
482
|
-
return this.generateSendPromise(nonce, 'Shard
|
|
489
|
+
return this.generateSendPromise(nonce, 'Shard payload send');
|
|
483
490
|
}
|
|
484
491
|
async getShardInfo(shardId) {
|
|
485
492
|
const workerId = this.calculateWorkerId(shardId);
|
|
486
493
|
const worker = this.has(workerId);
|
|
487
494
|
if (!worker) {
|
|
488
|
-
throw
|
|
495
|
+
throw this.createWorkerNotFoundError(workerId);
|
|
489
496
|
}
|
|
490
497
|
const nonce = this.generateNonce();
|
|
491
498
|
this.postMessage(workerId, { shardId, nonce, type: 'SHARD_INFO' });
|
|
492
|
-
return this.generateSendPromise(nonce, '
|
|
499
|
+
return this.generateSendPromise(nonce, 'Shard info request');
|
|
493
500
|
}
|
|
494
501
|
async getWorkerInfo(workerId) {
|
|
495
502
|
const worker = this.has(workerId);
|
|
496
503
|
if (!worker) {
|
|
497
|
-
throw
|
|
504
|
+
throw this.createWorkerNotFoundError(workerId);
|
|
498
505
|
}
|
|
499
506
|
const nonce = this.generateNonce();
|
|
500
507
|
this.postMessage(workerId, { nonce, type: 'WORKER_INFO' });
|
|
501
|
-
return this.generateSendPromise(nonce, '
|
|
508
|
+
return this.generateSendPromise(nonce, 'Worker info request');
|
|
502
509
|
}
|
|
503
510
|
tellWorker(workerId, func, vars) {
|
|
504
511
|
const nonce = this.generateNonce();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "seyfert",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "The most advanced framework for discord bots",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"module": "./lib/index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@types/node": "^24.10.0",
|
|
29
29
|
"husky": "^9.1.7",
|
|
30
30
|
"typescript": "^5.9.3",
|
|
31
|
-
"vitest": "^
|
|
31
|
+
"vitest": "^4.1.10"
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://seyfert.dev",
|
|
34
34
|
"repository": {
|