From 0f6fbd374e8cd6f21453adf47566a1a5501562b6 Mon Sep 17 00:00:00 2001 From: Peter Bailey Date: Sat, 2 Sep 2023 13:08:34 -0400 Subject: [PATCH] React fix and update --- assets/unicode_map.json | 12 +++++++++++- docs/changelog.md | 6 ++++++ src/commands/contextCommands/react.ts | 17 +++++++++++++---- version.yaml | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/assets/unicode_map.json b/assets/unicode_map.json index 4719cca..c83cc56 100644 --- a/assets/unicode_map.json +++ b/assets/unicode_map.json @@ -24,5 +24,15 @@ "w": "🇼", "x": "🇽", "y": "🇾", - "z": "🇿" + "z": "🇿", + "0": "0️⃣", + "1": "1️⃣", + "2": "2️⃣", + "3": "3️⃣", + "4": "4️⃣", + "5": "5️⃣", + "6": "6️⃣", + "7": "7️⃣", + "8": "8️⃣", + "9": "9️⃣" } \ No newline at end of file diff --git a/docs/changelog.md b/docs/changelog.md index 09f25e4..b918f14 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -1,3 +1,9 @@ +## Version 2.6.1 - 2023-09-02 +### Fixed +- React command errored when user didn't follow up in time. +### Added +- Numbers can be used with React now + ## Version 2.6.0 - 2023-09-01 ### Added - React command! diff --git a/src/commands/contextCommands/react.ts b/src/commands/contextCommands/react.ts index 75fc06f..64bb1a6 100644 --- a/src/commands/contextCommands/react.ts +++ b/src/commands/contextCommands/react.ts @@ -1,4 +1,4 @@ -import { Message, ApplicationCommandType, ContextMenuCommandInteraction, MessageContextMenuCommandInteraction, ContextMenuCommandBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder } from "discord.js"; +import { Message, ApplicationCommandType, ContextMenuCommandInteraction, MessageContextMenuCommandInteraction, ContextMenuCommandBuilder, ModalBuilder, TextInputBuilder, TextInputStyle, ActionRowBuilder, ModalSubmitInteraction, ModalComponentData } from "discord.js"; import { Command } from "../../utilities/Command"; @@ -18,7 +18,8 @@ let execute = async (interaction: ContextMenuCommandInteraction) => { .setLabel("What string should Bella react with?") .setRequired(true) .setPlaceholder("Heterogram goes here...") - .setStyle(TextInputStyle.Short); + .setStyle(TextInputStyle.Short) + .setMaxLength(36); const firstActionRow = new ActionRowBuilder().addComponents(heterogramInput); @@ -26,14 +27,22 @@ let execute = async (interaction: ContextMenuCommandInteraction) => { // now present it to the user await interaction.showModal(modal); - const modalInteraction = await interaction.awaitModalSubmit({time: 20000}); + let modalInteraction: ModalSubmitInteraction; + try{ + modalInteraction = await interaction.awaitModalSubmit({time: 20000}); + } + catch(error){ + interaction.followUp({ content: `You didn't submit a reaction in time.`, ephemeral: true }); + return; + } + const reactText = modalInteraction.fields.getTextInputValue("reactHeterogramInput"); const unicodeMap: any = require('../../../assets/unicode_map.json'); if(isValidHeterogram(reactText, unicodeMap)){ addReactions(reactText, (interaction as MessageContextMenuCommandInteraction).targetMessage, unicodeMap); // we can silently end the interaction - await modalInteraction.deferUpdate() + await modalInteraction.deferUpdate(); } else { await modalInteraction.reply({ content: `\`${reactText}\` is not a valid heterogram!`, ephemeral: true }); diff --git a/version.yaml b/version.yaml index b08a127..b41b0c8 100644 --- a/version.yaml +++ b/version.yaml @@ -1,6 +1,6 @@ # https://semver.org/ version: 2.6.1 -release_date: 2023-09-01 +release_date: 2023-09-02 author: Bella Bean's Bonstruction description: Bella returns. Bella Beyond. changelog: ./docs/changelog.md