mirror of
https://github.com/aydenjahola/discord-multipurpose-bot.git
synced 2024-11-22 08:45:55 +00:00
fix a bug where if the user enocouters an error it would still wouild be makred as ongoing trivia
This commit is contained in:
parent
50bfb9c6e3
commit
d693d2f714
1 changed files with 156 additions and 141 deletions
|
@ -43,8 +43,10 @@ module.exports = {
|
|||
// Add the user to the set of active trivia players
|
||||
ongoingTrivia.add(userId);
|
||||
|
||||
try {
|
||||
const categoryId = interaction.options.getString("category");
|
||||
const categoryName = categoryId === "15" ? "Video Games" : "Anime & Manga";
|
||||
const categoryName =
|
||||
categoryId === "15" ? "Video Games" : "Anime & Manga";
|
||||
|
||||
// Fetch a trivia question from the cache or the API
|
||||
let triviaQuestion = await TriviaQuestion.findOne({
|
||||
|
@ -190,5 +192,18 @@ module.exports = {
|
|||
ongoingTrivia.delete(userId);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error fetching trivia question:", error);
|
||||
|
||||
// Inform the user about the error and let them retry
|
||||
await interaction.reply({
|
||||
content:
|
||||
"There was an error fetching your trivia question. Please try again later.",
|
||||
ephemeral: true,
|
||||
});
|
||||
|
||||
// Remove the user from the ongoing trivia set in case of an error
|
||||
ongoingTrivia.delete(userId);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue