generated from nhcarrigan/template
fix: web client styling and nav updates #21
@@ -21,6 +21,7 @@ import type { Command } from "../interfaces/command.js";
|
||||
* @param _hikari - Hikari's Discord instance (unused).
|
||||
* @param interaction - The command interaction payload from Discord.
|
||||
*/
|
||||
// eslint-disable-next-line max-lines-per-function -- Modal requires many input components
|
||||
export const announcement: Command = async(_hikari, interaction) => {
|
||||
try {
|
||||
if (!entitledUsers.includes(interaction.user.id)) {
|
||||
@@ -41,6 +42,24 @@ export const announcement: Command = async(_hikari, interaction) => {
|
||||
setMaxLength(4000).
|
||||
setRequired(true);
|
||||
|
||||
const contentInput2 = new TextInputBuilder().
|
||||
setCustomId("content_2").
|
||||
setStyle(TextInputStyle.Paragraph).
|
||||
setMaxLength(4000).
|
||||
setRequired(false);
|
||||
|
||||
const contentInput3 = new TextInputBuilder().
|
||||
setCustomId("content_3").
|
||||
setStyle(TextInputStyle.Paragraph).
|
||||
setMaxLength(4000).
|
||||
setRequired(false);
|
||||
|
||||
const contentInput4 = new TextInputBuilder().
|
||||
setCustomId("content_4").
|
||||
setStyle(TextInputStyle.Paragraph).
|
||||
setMaxLength(4000).
|
||||
setRequired(false);
|
||||
|
||||
const categorySelect = new StringSelectMenuBuilder().
|
||||
setCustomId("category").
|
||||
setPlaceholder("Select a category").
|
||||
@@ -55,12 +74,27 @@ export const announcement: Command = async(_hikari, interaction) => {
|
||||
"Your version of the announcement, to send to the AI for processing.",
|
||||
).
|
||||
setTextInputComponent(contentInput);
|
||||
// eslint-disable-next-line stylistic/max-len -- Label chain exceeds line length limit
|
||||
const contentLabel2 = new LabelBuilder().setLabel("Additional Copy (Part 2)").
|
||||
setDescription("Optional continuation of your announcement copy.").
|
||||
setTextInputComponent(contentInput2);
|
||||
// eslint-disable-next-line stylistic/max-len -- Label chain exceeds line length limit
|
||||
const contentLabel3 = new LabelBuilder().setLabel("Additional Copy (Part 3)").
|
||||
setDescription("Optional continuation of your announcement copy.").
|
||||
setTextInputComponent(contentInput3);
|
||||
// eslint-disable-next-line stylistic/max-len -- Label chain exceeds line length limit
|
||||
const contentLabel4 = new LabelBuilder().setLabel("Additional Copy (Part 4)").
|
||||
setDescription("Optional continuation of your announcement copy.").
|
||||
setTextInputComponent(contentInput4);
|
||||
const categoryLabel = new LabelBuilder().setLabel("Announcement Category").
|
||||
setDescription("The category of the announcement.").
|
||||
setStringSelectMenuComponent(categorySelect);
|
||||
|
||||
modal.addLabelComponents(
|
||||
contentLabel,
|
||||
contentLabel2,
|
||||
contentLabel3,
|
||||
contentLabel4,
|
||||
categoryLabel,
|
||||
);
|
||||
|
||||
|
||||
@@ -87,26 +87,37 @@ const buildAnnouncementFiles = (rawPost: RawPost): Array<AttachmentBuilder> => {
|
||||
* to the owner's DMs, and replies ephemerally with the platform recap.
|
||||
* @param interaction - The modal submit interaction payload from Discord.
|
||||
*/
|
||||
// eslint-disable-next-line max-lines-per-function -- This is a big function.
|
||||
export const handleAnnouncementModal = async(
|
||||
interaction: ModalSubmitInteraction,
|
||||
): Promise<void> => {
|
||||
try {
|
||||
await interaction.deferReply({ ephemeral: true });
|
||||
|
||||
const content = interaction.fields.getTextInputValue("content");
|
||||
const content = [
|
||||
interaction.fields.getTextInputValue("content"),
|
||||
interaction.fields.getTextInputValue("content_2"),
|
||||
interaction.fields.getTextInputValue("content_3"),
|
||||
interaction.fields.getTextInputValue("content_4"),
|
||||
].filter((part) => {
|
||||
return part.length > 0;
|
||||
}).join("\n\n");
|
||||
const categoryValues = interaction.fields.getStringSelectValues("category");
|
||||
const type = categoryValues[0] ?? "company";
|
||||
|
||||
const response = await fetch("https://hikari.nhcarrigan.com/api/announcement", {
|
||||
body: JSON.stringify({ content, type }),
|
||||
headers: {
|
||||
const response = await fetch(
|
||||
"https://hikari.nhcarrigan.com/api/announcement",
|
||||
{
|
||||
body: JSON.stringify({ content, type }),
|
||||
headers: {
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- HTTP header capitalisation convention
|
||||
"Authorization": process.env.ANNOUNCEMENT_TOKEN ?? "",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- HTTP header naming convention
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": process.env.ANNOUNCEMENT_TOKEN ?? "",
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- HTTP header naming convention
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
method: "POST",
|
||||
},
|
||||
method: "POST",
|
||||
});
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
await interaction.editReply({
|
||||
|
||||
Reference in New Issue
Block a user