Skip to content

Commit 3a84bf8

Browse files
authored
Make group id optional when claiming T2 patreon benefits (#290)
1 parent 3b2139a commit 3a84bf8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/patreon-trigger.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ export async function handlePatreonTrigger(interaction: ButtonInteraction) {
7575
.setCustomId('groupId')
7676
.setLabel("Your group's ID")
7777
.setPlaceholder("Ex: 139 (Can be found on your group's page URL.)")
78-
.setStyle(1);
78+
.setStyle(1)
79+
.setRequired(false);
7980

8081
modal.addComponents(new ActionRowBuilder<TextInputBuilder>().addComponents(usernameInput));
8182

@@ -100,12 +101,12 @@ export async function handlePatreonModalSubmit(interaction: ModalSubmitInteracti
100101
const groupIdValue = interaction.fields.getTextInputValue('groupId');
101102
const isInteger = typeof groupIdValue === 'string' && Number.isInteger(parseInt(groupIdValue));
102103

103-
if (!isInteger) {
104+
if (groupIdValue !== '' && !isInteger) {
104105
interaction.reply({ content: '❌ Please provide a valid group ID.', ephemeral: true });
105106
return;
106107
}
107108

108-
groupId = parseInt(groupIdValue);
109+
groupId = groupIdValue === '' ? undefined : parseInt(groupIdValue);
109110
}
110111

111112
try {

0 commit comments

Comments
 (0)