aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/evergreen/trivia_quiz.py
diff options
context:
space:
mode:
authorGravatar Matteo Bertucci <[email protected]>2020-11-30 15:18:42 +0100
committerGravatar GitHub <[email protected]>2020-11-30 15:18:42 +0100
commit0ad849431eee3cab48485a132df23b0883142cf6 (patch)
treed9bd17fbd8f22c45e682079f6e3e565b6e17f61d /bot/exts/evergreen/trivia_quiz.py
parent"adding xkcd feature" (diff)
parentMerge pull request #532 from python-discord/sebastiaan/ci/add-core-dev-approv... (diff)
Merge branch 'master' into issue-337
Diffstat (limited to 'bot/exts/evergreen/trivia_quiz.py')
-rw-r--r--bot/exts/evergreen/trivia_quiz.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/bot/exts/evergreen/trivia_quiz.py b/bot/exts/evergreen/trivia_quiz.py
index c1a271e8..fe692c2a 100644
--- a/bot/exts/evergreen/trivia_quiz.py
+++ b/bot/exts/evergreen/trivia_quiz.py
@@ -40,7 +40,7 @@ class TriviaQuiz(commands.Cog):
def load_questions() -> dict:
"""Load the questions from the JSON file."""
p = Path("bot", "resources", "evergreen", "trivia_quiz.json")
- with p.open() as json_data:
+ with p.open(encoding="utf8") as json_data:
questions = json.load(json_data)
return questions
@@ -121,8 +121,10 @@ class TriviaQuiz(commands.Cog):
# A function to check whether user input is the correct answer(close to the right answer)
def check(m: discord.Message) -> bool:
- ratio = fuzz.ratio(answer.lower(), m.content.lower())
- return ratio > 85 and m.channel == ctx.channel
+ return (
+ m.channel == ctx.channel
+ and fuzz.ratio(answer.lower(), m.content.lower()) > 85
+ )
try:
msg = await self.bot.wait_for('message', check=check, timeout=10)