No typescript errors
diff --git a/src/commands/settings/logs/events.ts b/src/commands/settings/logs/events.ts
index 6d823b2..fbe79fa 100644
--- a/src/commands/settings/logs/events.ts
+++ b/src/commands/settings/logs/events.ts
@@ -1,11 +1,11 @@
import { LoadingEmbed } from "../../../utils/defaults.js";
import Discord, { CommandInteraction, Message, ActionRowBuilder, ButtonBuilder, ButtonStyle, StringSelectMenuBuilder, EmbedBuilder, StringSelectMenuInteraction } from "discord.js";
-import type { SlashCommandSubcommandBuilder } from "@discordjs/builders";
+import { SlashCommandSubcommandBuilder, StringSelectMenuOptionBuilder } from "@discordjs/builders";
import EmojiEmbed from "../../../utils/generateEmojiEmbed.js";
import client from "../../../utils/client.js";
import { toHexArray, toHexInteger } from "../../../utils/calculate.js";
-const logs = {
+const logs: Record<string, string> = {
channelUpdate: "Channels created, deleted or modified",
emojiUpdate: "Server emojis modified",
stickerUpdate: "Server stickers modified",
@@ -42,6 +42,18 @@
do {
const config = await client.database.guilds.read(interaction.guild!.id);
const converted = toHexArray(config.logging.logs.toLog);
+ const selectPane = new StringSelectMenuBuilder()
+ .setPlaceholder("Set events to log")
+ .setMaxValues(Object.keys(logs).length)
+ .setCustomId("logs")
+ .setMinValues(0)
+ Object.keys(logs).map((e, i) => {
+ selectPane.addOptions(new StringSelectMenuOptionBuilder()
+ .setLabel(logs[e]!)
+ .setValue(i.toString())
+ .setDefault(converted.includes(e))
+ )
+ });
m = (await interaction.editReply({
embeds: [
new EmojiEmbed()
@@ -53,20 +65,7 @@
.setEmoji("CHANNEL.TEXT.CREATE")
],
components: [
- new ActionRowBuilder<StringSelectMenuBuilder>().addComponents([
- new StringSelectMenuBuilder()
- .setPlaceholder("Set events to log")
- .setMaxValues(Object.keys(logs).length)
- .setCustomId("logs")
- .setMinValues(0)
- .setOptions(
- Object.keys(logs).map((e, i) => ({
- label: (logs as any)[e],
- value: i.toString(),
- default: converted.includes(e)
- }))
- )
- ]),
+ new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectPane),
new ActionRowBuilder<ButtonBuilder>().addComponents([
new ButtonBuilder().setLabel("Select all").setStyle(ButtonStyle.Primary).setCustomId("all"),
new ButtonBuilder().setLabel("Select none").setStyle(ButtonStyle.Danger).setCustomId("none")
diff --git a/src/commands/settings/tickets.ts b/src/commands/settings/tickets.ts
index ff545aa..892a420 100644
--- a/src/commands/settings/tickets.ts
+++ b/src/commands/settings/tickets.ts
@@ -7,7 +7,6 @@
GuildChannel,
Message,
ActionRowBuilder,
- Component,
ButtonBuilder,
MessageComponentInteraction,
StringSelectMenuBuilder,
@@ -74,9 +73,9 @@
})) as Message;
const options = {
enabled: (interaction.options.get("enabled")?.value as string).startsWith("yes") as boolean | null,
- category: interaction.options.get("category")?.channel,
- maxtickets: interaction.options.get("maxticketsperuser")?.value as number,
- supportping: interaction.options.get("supportrole")?.role as Role
+ category: interaction.options.get("category")?.channel as Discord.CategoryChannel | null,
+ maxtickets: interaction.options.get("maxticketsperuser")?.value as number | null,
+ supportping: interaction.options.get("supportrole")?.role as Role | null
};
if (options.enabled !== null || options.category || options.maxtickets || options.supportping) {
if (options.category) {
@@ -94,7 +93,6 @@
]
});
}
- if (!channel) return;
channel = channel as Discord.CategoryChannel;
if (channel.guild.id !== interaction.guild.id)
return interaction.editReply({
@@ -202,20 +200,20 @@
});
}
}
- let data = await client.database.guilds.read(interaction.guild.id);
- data.tickets.customTypes = (data.tickets.customTypes || []).filter(
+ const data = await client.database.guilds.read(interaction.guild.id);
+ data.tickets.customTypes = (data.tickets.customTypes ?? []).filter(
(value: string, index: number, array: string[]) => array.indexOf(value) === index
);
let lastClicked = "";
- let embed: EmojiEmbed = new EmojiEmbed();
- let compiledData = {
+ const embed: EmojiEmbed = new EmojiEmbed();
+ const compiledData = {
enabled: data.tickets.enabled,
category: data.tickets.category,
maxTickets: data.tickets.maxTickets,
supportRole: data.tickets.supportRole,
useCustom: data.tickets.useCustom,
types: data.tickets.types,
- customTypes: data.tickets.customTypes
+ customTypes: data.tickets.customTypes as string[] | null
};
let timedOut = false;
while (!timedOut) {
@@ -485,29 +483,27 @@
continue;
}
out = out as ModalSubmitInteraction;
- if (out.fields) {
- const title = out.fields.getTextInputValue("title");
- const description = out.fields.getTextInputValue("description");
- await interaction.channel!.send({
- embeds: [
- new EmojiEmbed()
- .setTitle(title)
- .setDescription(description)
- .setStatus("Success")
- .setEmoji("GUILD.TICKET.OPEN")
- ],
- components: [
- new ActionRowBuilder<ButtonBuilder>().addComponents([
- new ButtonBuilder()
- .setLabel("Create Ticket")
- .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
- .setStyle(ButtonStyle.Success)
- .setCustomId("createticket")
- ])
- ]
- });
- templateSelected = true;
- }
+ const title = out.fields.getTextInputValue("title");
+ const description = out.fields.getTextInputValue("description");
+ await interaction.channel!.send({
+ embeds: [
+ new EmojiEmbed()
+ .setTitle(title)
+ .setDescription(description)
+ .setStatus("Success")
+ .setEmoji("GUILD.TICKET.OPEN")
+ ],
+ components: [
+ new ActionRowBuilder<ButtonBuilder>().addComponents([
+ new ButtonBuilder()
+ .setLabel("Create Ticket")
+ .setEmoji(getEmojiByName("TICKETS.SUGGESTION", "id"))
+ .setStyle(ButtonStyle.Success)
+ .setCustomId("createticket")
+ ])
+ ]
+ });
+ templateSelected = true;
}
}
} else if ((i.component as ButtonComponent).customId === "enabled") {
@@ -516,7 +512,7 @@
});
compiledData.enabled = !compiledData.enabled;
} else if ((i.component as ButtonComponent).customId === "manageTypes") {
- data = await manageTypes(interaction, data, m as Message); //TODO: Fix this
+ data.tickets = await manageTypes(interaction, data.tickets, m as Message);
}
}
await interaction.editReply({
@@ -713,24 +709,20 @@
continue;
}
out = out as ModalSubmitInteraction;
- if (out.fields) {
- let toAdd = out.fields.getTextInputValue("type");
- if (!toAdd) {
- continue;
- }
- toAdd = toAdd.substring(0, 80);
- try {
- await client.database.guilds.append(interaction.guild!.id, "tickets.customTypes", toAdd);
- } catch {
- continue;
- }
- data.customTypes = data.customTypes ?? [];
- if (!data.customTypes.includes(toAdd)) {
- data.customTypes.push(toAdd);
- }
- } else {
+ let toAdd = out.fields.getTextInputValue("type");
+ if (!toAdd) {
continue;
}
+ toAdd = toAdd.substring(0, 80);
+ try {
+ await client.database.guilds.append(interaction.guild!.id, "tickets.customTypes", toAdd);
+ } catch {
+ continue;
+ }
+ data.customTypes = data.customTypes ?? [];
+ if (!data.customTypes.includes(toAdd)) {
+ data.customTypes.push(toAdd);
+ }
} else if ((i.component as ButtonComponent).customId === "switchToDefault") {
i.deferUpdate();
await client.database.guilds.write(interaction.guild!.id, { "tickets.useCustom": false }, []);