Skip to content

Commit 36c4898

Browse files
committed
fixed deferral to use editReply if already replied
1 parent 7b8728a commit 36c4898

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/utils/voteHelpers.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,15 @@ export async function handleVoting(
153153
if (participants.length && !participants.includes(interaction.user.id)) {
154154
if (!interaction.deferred)
155155
await interaction.deferReply({ flags: MessageFlags.Ephemeral })
156-
return interaction.editReply({
157-
content: `You are not allowed to vote in this poll.`,
158-
})
156+
if (interaction.deferred || interaction.replied) {
157+
return interaction.editReply({
158+
content: `You are not allowed to vote in this poll.`,
159+
})
160+
} else {
161+
return interaction.reply({
162+
content: `You are not allowed to vote in this poll.`,
163+
})
164+
}
159165
}
160166

161167
// Get current user vote from database
@@ -260,7 +266,12 @@ export async function handleTwoPlayerMatchVoting(
260266
if (participants.length && !participants.includes(interaction.user.id)) {
261267
if (!interaction.deferred)
262268
await interaction.deferReply({ flags: MessageFlags.Ephemeral })
263-
return interaction.editReply({
269+
if (interaction.deferred || interaction.replied) {
270+
return interaction.editReply({
271+
content: `You are not allowed to vote in this poll.`,
272+
})
273+
}
274+
return interaction.reply({
264275
content: `You are not allowed to vote in this poll.`,
265276
})
266277
}

0 commit comments

Comments
 (0)