generated from nhcarrigan/template
refactor: consolidate modal routing and use LabelBuilder for modal components
Merges modalInteractionCreate into interactionCreate, and replaces ActionRowBuilder with LabelBuilder for the announcement modal components.
This commit is contained in:
@@ -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<TextInputBuilder>().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<StringSelectMenuBuilder>().addComponents(
|
||||
categorySelect,
|
||||
) as unknown as ActionRowBuilder<TextInputBuilder>,
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user