styling fixes and some typing
diff --git a/src/commands/settings/verify.ts b/src/commands/settings/verify.ts
index 614ecb9..0eb4553 100644
--- a/src/commands/settings/verify.ts
+++ b/src/commands/settings/verify.ts
@@ -1,13 +1,14 @@
import { LoadingEmbed } from "./../../utils/defaultEmbeds.js";
import Discord, {
CommandInteraction,
+ Interaction,
Message,
MessageActionRow,
MessageActionRowComponent,
MessageButton,
MessageComponentInteraction,
- MessageEmbed,
MessageSelectMenu,
+ ModalSubmitInteraction,
Role,
SelectMenuInteraction,
TextInputComponent
@@ -15,7 +16,7 @@
import EmojiEmbed from "../../utils/generateEmojiEmbed.js";
import confirmationMessage from "../../utils/confirmationMessage.js";
import getEmojiByName from "../../utils/getEmojiByName.js";
-import { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
import client from "../../utils/client.js";
import { modalInteractionCollector } from "../../utils/dualCollector.js";
@@ -27,7 +28,7 @@
option.setName("role").setDescription("The role to give after verifying").setRequired(false)
);
-const callback = async (interaction: CommandInteraction): Promise<void | unknown> => {
+const callback = async (interaction: CommandInteraction): Promise<unknown> => {
const m = (await interaction.reply({
embeds: LoadingEmbed,
ephemeral: true,
@@ -49,7 +50,7 @@
});
}
role = role as Discord.Role;
- if (role.guild.id !== interaction.guild.id) {
+ if (role.guild.id !== interaction.guild!.id) {
return interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -70,7 +71,7 @@
if (confirmation.cancelled) return;
if (confirmation.success) {
try {
- await client.database.guilds.write(interaction.guild.id, {
+ await client.database.guilds.write(interaction.guild!.id, {
"verify.role": role.id,
"verify.enabled": true
});
@@ -90,7 +91,7 @@
role: entry(role.id, renderRole(role))
},
hidden: {
- guild: interaction.guild.id
+ guild: interaction.guild!.id
}
};
log(data);
@@ -121,7 +122,7 @@
}
}
let clicks = 0;
- const data = await client.database.guilds.read(interaction.guild.id);
+ const data = await client.database.guilds.read(interaction.guild!.id);
let role = data.verify.role;
while (true) {
await interaction.editReply({
@@ -161,7 +162,7 @@
clicks += 1;
if (clicks === 2) {
clicks = 0;
- await client.database.guilds.write(interaction.guild.id, null, ["verify.role", "verify.enabled"]);
+ await client.database.guilds.write(interaction.guild!.id, null, ["verify.role", "verify.enabled"]);
role = undefined;
}
} else if ((i.component as MessageActionRowComponent).customId === "send") {
@@ -241,12 +242,12 @@
}
if ((i.component as MessageActionRowComponent).customId === "template") {
i.deferUpdate();
- await interaction.channel.send({
+ await interaction.channel!.send({
embeds: [
new EmojiEmbed()
- .setTitle(verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].label)
+ .setTitle(verifyMessages[parseInt((i as SelectMenuInteraction).values[0]!)]!.label)
.setDescription(
- verifyMessages[parseInt((i as SelectMenuInteraction).values[0])].description
+ verifyMessages[parseInt((i as SelectMenuInteraction).values[0]!)]!.description
)
.setStatus("Success")
.setEmoji("CONTROL.BLOCKTICK")
@@ -264,7 +265,7 @@
break;
} else if ((i.component as MessageActionRowComponent).customId === "blank") {
i.deferUpdate();
- await interaction.channel.send({
+ await interaction.channel!.send({
components: [
new MessageActionRow().addComponents([
new MessageButton()
@@ -322,16 +323,20 @@
try {
out = await modalInteractionCollector(
m,
- (m) => m.channel.id === interaction.channel.id,
+ (m: Interaction) =>
+ (m as MessageComponentInteraction | ModalSubmitInteraction).channelId ===
+ interaction.channelId,
(m) => m.customId === "modify"
);
} catch (e) {
break;
}
- if (out.fields) {
+ if (out === null) {
+ continue;
+ } else if (out instanceof ModalSubmitInteraction) {
const title = out.fields.getTextInputValue("title");
const description = out.fields.getTextInputValue("description");
- await interaction.channel.send({
+ await interaction.channel!.send({
embeds: [
new EmojiEmbed()
.setTitle(title)
@@ -369,7 +374,7 @@
const check = (interaction: CommandInteraction) => {
const member = interaction.member as Discord.GuildMember;
if (!member.permissions.has("MANAGE_GUILD"))
- throw "You must have the *Manage Server* permission to use this command";
+ throw new Error("You must have the *Manage Server* permission to use this command");
return true;
};