@seedcord/gateway 0.1.0-next.0 → 0.1.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +37 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +28 -18
- package/dist/index.mjs +35 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ let chalk = require("chalk");
|
|
|
38
38
|
chalk = __toESM(chalk, 1);
|
|
39
39
|
let _discordjs_builders = require("@discordjs/builders");
|
|
40
40
|
let _seedcord_utils_internal = require("@seedcord/utils/internal");
|
|
41
|
+
let _seedcord_event_emitter = require("@seedcord/event-emitter");
|
|
41
42
|
let node_fs = require("node:fs");
|
|
42
43
|
let node_path = require("node:path");
|
|
43
44
|
let node_url = require("node:url");
|
|
@@ -1265,7 +1266,7 @@ function getDevChannel() {
|
|
|
1265
1266
|
* Extend this class to create plugins that integrate with the Seedcord lifecycle.
|
|
1266
1267
|
* Plugins have access to the core instance and must implement initialization logic.
|
|
1267
1268
|
*/
|
|
1268
|
-
var Plugin = class extends
|
|
1269
|
+
var Plugin = class extends _seedcord_event_emitter.TypedEventEmitter {
|
|
1269
1270
|
pluggable;
|
|
1270
1271
|
name = this.constructor.name;
|
|
1271
1272
|
constructor(pluggable) {
|
|
@@ -1287,16 +1288,12 @@ var Plugin = class extends _seedcord_services.StrictEventEmitter {
|
|
|
1287
1288
|
getDevChannel()?.send("seedcord:register-critical-files", { patterns });
|
|
1288
1289
|
}
|
|
1289
1290
|
/** @internal */
|
|
1290
|
-
setMaxListeners(n) {
|
|
1291
|
-
return super.setMaxListeners(n);
|
|
1292
|
-
}
|
|
1293
|
-
/** @internal */
|
|
1294
1291
|
removeListener(event, listener) {
|
|
1295
1292
|
return super.removeListener(event, listener);
|
|
1296
1293
|
}
|
|
1297
1294
|
/** @internal */
|
|
1298
|
-
removeAllListeners(
|
|
1299
|
-
return super.removeAllListeners(
|
|
1295
|
+
removeAllListeners(event) {
|
|
1296
|
+
return super.removeAllListeners(event);
|
|
1300
1297
|
}
|
|
1301
1298
|
};
|
|
1302
1299
|
/**
|
|
@@ -1305,7 +1302,7 @@ var Plugin = class extends _seedcord_services.StrictEventEmitter {
|
|
|
1305
1302
|
* Provides plugin attachment capabilities and lifecycle management. Plugins are attached during
|
|
1306
1303
|
* configuration and initialized during startup. Not constructed directly, the host is a {@link Seedcord}.
|
|
1307
1304
|
*/
|
|
1308
|
-
var Pluggable = class Pluggable extends
|
|
1305
|
+
var Pluggable = class Pluggable extends _seedcord_event_emitter.TypedEventEmitter {
|
|
1309
1306
|
isInitialized = false;
|
|
1310
1307
|
shutdown;
|
|
1311
1308
|
startup;
|
|
@@ -1358,16 +1355,12 @@ var Pluggable = class Pluggable extends _seedcord_services.StrictEventEmitter {
|
|
|
1358
1355
|
return Object.assign(this, entry);
|
|
1359
1356
|
}
|
|
1360
1357
|
/** @internal */
|
|
1361
|
-
setMaxListeners(n) {
|
|
1362
|
-
return super.setMaxListeners(n);
|
|
1363
|
-
}
|
|
1364
|
-
/** @internal */
|
|
1365
1358
|
removeListener(event, listener) {
|
|
1366
1359
|
return super.removeListener(event, listener);
|
|
1367
1360
|
}
|
|
1368
1361
|
/** @internal */
|
|
1369
|
-
removeAllListeners(
|
|
1370
|
-
return super.removeAllListeners(
|
|
1362
|
+
removeAllListeners(event) {
|
|
1363
|
+
return super.removeAllListeners(event);
|
|
1371
1364
|
}
|
|
1372
1365
|
};
|
|
1373
1366
|
|
|
@@ -1380,10 +1373,12 @@ var BaseHandler = class {
|
|
|
1380
1373
|
core;
|
|
1381
1374
|
event;
|
|
1382
1375
|
logger;
|
|
1383
|
-
|
|
1376
|
+
dispatch;
|
|
1377
|
+
constructor(event, core, dispatch) {
|
|
1384
1378
|
this.core = core;
|
|
1385
1379
|
this.event = event;
|
|
1386
1380
|
this.logger = new _seedcord_services.Logger(this.constructor.name);
|
|
1381
|
+
this.dispatch = dispatch;
|
|
1387
1382
|
}
|
|
1388
1383
|
/** @internal */
|
|
1389
1384
|
getEvent() {
|
|
@@ -1419,8 +1414,8 @@ var InteractionMiddleware = class extends BaseHandler {
|
|
|
1419
1414
|
* @typeParam Repliable - The interaction type this handler processes
|
|
1420
1415
|
*/
|
|
1421
1416
|
var InteractionHandler = class extends BaseHandler {
|
|
1422
|
-
constructor(event, core) {
|
|
1423
|
-
super(event, core);
|
|
1417
|
+
constructor(event, core, dispatch) {
|
|
1418
|
+
super(event, core, dispatch);
|
|
1424
1419
|
}
|
|
1425
1420
|
};
|
|
1426
1421
|
|
|
@@ -1565,8 +1560,8 @@ var ContextMenuHandler = class extends InteractionHandler {
|
|
|
1565
1560
|
* ```
|
|
1566
1561
|
*/
|
|
1567
1562
|
var AutocompleteHandler = class extends BaseHandler {
|
|
1568
|
-
constructor(event, core) {
|
|
1569
|
-
super(event, core);
|
|
1563
|
+
constructor(event, core, dispatch) {
|
|
1564
|
+
super(event, core, dispatch);
|
|
1570
1565
|
}
|
|
1571
1566
|
/**
|
|
1572
1567
|
* The focused option for this interaction. `value` is always the raw partial string the user is typing,
|
|
@@ -2602,7 +2597,8 @@ function interactionGateContext(interaction, core) {
|
|
|
2602
2597
|
guildId: interaction.guildId,
|
|
2603
2598
|
channelId: interaction.channelId,
|
|
2604
2599
|
memberRoleIds,
|
|
2605
|
-
memberPermissions: interaction.memberPermissions?.bitfield ?? null
|
|
2600
|
+
memberPermissions: interaction.memberPermissions?.bitfield ?? null,
|
|
2601
|
+
routeId: null
|
|
2606
2602
|
};
|
|
2607
2603
|
}
|
|
2608
2604
|
function eventGateContext(eventName, args, core) {
|
|
@@ -2619,7 +2615,8 @@ function eventGateContext(eventName, args, core) {
|
|
|
2619
2615
|
guildId: actor.guild?.id ?? null,
|
|
2620
2616
|
channelId: actor.channelId,
|
|
2621
2617
|
memberRoleIds: actor.member ? [...actor.member.roles.cache.keys()].filter((id) => id !== actor.guild?.id) : [],
|
|
2622
|
-
memberPermissions: actor.member?.permissions.bitfield ?? null
|
|
2618
|
+
memberPermissions: actor.member?.permissions.bitfield ?? null,
|
|
2619
|
+
routeId: null
|
|
2623
2620
|
};
|
|
2624
2621
|
}
|
|
2625
2622
|
|
|
@@ -2993,7 +2990,7 @@ var EventDispatcher = class {
|
|
|
2993
2990
|
const handlerEntries = this.eventMap.get(eventName);
|
|
2994
2991
|
this.logger.debug(`Attaching ${chalk.default.bold.green(eventName)} to the client with ${chalk.default.gray(handlerEntries?.length ?? 0)} handler(s)`);
|
|
2995
2992
|
this.core.bot.client.on(eventName, (...args) => {
|
|
2996
|
-
this.core.bot.
|
|
2993
|
+
this.core.bot.emitSafe("any:event", eventName, ...args);
|
|
2997
2994
|
(async () => {
|
|
2998
2995
|
await this.processEvent(eventName, args).catch((err) => {
|
|
2999
2996
|
this.logger.error(`[${chalk.default.bold.red("UNHANDLED ERROR AT ROOT")}] ${err.name}`, err.stack);
|
|
@@ -3284,7 +3281,7 @@ var InteractionDispatcher = class {
|
|
|
3284
3281
|
}
|
|
3285
3282
|
attachToClient() {
|
|
3286
3283
|
this.core.bot.client.on(discord_js.Events.InteractionCreate, (interaction) => {
|
|
3287
|
-
this.core.bot.
|
|
3284
|
+
this.core.bot.emitSafe("any:interaction", interaction);
|
|
3288
3285
|
this.handleInteraction(interaction).catch((err) => {
|
|
3289
3286
|
this.logger.error(`[${chalk.default.bold.red("UNHANDLED ERROR AT ROOT")}] ${err.name}`, err.stack);
|
|
3290
3287
|
this.core.bot.emit("error:unhandled:interaction", err);
|
|
@@ -3307,7 +3304,8 @@ var InteractionDispatcher = class {
|
|
|
3307
3304
|
HandlerCtor = UnhandledEvent;
|
|
3308
3305
|
}
|
|
3309
3306
|
this.logger.debug(`Processing ${chalk.default.bold.green(key)} with ${chalk.default.gray(HandlerCtor.name)}`);
|
|
3310
|
-
const
|
|
3307
|
+
const dispatch = new _seedcord_core.DispatchContext((0, _seedcord_core_internal.routeIdOf)(HandlerCtor));
|
|
3308
|
+
const handler = new HandlerCtor(interaction, this.core, dispatch);
|
|
3311
3309
|
if (!interaction.isAutocomplete()) await (0, _seedcord_core_internal.runHandlerGates)(HandlerCtor, interactionGateContext(interaction, this.core));
|
|
3312
3310
|
await handler.execute();
|
|
3313
3311
|
} catch (caught) {
|
|
@@ -3498,6 +3496,12 @@ var Bot = class extends Plugin {
|
|
|
3498
3496
|
emit(event, ...args) {
|
|
3499
3497
|
return super.emit(event, ...args);
|
|
3500
3498
|
}
|
|
3499
|
+
emitSafe(event, ...args) {
|
|
3500
|
+
return super.emitSafe(event, ...args);
|
|
3501
|
+
}
|
|
3502
|
+
onListenerError(error, event) {
|
|
3503
|
+
this.logger.error(`listener for ${String(event)} threw`, error);
|
|
3504
|
+
}
|
|
3501
3505
|
};
|
|
3502
3506
|
__decorate([(0, envapt.Envapt)("DISCORD_BOT_TOKEN", { converter: (raw) => (0, _seedcord_errors_internal.validateDiscordToken)(raw) }), __decorateMetadata("design:type", String)], Bot.prototype, "botToken", void 0);
|
|
3503
3507
|
|
|
@@ -3831,7 +3835,7 @@ var Bus = class extends Plugin {
|
|
|
3831
3835
|
//#endregion
|
|
3832
3836
|
//#region src/version.ts
|
|
3833
3837
|
/** Package version */
|
|
3834
|
-
const version = "0.1.0-next.
|
|
3838
|
+
const version = "0.1.0-next.1";
|
|
3835
3839
|
|
|
3836
3840
|
//#endregion
|
|
3837
3841
|
//#region src/Seedcord.ts
|
|
@@ -3884,7 +3888,7 @@ var Seedcord = class Seedcord extends Pluggable {
|
|
|
3884
3888
|
this.hmrManager.init();
|
|
3885
3889
|
this.bus = new Bus(this);
|
|
3886
3890
|
this.bot = new Bot(this);
|
|
3887
|
-
this.rateLimiter = new _seedcord_rate_limiter.MemoryRateLimiter();
|
|
3891
|
+
this.rateLimiter = config.store ?? new _seedcord_rate_limiter.MemoryRateLimiter();
|
|
3888
3892
|
this.healthCheck = new _seedcord_services.HealthCheck(this.shutdown, config.healthCheck);
|
|
3889
3893
|
this.registerStartupTasks();
|
|
3890
3894
|
}
|
|
@@ -4006,6 +4010,13 @@ Object.keys(_seedcord_errors).forEach(function (k) {
|
|
|
4006
4010
|
});
|
|
4007
4011
|
});
|
|
4008
4012
|
|
|
4013
|
+
Object.keys(_seedcord_event_emitter).forEach(function (k) {
|
|
4014
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4015
|
+
enumerable: true,
|
|
4016
|
+
get: function () { return _seedcord_event_emitter[k]; }
|
|
4017
|
+
});
|
|
4018
|
+
});
|
|
4019
|
+
|
|
4009
4020
|
Object.keys(_seedcord_rate_limiter).forEach(function (k) {
|
|
4010
4021
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
4011
4022
|
enumerable: true,
|