Skip to content

Commit

Permalink
React fix and update
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterKBailey committed Sep 2, 2023
1 parent 97150ce commit 0f6fbd3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
12 changes: 11 additions & 1 deletion assets/unicode_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -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️⃣"
}
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -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!
Expand Down
17 changes: 13 additions & 4 deletions src/commands/contextCommands/react.ts
Original file line number Diff line number Diff line change
@@ -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";


Expand All @@ -18,22 +18,31 @@ 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<TextInputBuilder>().addComponents(heterogramInput);

modal.addComponents(firstActionRow);

// 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 });
Expand Down
2 changes: 1 addition & 1 deletion version.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0f6fbd3

Please sign in to comment.