Repository: Cog-Creators/Red-DiscordBot

Issue:
Trivia Coding Bot - Answer in spoiler tags
# Feature request
#### Select the type of feature you are requesting:

<!-- To check a box, replace the space between the [] with a x -->

- [x] Cog
- [ ] Command
- [ ] API functionality

Hello everyone, Sorry if the request is at the wrong place or put in the wrong way.
We are using (and very much appreciating!!) your trivia coding bot. As we are new to the topic of programing we use your bot to learn new bits and pieces every day. 
I'd like to suggest a feature which could be very useful: Could you please put the bot's answer to it's own questions in spoiler tags? So someone who is scrolling through the questions wouldn't unintentionally already read some answers.

I think this could be a very useful feature and I would very much appreciate if you could implement it.
Thanks for your attention and all the best,
Mel



Discussion:
I don't really see the point in this personally - why should someone not be able to read answers to questions they didn't answer? And if they did read the answer, is it a big deal? I might be catching your request wrong but users can just start their own trivia session instead of scrolling up the chats to answer existing questions.
I don't think it's a terrible idea, and it's a very little effort request, my only concern is adding one extra step to be able to see the answer for the people currently playing the game.
> 
> 
> I don't really see the point in this personally - why should someone not be able to read answers to questions they didn't answer? And if they did read the answer, is it a big deal? I might be catching your request wrong but users can just start their own trivia session instead of scrolling up the chats to answer existing questions.

Thanks for your answer. We let the bot constantly run in an extra room, creating kind of a library of questions and answers. Maybe that explains a bit more.
Currently, you can do `[p]triviaset revealanswer false` in order to stop the bot from posting answers. This could potentially be added as an extension to that setting.
This Feature would help us greatly as currently we have Our Questions in JSON Format and so we Placed the Explanations before the Questions. And since, it seems, there can not be more than 1000 Characters per line, we can not place enough \n or \r in order to not see the Explantions from the begginning for many of our Questions, and also placing a lot of New Lines makes Reading Past Questions hard, as you need to Scroll Up quite a bit :)

Resolving patch:
diff --git a/redbot/cogs/trivia/session.py b/redbot/cogs/trivia/session.py
--- a/redbot/cogs/trivia/session.py
+++ b/redbot/cogs/trivia/session.py
@@ -21,6 +21,13 @@
     _("Easy: {answer}."),
     _("Oh really? It's {answer} of course."),
 )
+
+SPOILER_REVEAL_MESSAGES = (
+    _("I know this one! ||{answer}!||"),
+    _("Easy: ||{answer}.||"),
+    _("Oh really? It's ||{answer}|| of course."),
+)
+
 _FAIL_MESSAGES = (
     _("To the next one I guess..."),
     _("Moving on..."),
@@ -204,7 +211,10 @@ async def wait_for_answer(self, answers, delay: float, timeout: float):
                 self.stop()
                 return False
             if self.settings["reveal_answer"]:
-                reply = T_(random.choice(_REVEAL_MESSAGES)).format(answer=answers[0])
+                if self.settings["use_spoilers"]:
+                    reply = T_(random.choice(SPOILER_REVEAL_MESSAGES)).format(answer=answers[0])
+                else:
+                    reply = T_(random.choice(_REVEAL_MESSAGES)).format(answer=answers[0])
             else:
                 reply = T_(random.choice(_FAIL_MESSAGES))
             if self.settings["bot_plays"]:
diff --git a/redbot/cogs/trivia/trivia.py b/redbot/cogs/trivia/trivia.py
--- a/redbot/cogs/trivia/trivia.py
+++ b/redbot/cogs/trivia/trivia.py
@@ -53,6 +53,7 @@ def __init__(self):
             reveal_answer=True,
             payout_multiplier=0.0,
             allow_override=True,
+            use_spoilers=False,
         )
 
         self.config.register_member(wins=0, games=0, total_score=0)
@@ -92,7 +93,8 @@ async def triviaset_showsettings(self, ctx: commands.Context):
                 "Points to win: {max_score}\n"
                 "Reveal answer on timeout: {reveal_answer}\n"
                 "Payout multiplier: {payout_multiplier}\n"
-                "Allow lists to override settings: {allow_override}"
+                "Allow lists to override settings: {allow_override}\n"
+                "Use Spoilers in answers: {use_spoilers}"
             ).format(**settings_dict),
             lang="py",
         )
@@ -149,6 +151,19 @@ async def triviaset_allowoverride(self, ctx: commands.Context, enabled: bool):
                 )
             )
 
+    @triviaset.command(name="usespoilers", usage="<true_or_false>")
+    async def trivaset_use_spoilers(self, ctx: commands.Context, enabled: bool):
+        """Set if bot will display the answers in spoilers.
+
+        If enabled, the bot will use spoilers to hide answers.
+        """
+        settings = self.config.guild(ctx.guild)
+        await settings.use_spoilers.set(enabled)
+        if enabled:
+            await ctx.send(_("Done. I'll put the answers in spoilers next time."))
+        else:
+            await ctx.send(_("Alright, I won't use spoilers to hide answers anymore."))
+
     @triviaset.command(name="botplays", usage="<true_or_false>")
     async def trivaset_bot_plays(self, ctx: commands.Context, enabled: bool):
         """Set whether or not the bot gains points.


Test patch: