Add a codeowners file
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 0000000..41f9571
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1,9 @@
+package.json @Minion3665
+tsconfig.json @Minion3665
+.prettierrc.json @Minion3665
+.prettierignore @Minion3665
+.eslintrc.json @Minion3665
+.eslintignore @Minion3665
+.editorconfig @Minion3665
+.github/ @Minion3665
+
diff --git a/src/utils/confirmationMessage.ts b/src/utils/confirmationMessage.ts
index a8c7ab4..58ab9d4 100644
--- a/src/utils/confirmationMessage.ts
+++ b/src/utils/confirmationMessage.ts
@@ -86,7 +86,12 @@
components?: Record<string, CustomBoolean<unknown>>;
newReason?: string;
}> {
- while (true) {
+ let cancelled = false;
+ let success: boolean | undefined = undefined;
+ let returnComponents = false;
+ let newReason = undefined;
+
+ while (!cancelled && success === undefined && !returnComponents && !newReason) {
const fullComponents = [
new Discord.MessageButton()
.setCustomId("yes")
@@ -150,7 +155,8 @@
m = (await this.interaction.reply(object)) as unknown as Message;
}
} catch {
- return { cancelled: true };
+ cancelled = true;
+ continue;
}
let component;
try {
@@ -159,7 +165,9 @@
time: 300000
});
} catch (e) {
- return { success: false, components: this.customButtons };
+ success = false;
+ returnComponents = true;
+ continue;
}
if (component.customId === "yes") {
component.deferUpdate();
@@ -171,10 +179,14 @@
console.log(e);
}
}
- return { success: true, components: this.customButtons };
+ success = true;
+ returnComponents = true;
+ continue;
} else if (component.customId === "no") {
component.deferUpdate();
- return { success: false, components: this.customButtons };
+ success = false;
+ returnComponents = true;
+ continue;
} else if (component.customId === "reason") {
await component.showModal(
new Discord.Modal()
@@ -221,24 +233,35 @@
(m) => m.customId === "reason"
);
} catch (e) {
- return { cancelled: true };
+ cancelled = true;
+ continue;
}
if (out === null) {
- return { cancelled: true };
+ cancelled = true;
+ continue;
}
if (out instanceof ModalSubmitInteraction) {
- return {
- newReason: out.fields.getTextInputValue("reason")
- };
+ newReason = out.fields.getTextInputValue("reason");
+ continue;
} else {
- return { components: this.customButtons };
+ returnComponents = true;
+ continue;
}
} else {
component.deferUpdate();
this.customButtons[component.customId]!.active = !this.customButtons[component.customId]!.active;
- return { components: this.customButtons };
+ returnComponents = true;
+ continue;
}
}
+ const returnValue: Awaited<ReturnType<typeof this.send>> = {};
+
+ if (returnComponents) returnValue.components = this.customButtons;
+ if (success !== undefined) returnValue.success = success;
+ if (cancelled) returnValue.cancelled = true;
+ if (newReason) returnValue.newReason = newReason;
+
+ return returnValue;
}
}
diff --git a/src/utils/specialTypes.ts b/src/utils/specialTypes.ts
new file mode 100644
index 0000000..93264d6
--- /dev/null
+++ b/src/utils/specialTypes.ts
@@ -0,0 +1,4 @@
+/* eslint-disable @typescript-eslint/no-explicit-any */
+export type AsyncReturnType<T extends (...args: any[]) => Promise<any>> = T extends (...args: any[]) => Promise<infer X>
+ ? X
+ : unknown;