From 82f2f7ed3687e08ad70fc6b3970bc8cd93cac247 Mon Sep 17 00:00:00 2001 From: Ayden Jahola Date: Fri, 6 Sep 2024 01:41:23 +0100 Subject: [PATCH] trivia: add regex formatting so that titles can have the category names --- commands/fun/trivia.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/commands/fun/trivia.js b/commands/fun/trivia.js index 7aedc33..e13e458 100644 --- a/commands/fun/trivia.js +++ b/commands/fun/trivia.js @@ -90,7 +90,9 @@ module.exports = { default: return "Video Games"; } - })(); + })() + .replace(/[^a-zA-Z0-9 ]/g, "") + .trim(); // Remove special characters and trim the category name for MongoDB query purposes in the Emebed title // Fetch a trivia question from the cache or the API let triviaQuestion = await TriviaQuestion.findOne({ @@ -154,7 +156,7 @@ module.exports = { // Create an embed with the trivia question and numbered options const triviaEmbed = new EmbedBuilder() .setColor("#0099ff") - .setTitle("Trivia Question") + .setTitle(`${categoryName} Trivia Question`) .setDescription(question) .addFields( Object.entries(answerMap).map(([number, answer]) => ({