fixed loads of typing errors
diff --git a/src/commands/settings/automod.ts b/src/commands/settings/automod.ts
index 8e006b0..ab5e037 100644
--- a/src/commands/settings/automod.ts
+++ b/src/commands/settings/automod.ts
@@ -48,28 +48,30 @@
const toSelectMenu = async (interaction: StringSelectMenuInteraction, m: Message, ids: string[], type: "member" | "role" | "channel", title: string): Promise<string[]> => {
const back = new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setCustomId("back").setLabel("Back").setStyle(ButtonStyle.Secondary).setEmoji(getEmojiByName("CONTROL.LEFT", "id") as APIMessageComponentEmoji));
-
let closed;
do {
let render: string[] = []
let mapped: string[] = [];
let menu: UserSelectMenuBuilder | RoleSelectMenuBuilder | ChannelSelectMenuBuilder;
switch(type) {
- case "member":
+ case "member": {
menu = new UserSelectMenuBuilder().setCustomId("user").setPlaceholder("Select users").setMaxValues(25);
mapped = await Promise.all(ids.map(async (id) => { return (await client.users.fetch(id).then(user => user.tag)) || "Unknown User" }));
render = ids.map(id => client.logger.renderUser(id))
break;
- case "role":
+ }
+ case "role": {
menu = new RoleSelectMenuBuilder().setCustomId("role").setPlaceholder("Select roles").setMaxValues(25);
- mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.roles.fetch(id).then(role => role?.name)) || "Unknown Role" }));
+ mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.roles.fetch(id).then(role => role?.name ?? "Unknown Role"))}));
render = ids.map(id => client.logger.renderRole(id, interaction.guild!))
break;
- case "channel":
+ }
+ case "channel": {
menu = new ChannelSelectMenuBuilder().setCustomId("channel").setPlaceholder("Select channels").setMaxValues(25);
- mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.channels.fetch(id).then(channel => channel?.name)) || "Unknown Channel" }));
+ mapped = await Promise.all(ids.map(async (id) => { return (await interaction.guild!.channels.fetch(id).then(channel => channel?.name ?? "Unknown Role")) }));
render = ids.map(id => client.logger.renderChannel(id))
break;
+ }
}
const removeOptions = new ActionRowBuilder<StringSelectMenuBuilder>()
.addComponents(
@@ -85,7 +87,7 @@
.setEmoji(getEmojiByName("GUILD.SETTINGS.GREEN"))
.setDescription(`Select ${type}s:\n\nCurrent:\n` + (render.length > 0 ? render.join("\n") : "None"))
.setStatus("Success");
- let components: ActionRowBuilder<
+ const components: ActionRowBuilder<
StringSelectMenuBuilder |
ButtonBuilder |
ChannelSelectMenuBuilder |
@@ -102,7 +104,7 @@
i = await m.awaitMessageComponent({filter: i => i.user.id === interaction.user.id, time: 300000});
} catch(e) {
closed = true;
- break;
+ continue;
}
if(i.isButton()) {
@@ -176,15 +178,18 @@
}
await i.deferUpdate();
switch(i.customId) {
- case "back":
+ case "back": {
closed = true;
break;
- case "nsfw":
+ }
+ case "nsfw": {
current.NSFW = !current.NSFW;
break;
- case "size":
+ }
+ case "size": {
current.size = !current.size;
break;
+ }
}
} while(!closed);
return current;
@@ -267,16 +272,18 @@
if(i.isButton()) {
await i.deferUpdate();
switch(i.customId) {
- case "back":
+ case "back": {
closed = true;
break;
- case "enabled":
+ }
+ case "enabled": {
current.enabled = !current.enabled;
break;
+ }
}
} else {
switch(i.values[0]) {
- case "words":
+ case "words": {
await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Word Filter")
.setDescription("Modal opened. If you can't see it, click back and try again.")
@@ -298,7 +305,7 @@
.setCustomId("wordStrict")
.setLabel("Strict Words")
.setPlaceholder("Matches anywhere in the message, including surrounded by other characters")
- .setValue(current.words.strict.join(", ") ?? "")
+ .setValue(current.words.strict.join(", "))
.setStyle(TextInputStyle.Paragraph)
.setRequired(false)
),
@@ -308,7 +315,7 @@
.setCustomId("wordLoose")
.setLabel("Loose Words")
.setPlaceholder("Matches only if the word is by itself, surrounded by spaces or punctuation")
- .setValue(current.words.loose.join(", ") ?? "")
+ .setValue(current.words.loose.join(", "))
.setStyle(TextInputStyle.Paragraph)
.setRequired(false)
)
@@ -333,18 +340,22 @@
current.words.loose = out.fields.getTextInputValue("wordLoose")
.split(",").map(s => s.trim()).filter(s => s.length > 0);
break;
- case "allowedUsers":
+ }
+ case "allowedUsers": {
await i.deferUpdate();
current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Word Filter");
break;
- case "allowedRoles":
+ }
+ case "allowedRoles": {
await i.deferUpdate();
current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Word Filter");
break;
- case "allowedChannels":
+ }
+ case "allowedChannels": {
await i.deferUpdate();
current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Word Filter");
break;
+ }
}
}
} while(!closed);
@@ -420,25 +431,30 @@
if(i.isButton()) {
await i.deferUpdate();
switch(i.customId) {
- case "back":
+ case "back": {
closed = true;
break;
- case "enabled":
+ }
+ case "enabled": {
current.enabled = !current.enabled;
break;
+ }
}
} else {
await i.deferUpdate();
switch(i.values[0]) {
- case "users":
+ case "users": {
current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Invite Settings");
break;
- case "roles":
+ }
+ case "roles": {
current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Invite Settings");
break;
- case "channels":
+ }
+ case "channels": {
current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Invite Settings");
break;
+ }
}
}
@@ -557,21 +573,24 @@
if(i.isButton()) {
await i.deferUpdate();
switch (i.customId) {
- case "back":
+ case "back": {
closed = true;
break;
- case "everyone":
+ }
+ case "everyone": {
current.everyone = !current.everyone;
break;
- case "roles":
+ }
+ case "roles": {
current.roles = !current.roles;
break;
+ }
}
} else {
switch (i.customId) {
- case "toEdit":
+ case "toEdit": {
switch (i.values[0]) {
- case "mass":
+ case "mass": {
await interaction.editReply({embeds: [new EmojiEmbed()
.setTitle("Word Filter")
.setDescription("Modal opened. If you can't see it, click back and try again.")
@@ -613,26 +632,33 @@
if(out.isButton()) break;
current.mass = parseInt(out.fields.getTextInputValue("mass"));
break;
- case "roles":
+ }
+ case "roles": {
await i.deferUpdate();
current.allowed.rolesToMention = await toSelectMenu(interaction, m, current.allowed.rolesToMention, "role", "Mention Settings");
break;
+ }
}
break;
- case "allowed":
+ }
+ case "allowed": {
await i.deferUpdate();
switch (i.values[0]) {
- case "users":
+ case "users": {
current.allowed.users = await toSelectMenu(interaction, m, current.allowed.users, "member", "Mention Settings");
break;
- case "roles":
+ }
+ case "roles": {
current.allowed.roles = await toSelectMenu(interaction, m, current.allowed.roles, "role", "Mention Settings");
break;
- case "channels":
+ }
+ case "channels": {
current.allowed.channels = await toSelectMenu(interaction, m, current.allowed.channels, "channel", "Mention Settings");
break;
+ }
}
break;
+ }
}
}
@@ -706,34 +732,38 @@
i = await m.awaitMessageComponent({filter: (i) => i.user.id === interaction.user.id && i.message.id === m.id, time: 300000}) as StringSelectMenuInteraction | ButtonInteraction;
} catch (e) {
closed = true;
- return;
+ continue;
}
- if(!i) return;
if(i.isButton()) {
await i.deferUpdate();
await client.database.guilds.write(interaction.guild.id, {filters: config});
} else {
switch(i.values[0]) {
- case "invites":
+ case "invites": {
await i.deferUpdate();
config.invite = await inviteMenu(i, m, config.invite);
break;
- case "mentions":
+ }
+ case "mentions": {
await i.deferUpdate();
config.pings = await mentionMenu(i, m, config.pings);
break;
- case "words":
+ }
+ case "words": {
await i.deferUpdate();
config.wordFilter = await wordMenu(i, m, config.wordFilter);
break;
- case "malware":
+ }
+ case "malware": {
await i.deferUpdate();
config.malware = !config.malware;
break;
- case "images":
- let next = await imageMenu(i, m, config.images);
- if(next) config.images = next;
+ }
+ case "images": {
+ const next = await imageMenu(i, m, config.images);
+ config.images = next;
break;
+ }
}
}