seyfert 2.2.1-dev-13340711253.0 → 2.2.1-dev-13380910405.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/common/it/utils.js +1 -11
- package/lib/components/componentcommand.d.ts +2 -1
- package/lib/components/componentcommand.js +8 -0
- package/lib/components/handler.js +2 -2
- package/lib/components/modalcommand.d.ts +2 -1
- package/lib/components/modalcommand.js +8 -0
- package/lib/langs/handler.d.ts +1 -4
- package/lib/langs/handler.js +11 -3
- package/package.json +1 -1
package/lib/common/it/utils.js
CHANGED
|
@@ -261,17 +261,7 @@ exports.ReplaceRegex = {
|
|
|
261
261
|
},
|
|
262
262
|
};
|
|
263
263
|
async function magicImport(path) {
|
|
264
|
-
|
|
265
|
-
if ('Deno' in globalThis)
|
|
266
|
-
throw new Error('https://github.com/denoland/deno/issues/26136');
|
|
267
|
-
return require(path);
|
|
268
|
-
}
|
|
269
|
-
catch (e) {
|
|
270
|
-
// (bun)dows moment
|
|
271
|
-
if (!('Bun' in globalThis) || e.message.includes('is unsupported. use "await import()" instead.'))
|
|
272
|
-
return new Function('path', 'return import(`file:///${path}?update=${Date.now()}`)')(path.split('\\').join('\\\\'));
|
|
273
|
-
throw new Error(`Cannot import ${path}`, { cause: e });
|
|
274
|
-
}
|
|
264
|
+
return new Function('path', 'return import(`file:///${path}?update=${Date.now()}`)')(path);
|
|
275
265
|
}
|
|
276
266
|
function fakePromise(value) {
|
|
277
267
|
if (value instanceof Promise)
|
|
@@ -10,7 +10,8 @@ export interface ComponentCommand {
|
|
|
10
10
|
export declare abstract class ComponentCommand {
|
|
11
11
|
type: 0;
|
|
12
12
|
abstract componentType: keyof ContextComponentCommandInteractionMap;
|
|
13
|
-
|
|
13
|
+
customId?: string;
|
|
14
|
+
filter?(context: ComponentContext<typeof this.componentType>): Promise<boolean> | boolean;
|
|
14
15
|
abstract run(context: ComponentContext<typeof this.componentType>): any;
|
|
15
16
|
middlewares: (keyof RegisteredMiddlewares)[];
|
|
16
17
|
props: ExtraProps;
|
|
@@ -8,6 +8,14 @@ exports.InteractionCommandType = {
|
|
|
8
8
|
};
|
|
9
9
|
class ComponentCommand {
|
|
10
10
|
type = exports.InteractionCommandType.COMPONENT;
|
|
11
|
+
customId;
|
|
12
|
+
/** @internal */
|
|
13
|
+
async _filter(context) {
|
|
14
|
+
const old = (await this.filter?.(context)) ?? true;
|
|
15
|
+
if (this.customId)
|
|
16
|
+
return this.customId === context.customId && old;
|
|
17
|
+
return old;
|
|
18
|
+
}
|
|
11
19
|
middlewares = [];
|
|
12
20
|
props;
|
|
13
21
|
get cType() {
|
|
@@ -257,7 +257,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
257
257
|
try {
|
|
258
258
|
if (i.type === componentcommand_1.InteractionCommandType.COMPONENT &&
|
|
259
259
|
i.cType === context.interaction.componentType &&
|
|
260
|
-
(await i.
|
|
260
|
+
(await i._filter(context))) {
|
|
261
261
|
context.command = i;
|
|
262
262
|
await this.execute(i, context);
|
|
263
263
|
}
|
|
@@ -270,7 +270,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
270
270
|
async executeModal(context) {
|
|
271
271
|
for (const i of this.commands) {
|
|
272
272
|
try {
|
|
273
|
-
if (i.type === componentcommand_1.InteractionCommandType.MODAL && (await i.
|
|
273
|
+
if (i.type === componentcommand_1.InteractionCommandType.MODAL && (await i._filter(context))) {
|
|
274
274
|
context.command = i;
|
|
275
275
|
await this.execute(i, context);
|
|
276
276
|
}
|
|
@@ -5,7 +5,8 @@ export interface ModalCommand {
|
|
|
5
5
|
}
|
|
6
6
|
export declare abstract class ModalCommand {
|
|
7
7
|
type: 1;
|
|
8
|
-
|
|
8
|
+
filter?(context: ModalContext): Promise<boolean> | boolean;
|
|
9
|
+
customId?: string;
|
|
9
10
|
abstract run(context: ModalContext): any;
|
|
10
11
|
middlewares: (keyof RegisteredMiddlewares)[];
|
|
11
12
|
props: ExtraProps;
|
|
@@ -4,6 +4,14 @@ exports.ModalCommand = void 0;
|
|
|
4
4
|
const componentcommand_1 = require("./componentcommand");
|
|
5
5
|
class ModalCommand {
|
|
6
6
|
type = componentcommand_1.InteractionCommandType.MODAL;
|
|
7
|
+
customId;
|
|
8
|
+
/** @internal */
|
|
9
|
+
async _filter(context) {
|
|
10
|
+
const old = (await this.filter?.(context)) ?? true;
|
|
11
|
+
if (this.customId)
|
|
12
|
+
return this.customId === context.customId && old;
|
|
13
|
+
return old;
|
|
14
|
+
}
|
|
7
15
|
middlewares = [];
|
|
8
16
|
props;
|
|
9
17
|
}
|
package/lib/langs/handler.d.ts
CHANGED
|
@@ -15,10 +15,7 @@ export declare class LangsHandler extends BaseHandler {
|
|
|
15
15
|
load(dir: string): Promise<void>;
|
|
16
16
|
parse(file: LangInstance): void;
|
|
17
17
|
set(instances: LangInstance[]): void;
|
|
18
|
-
reload(lang: string): Promise<
|
|
19
|
-
file: Record<string, any>;
|
|
20
|
-
locale: string;
|
|
21
|
-
} | null>;
|
|
18
|
+
reload(lang: string): Promise<Record<string, any> | null>;
|
|
22
19
|
reloadAll(stopIfFail?: boolean): Promise<void>;
|
|
23
20
|
onFile(locale: string, { file }: LangInstance): {
|
|
24
21
|
file: Record<string, any>;
|
package/lib/langs/handler.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LangsHandler = void 0;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
4
5
|
const common_1 = require("../common");
|
|
5
6
|
const router_1 = require("./router");
|
|
6
7
|
class LangsHandler extends common_1.BaseHandler {
|
|
@@ -55,11 +56,18 @@ class LangsHandler extends common_1.BaseHandler {
|
|
|
55
56
|
if ((0, common_1.isCloudfareWorker)()) {
|
|
56
57
|
throw new Error('Reload in cloudfare worker is not supported');
|
|
57
58
|
}
|
|
58
|
-
const
|
|
59
|
+
const path = this.__paths[lang];
|
|
60
|
+
if (!path)
|
|
61
|
+
return null;
|
|
62
|
+
delete require.cache[path];
|
|
63
|
+
const value = await (0, common_1.magicImport)(path).then(x => this.onFile(lang, {
|
|
64
|
+
file: x,
|
|
65
|
+
name: (0, node_path_1.basename)(path),
|
|
66
|
+
path,
|
|
67
|
+
}));
|
|
59
68
|
if (!value)
|
|
60
69
|
return null;
|
|
61
|
-
|
|
62
|
-
return (this.values[lang] = await (0, common_1.magicImport)(value).then(x => this.onFile(lang, x)));
|
|
70
|
+
return (this.values[lang] = value.file);
|
|
63
71
|
}
|
|
64
72
|
async reloadAll(stopIfFail = true) {
|
|
65
73
|
for (const i in this.__paths) {
|