aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/fun
diff options
context:
space:
mode:
Diffstat (limited to 'bot/exts/fun')
-rw-r--r--bot/exts/fun/battleship.py5
-rw-r--r--bot/exts/fun/connect_four.py5
-rw-r--r--bot/exts/fun/game.py8
-rw-r--r--bot/exts/fun/hangman.py1
-rw-r--r--bot/exts/fun/madlibs.py1
-rw-r--r--bot/exts/fun/snakes/_snakes_cog.py6
-rw-r--r--bot/exts/fun/snakes/_utils.py5
-rw-r--r--bot/exts/fun/tic_tac_toe.py5
-rw-r--r--bot/exts/fun/trivia_quiz.py2
9 files changed, 16 insertions, 22 deletions
diff --git a/bot/exts/fun/battleship.py b/bot/exts/fun/battleship.py
index 4a552605..ded784be 100644
--- a/bot/exts/fun/battleship.py
+++ b/bot/exts/fun/battleship.py
@@ -1,4 +1,3 @@
-import asyncio
import logging
import random
import re
@@ -244,7 +243,7 @@ class Game:
while True:
try:
await self.bot.wait_for("message", check=self.predicate, timeout=60.0)
- except asyncio.TimeoutError:
+ except TimeoutError:
await self.turn.user.send("You took too long. Game over!")
await self.next.user.send(f"{self.turn.user} took too long. Game over!")
await self.public_channel.send(
@@ -400,7 +399,7 @@ class Battleship(commands.Cog):
check=partial(self.predicate, ctx, announcement),
timeout=60.0
)
- except asyncio.TimeoutError:
+ except TimeoutError:
self.waiting.remove(ctx.author)
await announcement.delete()
await ctx.send(f"{ctx.author.mention} Seems like there's no one here to play...")
diff --git a/bot/exts/fun/connect_four.py b/bot/exts/fun/connect_four.py
index 6544dc48..eec092d1 100644
--- a/bot/exts/fun/connect_four.py
+++ b/bot/exts/fun/connect_four.py
@@ -1,4 +1,3 @@
-import asyncio
import random
from functools import partial
@@ -131,7 +130,7 @@ class Game:
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", check=self.predicate, timeout=30.0)
- except asyncio.TimeoutError:
+ except TimeoutError:
await self.channel.send(f"{self.player_active.mention}, you took too long. Game over!")
return None
else:
@@ -406,7 +405,7 @@ class ConnectFour(commands.Cog):
check=partial(self.get_player, ctx, announcement),
timeout=60.0
)
- except asyncio.TimeoutError:
+ except TimeoutError:
self.waiting.remove(ctx.author)
await announcement.delete()
await ctx.send(
diff --git a/bot/exts/fun/game.py b/bot/exts/fun/game.py
index b2b18f04..c9824f22 100644
--- a/bot/exts/fun/game.py
+++ b/bot/exts/fun/game.py
@@ -421,13 +421,13 @@ class Games(Cog):
"url": data["url"],
"description": f"{data['summary']}\n\n" if "summary" in data else "\n",
"release_date": release_date,
- "rating": round(data["total_rating"] if "total_rating" in data else 0, 2),
- "rating_count": data["total_rating_count"] if "total_rating_count" in data else "?",
+ "rating": round(data.get("total_rating", 0), 2),
+ "rating_count": data.get("total_rating_count", "?"),
"platforms": ", ".join(platform["name"] for platform in data["platforms"]) if "platforms" in data else "?",
"status": GameStatus(data["status"]).name if "status" in data else "?",
"age_ratings": rating,
"made_by": ", ".join(companies),
- "storyline": data["storyline"] if "storyline" in data else ""
+ "storyline": data.get("storyline", "")
}
page = GAME_PAGE.format(**formatting)
@@ -448,7 +448,7 @@ class Games(Cog):
formatting = {
"name": game["name"],
"url": game["url"],
- "rating": round(game["total_rating"] if "total_rating" in game else 0, 2),
+ "rating": round(game.get("total_rating", 0), 2),
"rating_count": game["total_rating_count"] if "total_rating" in game else "?"
}
line = GAME_SEARCH_LINE.format(**formatting)
diff --git a/bot/exts/fun/hangman.py b/bot/exts/fun/hangman.py
index 7a02a552..869e0644 100644
--- a/bot/exts/fun/hangman.py
+++ b/bot/exts/fun/hangman.py
@@ -1,4 +1,3 @@
-from asyncio import TimeoutError
from pathlib import Path
from random import choice
diff --git a/bot/exts/fun/madlibs.py b/bot/exts/fun/madlibs.py
index c14e8a3a..f457a191 100644
--- a/bot/exts/fun/madlibs.py
+++ b/bot/exts/fun/madlibs.py
@@ -1,5 +1,4 @@
import json
-from asyncio import TimeoutError
from pathlib import Path
from random import choice
from typing import TypedDict
diff --git a/bot/exts/fun/snakes/_snakes_cog.py b/bot/exts/fun/snakes/_snakes_cog.py
index c0210e43..6f359928 100644
--- a/bot/exts/fun/snakes/_snakes_cog.py
+++ b/bot/exts/fun/snakes/_snakes_cog.py
@@ -283,7 +283,7 @@ class Snakes(Cog):
params = {}
async with self.bot.http_session.get(url, params=params, timeout=ClientTimeout(total=10)) as response:
- return await response.json()
+ return await response.json()
def _get_random_long_message(self, messages: list[str], retries: int = 10) -> str:
"""
@@ -422,7 +422,7 @@ class Snakes(Cog):
# Validate the answer
try:
reaction, user = await ctx.bot.wait_for("reaction_add", timeout=45.0, check=predicate)
- except asyncio.TimeoutError:
+ except TimeoutError:
await ctx.send(f"You took too long. The correct answer was **{options[answer]}**.")
await message.clear_reactions()
return
@@ -516,7 +516,7 @@ class Snakes(Cog):
try:
reaction, user = await ctx.bot.wait_for(
"reaction_add", timeout=300, check=predicate)
- except asyncio.TimeoutError:
+ except TimeoutError:
log.debug("Antidote timed out waiting for a reaction")
break # We're done, no reactions for the last 5 minutes
diff --git a/bot/exts/fun/snakes/_utils.py b/bot/exts/fun/snakes/_utils.py
index a967f47b..c48ecf8d 100644
--- a/bot/exts/fun/snakes/_utils.py
+++ b/bot/exts/fun/snakes/_utils.py
@@ -1,4 +1,3 @@
-import asyncio
import io
import json
import logging
@@ -453,7 +452,7 @@ class SnakeAndLaddersGame:
await startup.remove_reaction(reaction.emoji, user)
- except asyncio.TimeoutError:
+ except TimeoutError:
log.debug("Snakes and Ladders timed out waiting for a reaction")
await self.cancel_game()
return # We're done, no reactions for the last 5 minutes
@@ -630,7 +629,7 @@ class SnakeAndLaddersGame:
if self._check_all_rolled():
break
- except asyncio.TimeoutError:
+ except TimeoutError:
log.debug("Snakes and Ladders timed out waiting for a reaction")
await self.cancel_game()
return # We're done, no reactions for the last 5 minutes
diff --git a/bot/exts/fun/tic_tac_toe.py b/bot/exts/fun/tic_tac_toe.py
index d4ae7107..f6ee6293 100644
--- a/bot/exts/fun/tic_tac_toe.py
+++ b/bot/exts/fun/tic_tac_toe.py
@@ -1,4 +1,3 @@
-import asyncio
import random
from collections.abc import Callable
@@ -59,7 +58,7 @@ class Player:
try:
react, _ = await self.ctx.bot.wait_for("reaction_add", timeout=30.0, check=check_for_move)
- except asyncio.TimeoutError:
+ except TimeoutError:
return True, None
else:
return False, list(Emojis.number_emojis.keys())[list(Emojis.number_emojis.values()).index(react.emoji)]
@@ -162,7 +161,7 @@ class Game:
timeout=60.0,
check=confirm_check
)
- except asyncio.TimeoutError:
+ except TimeoutError:
self.over = True
self.canceled = True
await confirm_message.delete()
diff --git a/bot/exts/fun/trivia_quiz.py b/bot/exts/fun/trivia_quiz.py
index b96007b5..4f352b71 100644
--- a/bot/exts/fun/trivia_quiz.py
+++ b/bot/exts/fun/trivia_quiz.py
@@ -430,7 +430,7 @@ class TriviaQuiz(commands.Cog):
try:
msg = await self.bot.wait_for("message", check=check_func(quiz_entry.var_tol), timeout=10)
- except asyncio.TimeoutError:
+ except TimeoutError:
# In case of TimeoutError and the game has been stopped, then do nothing.
if not self.game_status[ctx.channel.id]:
break