From 0c3e77213566731bb54039daba6d57db0e1826ef Mon Sep 17 00:00:00 2001 From: kingslayer268 <36760455+kingslayer268@users.noreply.github.com> Date: Mon, 8 Mar 2021 02:57:41 +0530 Subject: [PATCH] Added use spoilers functionality (#4877) * Added use spoilers functionallity * Update trivia.py * Update session.py --- redbot/cogs/trivia/session.py | 12 +++++++++++- redbot/cogs/trivia/trivia.py | 17 ++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/redbot/cogs/trivia/session.py b/redbot/cogs/trivia/session.py index 334a0aee8..45d177da8 100644 --- a/redbot/cogs/trivia/session.py +++ b/redbot/cogs/trivia/session.py @@ -21,6 +21,13 @@ _REVEAL_MESSAGES = ( _("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 @@ class TriviaSession: 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 index 64b2ec22c..3f7d3c431 100644 --- a/redbot/cogs/trivia/trivia.py +++ b/redbot/cogs/trivia/trivia.py @@ -53,6 +53,7 @@ class Trivia(commands.Cog): 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 @@ class Trivia(commands.Cog): "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 @@ class Trivia(commands.Cog): ) ) + @triviaset.command(name="usespoilers", usage="") + 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="") async def trivaset_bot_plays(self, ctx: commands.Context, enabled: bool): """Set whether or not the bot gains points.