seyfert 2.2.1-dev-13493266703.0 → 2.2.1-dev-13573766445.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/builders/types.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Button } from './Button';
|
|
|
3
3
|
import type { TextInput } from './Modal';
|
|
4
4
|
import type { BuilderSelectMenus } from './SelectMenu';
|
|
5
5
|
export type ComponentCallback<T extends ComponentInteraction | StringSelectMenuInteraction = ComponentInteraction | StringSelectMenuInteraction> = (interaction: T, stop: ComponentStopCallback, refresh: ComponentRefreshCallback) => any;
|
|
6
|
+
export type ComponentOnErrorCallback<T extends ComponentInteraction | StringSelectMenuInteraction = ComponentInteraction | StringSelectMenuInteraction> = (interaction: T, error: unknown, stop: ComponentStopCallback, refresh: ComponentRefreshCallback) => any;
|
|
6
7
|
export type ComponentFilterCallback<T = ComponentInteraction> = (interaction: T) => any;
|
|
7
8
|
export type ComponentStopCallback = (reason: 'messageDelete' | 'channelDelete' | 'guildDelete' | 'idle' | 'timeout' | (string & {}) | undefined, refresh: ComponentRefreshCallback) => any;
|
|
8
9
|
export type ComponentRefreshCallback = () => any;
|
|
@@ -19,4 +20,5 @@ export interface ListenerOptions {
|
|
|
19
20
|
filter?: ComponentFilterCallback;
|
|
20
21
|
onPass?: ComponentFilterCallback;
|
|
21
22
|
onStop?: ComponentStopCallback;
|
|
23
|
+
onError?: ComponentOnErrorCallback;
|
|
22
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ComponentCallback, ListenerOptions, ModalSubmitCallback } from '../builders/types';
|
|
1
|
+
import type { ComponentCallback, ComponentOnErrorCallback, ListenerOptions, ModalSubmitCallback } from '../builders/types';
|
|
2
2
|
import { LimitedCollection } from '../collection';
|
|
3
3
|
import { type UsingClient } from '../commands';
|
|
4
4
|
import type { FileLoaded } from '../commands/handler';
|
|
@@ -20,6 +20,7 @@ type COMPONENTS = {
|
|
|
20
20
|
guildId: string | undefined;
|
|
21
21
|
idle?: NodeJS.Timeout;
|
|
22
22
|
timeout?: NodeJS.Timeout;
|
|
23
|
+
onError?: ComponentOnErrorCallback;
|
|
23
24
|
__run: (customId: UserMatches, callback: ComponentCallback) => any;
|
|
24
25
|
};
|
|
25
26
|
export type MatchCallback = (str: string) => boolean;
|
|
@@ -60,6 +60,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
+
onError: options.onError,
|
|
63
64
|
});
|
|
64
65
|
return {
|
|
65
66
|
//@ts-expect-error generic
|
|
@@ -84,14 +85,31 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
84
85
|
return row.options.onPass?.(interaction);
|
|
85
86
|
}
|
|
86
87
|
row.idle?.refresh();
|
|
87
|
-
|
|
88
|
+
const stop = reason => {
|
|
88
89
|
this.clearValue(id);
|
|
89
90
|
row.options?.onStop?.(reason ?? 'stop', () => {
|
|
90
91
|
this.createComponentCollector(row.messageId, row.channelId, row.guildId, row.options, row.components);
|
|
91
92
|
});
|
|
92
|
-
}
|
|
93
|
+
};
|
|
94
|
+
const refresh = () => {
|
|
93
95
|
this.resetTimeouts(id);
|
|
94
|
-
}
|
|
96
|
+
};
|
|
97
|
+
try {
|
|
98
|
+
await component.callback(interaction, stop, refresh);
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
try {
|
|
102
|
+
if (row.onError) {
|
|
103
|
+
await row.onError(interaction, err, stop, refresh);
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
this.client.logger.error('<Client>.components.onComponent', err);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
this.client.logger.error('<Client>.components.onComponent', err);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
95
113
|
}
|
|
96
114
|
hasComponent(id, customId) {
|
|
97
115
|
return this.values.get(id)?.components?.some(x => x.match(customId));
|
package/lib/deps/mixer.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @param args The classes to mix.
|
|
4
|
-
* @returns The mixed class.
|
|
5
|
-
*/
|
|
6
|
-
export declare function Mixin<T, C extends TypeClass[]>(...args: C): C[number] & T;
|
|
1
|
+
export declare function copyProperties(target: InstanceType<TypeClass>, source: TypeClass): void;
|
|
2
|
+
export declare function Mixin<T, C extends TypeClass[]>(...mixins: C): C[number] & T;
|
|
7
3
|
export type TypeClass<InstanceType = object, StaticType = object> = (abstract new (...args: any[]) => InstanceType) & StaticType;
|
|
8
4
|
export declare const mix: (...ingredients: TypeClass[]) => (decoratedClass: any) => any;
|
package/lib/deps/mixer.js
CHANGED
|
@@ -1,76 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mix = void 0;
|
|
4
|
+
exports.copyProperties = copyProperties;
|
|
4
5
|
exports.Mixin = Mixin;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return protos.map(x => Object.getOwnPropertyDescriptors(x));
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Gets the descriptors of a class.
|
|
21
|
-
* @param c The class to get the descriptors of.
|
|
22
|
-
* @returns The descriptors of the class.
|
|
23
|
-
*/
|
|
24
|
-
function getNodeDescriptors(c) {
|
|
25
|
-
let proto = c.prototype;
|
|
26
|
-
const result = [];
|
|
27
|
-
while (proto) {
|
|
28
|
-
const descriptors = Object.getOwnPropertyDescriptors(proto);
|
|
29
|
-
// @ts-expect-error this is not a function in all cases
|
|
30
|
-
if (descriptors.valueOf.configurable)
|
|
31
|
-
break;
|
|
32
|
-
result.push(descriptors);
|
|
33
|
-
proto = Object.getPrototypeOf(proto);
|
|
6
|
+
const IgnoredProps = ['constructor', 'prototype', 'name'];
|
|
7
|
+
function copyProperties(target, source) {
|
|
8
|
+
const keys = Reflect.ownKeys(source);
|
|
9
|
+
for (const key of keys) {
|
|
10
|
+
if (IgnoredProps.includes(key))
|
|
11
|
+
continue;
|
|
12
|
+
if (key in target)
|
|
13
|
+
continue;
|
|
14
|
+
const descriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
15
|
+
if (descriptor) {
|
|
16
|
+
Object.defineProperty(target, key, descriptor);
|
|
17
|
+
}
|
|
34
18
|
}
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
function getDescriptors(c) {
|
|
38
|
-
//@ts-expect-error
|
|
39
|
-
// biome-ignore lint/correctness/noUndeclaredVariables: <explanation>
|
|
40
|
-
return typeof Deno === 'undefined' ? getNodeDescriptors(c) : getDenoDescriptors(c);
|
|
41
19
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
* @param args The classes to mix.
|
|
45
|
-
* @returns The mixed class.
|
|
46
|
-
*/
|
|
47
|
-
function Mixin(...args) {
|
|
48
|
-
const Base = args[0];
|
|
20
|
+
function Mixin(...mixins) {
|
|
21
|
+
const Base = mixins[0];
|
|
49
22
|
class MixedClass extends Base {
|
|
50
|
-
constructor(...
|
|
51
|
-
super(...
|
|
52
|
-
for (const mixin of
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (key in MixedClass.prototype)
|
|
61
|
-
continue;
|
|
62
|
-
const descriptor = desc[key];
|
|
63
|
-
if (descriptor.value) {
|
|
64
|
-
// @ts-expect-error
|
|
65
|
-
MixedClass.prototype[key] = descriptor.value;
|
|
66
|
-
}
|
|
67
|
-
else if (descriptor.get || descriptor.set) {
|
|
68
|
-
Object.defineProperty(MixedClass.prototype, key, {
|
|
69
|
-
get: descriptor.get,
|
|
70
|
-
set: descriptor.set,
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
23
|
+
constructor(...args) {
|
|
24
|
+
super(...args);
|
|
25
|
+
for (const mixin of mixins.slice(1)) {
|
|
26
|
+
// @ts-expect-error
|
|
27
|
+
const mixinInstance = new mixin(...args);
|
|
28
|
+
copyProperties(this, mixinInstance);
|
|
29
|
+
let proto = Object.getPrototypeOf(mixinInstance);
|
|
30
|
+
while (proto && proto !== Object.prototype) {
|
|
31
|
+
copyProperties(this, proto);
|
|
32
|
+
proto = Object.getPrototypeOf(proto);
|
|
74
33
|
}
|
|
75
34
|
}
|
|
76
35
|
}
|