seyfert 2.1.1-dev-11415196258.0 → 2.1.1-dev-11431445625.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 +1 -1
- package/lib/client/client.js +4 -2
- package/lib/client/workerclient.js +7 -3
- package/lib/components/componentcontext.d.ts +4 -0
- package/lib/components/componentcontext.js +6 -0
- package/lib/components/handler.d.ts +7 -4
- package/lib/components/handler.js +10 -15
- package/package.json +1 -1
package/lib/builders/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ 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
6
|
export type ComponentFilterCallback<T = ComponentInteraction> = (interaction: T) => any;
|
|
7
|
-
export type ComponentStopCallback = (reason: 'messageDelete' | 'channelDelete' | 'guildDelete' | (string & {}) | undefined, refresh: ComponentRefreshCallback) => any;
|
|
7
|
+
export type ComponentStopCallback = (reason: 'messageDelete' | 'channelDelete' | 'guildDelete' | 'idle' | 'timeout' | (string & {}) | undefined, refresh: ComponentRefreshCallback) => any;
|
|
8
8
|
export type ComponentRefreshCallback = () => any;
|
|
9
9
|
export type ModalSubmitCallback<T = ModalSubmitInteraction> = (interaction: T) => any;
|
|
10
10
|
export type ButtonLink = Omit<Button, 'setCustomId'>;
|
package/lib/client/client.js
CHANGED
|
@@ -159,11 +159,13 @@ class Client extends base_1.BaseClient {
|
|
|
159
159
|
break;
|
|
160
160
|
case 'READY': {
|
|
161
161
|
const ids = packet.d.guilds.map(x => x.id);
|
|
162
|
-
|
|
162
|
+
if ((0, common_1.hasIntent)(this.gateway.options.intents, 'Guilds')) {
|
|
163
|
+
this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids;
|
|
164
|
+
}
|
|
163
165
|
this.botId = packet.d.user.id;
|
|
164
166
|
this.applicationId = packet.d.application.id;
|
|
165
167
|
this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
|
|
166
|
-
if (!this.__handleGuilds
|
|
168
|
+
if (!this.__handleGuilds?.length) {
|
|
167
169
|
if ([...this.gateway.values()].every(shard => shard.data.session_id)) {
|
|
168
170
|
await this.events?.runEvent('BOT_READY', this, this.me, -1);
|
|
169
171
|
}
|
|
@@ -227,8 +227,10 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
227
227
|
return;
|
|
228
228
|
shardsConnected++;
|
|
229
229
|
const ids = payload.d.guilds.map(x => x.id);
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
if ((0, common_1.hasIntent)(workerData.intents, 'Guilds')) {
|
|
231
|
+
self.__handleGuildsResharding = self.__handleGuildsResharding?.concat(ids) ?? ids;
|
|
232
|
+
}
|
|
233
|
+
if (shardsConnected === workerData.shards.length && !self.__handleGuildsResharding?.length) {
|
|
232
234
|
delete self.__handleGuildsResharding;
|
|
233
235
|
self.postMessage({
|
|
234
236
|
type: 'WORKER_READY_RESHARDING',
|
|
@@ -486,7 +488,9 @@ class WorkerClient extends base_1.BaseClient {
|
|
|
486
488
|
case 'READY':
|
|
487
489
|
{
|
|
488
490
|
const ids = packet.d.guilds.map(x => x.id);
|
|
489
|
-
|
|
491
|
+
if ((0, common_1.hasIntent)(this.workerData.intents, 'Guilds')) {
|
|
492
|
+
this.__handleGuilds = this.__handleGuilds?.concat(ids) ?? ids;
|
|
493
|
+
}
|
|
490
494
|
this.botId = packet.d.user.id;
|
|
491
495
|
this.applicationId = packet.d.application.id;
|
|
492
496
|
this.me = transformers_1.Transformers.ClientUser(this, packet.d.user, packet.d.application);
|
|
@@ -42,6 +42,10 @@ export declare class ComponentContext<Type extends keyof ContextComponentCommand
|
|
|
42
42
|
* @param ephemeral - Whether the reply should be ephemeral or not.
|
|
43
43
|
*/
|
|
44
44
|
deferReply(ephemeral?: boolean): Promise<undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* ACK an interaction and edit the original message later; the user does not see a loading state
|
|
47
|
+
*/
|
|
48
|
+
deferUpdate(): Promise<undefined>;
|
|
45
49
|
/**
|
|
46
50
|
* Edits the response of the interaction.
|
|
47
51
|
* @param body - The updated body of the response.
|
|
@@ -50,6 +50,12 @@ class ComponentContext extends basecontext_1.BaseContext {
|
|
|
50
50
|
deferReply(ephemeral = false) {
|
|
51
51
|
return this.interaction.deferReply(ephemeral ? types_1.MessageFlags.Ephemeral : undefined);
|
|
52
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* ACK an interaction and edit the original message later; the user does not see a loading state
|
|
55
|
+
*/
|
|
56
|
+
deferUpdate() {
|
|
57
|
+
return this.interaction.deferUpdate();
|
|
58
|
+
}
|
|
53
59
|
/**
|
|
54
60
|
* Edits the response of the interaction.
|
|
55
61
|
* @param body - The updated body of the response.
|
|
@@ -8,9 +8,10 @@ import { ComponentCommand } from './componentcommand';
|
|
|
8
8
|
import type { ComponentContext } from './componentcontext';
|
|
9
9
|
import { ModalCommand } from './modalcommand';
|
|
10
10
|
import type { ModalContext } from './modalcontext';
|
|
11
|
+
type UserMatches = string | string[] | RegExp;
|
|
11
12
|
type COMPONENTS = {
|
|
12
13
|
components: {
|
|
13
|
-
match:
|
|
14
|
+
match: MatchCallback;
|
|
14
15
|
callback: ComponentCallback;
|
|
15
16
|
}[];
|
|
16
17
|
options?: ListenerOptions;
|
|
@@ -19,12 +20,13 @@ type COMPONENTS = {
|
|
|
19
20
|
guildId: string | undefined;
|
|
20
21
|
idle?: NodeJS.Timeout;
|
|
21
22
|
timeout?: NodeJS.Timeout;
|
|
22
|
-
__run: (customId:
|
|
23
|
+
__run: (customId: UserMatches, callback: ComponentCallback) => any;
|
|
23
24
|
};
|
|
25
|
+
export type MatchCallback = (str: string) => boolean;
|
|
24
26
|
export type CollectorInteraction = ComponentInteraction | StringSelectMenuInteraction;
|
|
25
27
|
export type ComponentCommands = ComponentCommand | ModalCommand;
|
|
26
28
|
export interface CreateComponentCollectorResult {
|
|
27
|
-
run<T extends CollectorInteraction = CollectorInteraction>(customId:
|
|
29
|
+
run<T extends CollectorInteraction = CollectorInteraction>(customId: UserMatches, callback: ComponentCallback<T>): any;
|
|
28
30
|
stop(reason?: string): any;
|
|
29
31
|
}
|
|
30
32
|
export declare class ComponentHandler extends BaseHandler {
|
|
@@ -35,9 +37,10 @@ export declare class ComponentHandler extends BaseHandler {
|
|
|
35
37
|
readonly commands: ComponentCommands[];
|
|
36
38
|
filter: (path: string) => boolean;
|
|
37
39
|
constructor(logger: Logger, client: UsingClient);
|
|
40
|
+
private createMatchCallback;
|
|
38
41
|
createComponentCollector(messageId: string, channelId: string, guildId: string | undefined, options?: ListenerOptions): CreateComponentCollectorResult;
|
|
39
42
|
onComponent(id: string, interaction: ComponentInteraction): Promise<any>;
|
|
40
|
-
hasComponent(id: string, customId: string): boolean;
|
|
43
|
+
hasComponent(id: string, customId: string): boolean | undefined;
|
|
41
44
|
resetTimeouts(id: string): void;
|
|
42
45
|
hasModal(interaction: ModalSubmitInteraction): boolean;
|
|
43
46
|
onModalSubmit(interaction: ModalSubmitInteraction): any;
|
|
@@ -18,6 +18,13 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
18
18
|
super(logger);
|
|
19
19
|
this.client = client;
|
|
20
20
|
}
|
|
21
|
+
createMatchCallback(match) {
|
|
22
|
+
if (typeof match === 'string')
|
|
23
|
+
return str => str === match;
|
|
24
|
+
if (Array.isArray(match))
|
|
25
|
+
return str => match.includes(str);
|
|
26
|
+
return str => match.test(str);
|
|
27
|
+
}
|
|
21
28
|
createComponentCollector(messageId, channelId, guildId, options = {}) {
|
|
22
29
|
this.values.set(messageId, {
|
|
23
30
|
messageId,
|
|
@@ -45,7 +52,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
45
52
|
if (this.values.has(messageId)) {
|
|
46
53
|
this.values.get(messageId).components.push({
|
|
47
54
|
callback,
|
|
48
|
-
match: customId,
|
|
55
|
+
match: this.createMatchCallback(customId),
|
|
49
56
|
});
|
|
50
57
|
}
|
|
51
58
|
},
|
|
@@ -63,13 +70,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
63
70
|
}
|
|
64
71
|
async onComponent(id, interaction) {
|
|
65
72
|
const row = this.values.get(id);
|
|
66
|
-
const component = row?.components?.find(x =>
|
|
67
|
-
if (typeof x.match === 'string')
|
|
68
|
-
return x.match === interaction.customId;
|
|
69
|
-
if (Array.isArray(x.match))
|
|
70
|
-
return x.match.includes(interaction.customId);
|
|
71
|
-
return interaction.customId.match(x.match);
|
|
72
|
-
});
|
|
73
|
+
const component = row?.components?.find(x => x.match(interaction.customId));
|
|
73
74
|
if (!component)
|
|
74
75
|
return;
|
|
75
76
|
if (row.options?.filter) {
|
|
@@ -87,13 +88,7 @@ class ComponentHandler extends common_1.BaseHandler {
|
|
|
87
88
|
});
|
|
88
89
|
}
|
|
89
90
|
hasComponent(id, customId) {
|
|
90
|
-
return
|
|
91
|
-
if (typeof x.match === 'string')
|
|
92
|
-
return x.match === customId;
|
|
93
|
-
if (Array.isArray(x.match))
|
|
94
|
-
return x.match.includes(customId);
|
|
95
|
-
return customId.match(x.match);
|
|
96
|
-
}) ?? false);
|
|
91
|
+
return this.values.get(id)?.components?.some(x => x.match(customId));
|
|
97
92
|
}
|
|
98
93
|
resetTimeouts(id) {
|
|
99
94
|
const listener = this.values.get(id);
|