possibly finished current features
diff --git a/src/utils/dualCollector.ts b/src/utils/dualCollector.ts
index f55716e..072f73f 100644
--- a/src/utils/dualCollector.ts
+++ b/src/utils/dualCollector.ts
@@ -1,4 +1,4 @@
-import { ButtonInteraction, Client, Interaction, InteractionCollector, Message, MessageComponentInteraction, ModalSubmitInteraction } from "discord.js";
+import { ButtonInteraction, Client, User, Interaction, InteractionCollector, Message, MessageComponentInteraction, ModalSubmitInteraction } from "discord.js";
import client from "./client.js";
export default async function (
@@ -45,17 +45,25 @@
return out;
}
+function defaultInteractionFilter(i: MessageComponentInteraction, user: User, m: Message) {
+ return i.channel!.id === m.channel!.id && i.user.id === user.id
+}
+function defaultModalFilter(i: ModalSubmitInteraction, user: User, m: Message) {
+ return i.channel!.id === m.channel!.id && i.user.id === user.id
+}
+
+
export async function modalInteractionCollector(
- m: Message,
- modalFilter: (i: Interaction) => boolean | Promise<boolean>,
- interactionFilter: (i: MessageComponentInteraction) => boolean | Promise<boolean>
+ m: Message, user: User,
+ modalFilter?: (i: Interaction) => boolean | Promise<boolean>,
+ interactionFilter?: (i: MessageComponentInteraction) => boolean | Promise<boolean>
): Promise<null | ButtonInteraction | ModalSubmitInteraction> {
let out: ButtonInteraction | ModalSubmitInteraction;
try {
out = await new Promise((resolve, _reject) => {
const int = m
.createMessageComponentCollector({
- filter: (i: MessageComponentInteraction) => interactionFilter(i),
+ filter: (i: MessageComponentInteraction) => (interactionFilter ? interactionFilter(i) : true) && defaultInteractionFilter(i, user, m),
time: 300000
})
.on("collect", async (i: ButtonInteraction) => {
@@ -65,7 +73,7 @@
resolve(i);
});
const mod = new InteractionCollector(client as Client, {
- filter: (i: Interaction) => modalFilter(i) && i.isModalSubmit(),
+ filter: (i: Interaction) => (modalFilter ? modalFilter(i) : true) && i.isModalSubmit() && defaultModalFilter(i, user, m),
time: 300000
}).on("collect", async (i: ModalSubmitInteraction) => {
int.stop();
@@ -75,6 +83,7 @@
});
});
} catch (e) {
+ console.log(e);
return null;
}
return out;