diff --git a/bot/src/commands/announcement.ts b/bot/src/commands/announcement.ts index c4daf63..683e986 100644 --- a/bot/src/commands/announcement.ts +++ b/bot/src/commands/announcement.ts @@ -5,7 +5,7 @@ */ import { - ActionRowBuilder, + LabelBuilder, ModalBuilder, StringSelectMenuBuilder, TextInputBuilder, @@ -37,8 +37,6 @@ export const announcement: Command = async(_hikari, interaction) => { const contentInput = new TextInputBuilder(). setCustomId("content"). - // eslint-disable-next-line deprecation/deprecation -- No V2 equivalent exists for modal text input labels - setLabel("Announcement Copy"). setStyle(TextInputStyle.Paragraph). setMaxLength(4000). setRequired(true); @@ -52,13 +50,18 @@ export const announcement: Command = async(_hikari, interaction) => { { label: "Company", value: "company" }, ]); - // eslint-disable-next-line deprecation/deprecation -- No V2 equivalent exists for modal component rows - modal.addComponents( - new ActionRowBuilder().addComponents(contentInput), - // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- discord.js types don't yet reflect select menus in modals, but they're supported at the API level - new ActionRowBuilder().addComponents( - categorySelect, - ) as unknown as ActionRowBuilder, + const contentLabel = new LabelBuilder().setLabel("Announcement Copy"). + setDescription( + "Your version of the announcement, to send to the AI for processing.", + ). + setTextInputComponent(contentInput); + const categoryLabel = new LabelBuilder().setLabel("Announcement Category"). + setDescription("The category of the announcement."). + setStringSelectMenuComponent(categorySelect); + + modal.addLabelComponents( + contentLabel, + categoryLabel, ); await interaction.showModal(modal); diff --git a/bot/src/events/interactionCreate.ts b/bot/src/events/interactionCreate.ts index 2fae47a..3e449ab 100644 --- a/bot/src/events/interactionCreate.ts +++ b/bot/src/events/interactionCreate.ts @@ -6,9 +6,14 @@ import { about } from "../commands/about.js"; import { announcement } from "../commands/announcement.js"; import { dm } from "../commands/dm.js"; +import { handleAnnouncementModal } from "../modules/handleAnnouncementModal.js"; import { logger } from "../utils/logger.js"; import type { Command } from "../interfaces/command.js"; -import type { ChatInputCommandInteraction, Client } from "discord.js"; +import type { + ModalSubmitInteraction, + ChatInputCommandInteraction, + Client, +} from "discord.js"; const handlers: { _default: Command } & Record = { _default: async(_, interaction): Promise => { @@ -41,4 +46,18 @@ const chatInputInteractionCreate = async( }); }; -export { chatInputInteractionCreate }; +/** + * Routes a modal submit interaction to the appropriate handler. + * @param _hikari - Hikari's Discord instance (unused). + * @param interaction - The modal submit interaction payload from Discord. + */ +const modalSubmitInteractionCreate = async( + _hikari: Client, + interaction: ModalSubmitInteraction, +): Promise => { + if (interaction.customId === "announcement_modal") { + await handleAnnouncementModal(interaction); + } +}; + +export { chatInputInteractionCreate, modalSubmitInteractionCreate }; diff --git a/bot/src/events/modalInteractionCreate.ts b/bot/src/events/modalInteractionCreate.ts deleted file mode 100644 index f2101d3..0000000 --- a/bot/src/events/modalInteractionCreate.ts +++ /dev/null @@ -1,24 +0,0 @@ -/** - * @copyright nhcarrigan - * @license Naomi's Public License - * @author Naomi Carrigan - */ - -import { handleAnnouncementModal } from "../modules/handleAnnouncementModal.js"; -import type { Client, ModalSubmitInteraction } from "discord.js"; - -/** - * Routes a modal submit interaction to the appropriate handler. - * @param _hikari - Hikari's Discord instance (unused). - * @param interaction - The modal submit interaction payload from Discord. - */ -const modalSubmitInteractionCreate = async( - _hikari: Client, - interaction: ModalSubmitInteraction, -): Promise => { - if (interaction.customId === "announcement_modal") { - await handleAnnouncementModal(interaction); - } -}; - -export { modalSubmitInteractionCreate }; diff --git a/bot/src/index.ts b/bot/src/index.ts index a40b8b9..25ddbcf 100644 --- a/bot/src/index.ts +++ b/bot/src/index.ts @@ -6,10 +6,10 @@ import { DiscordAnalytics } from "@nhcarrigan/discord-analytics"; import { Client, Events, GatewayIntentBits, Partials } from "discord.js"; -import { chatInputInteractionCreate } from "./events/interactionCreate.js"; import { + chatInputInteractionCreate, modalSubmitInteractionCreate, -} from "./events/modalInteractionCreate.js"; +} from "./events/interactionCreate.js"; import { logger } from "./utils/logger.js"; /*