diff --git a/redbot/cogs/trivia/session.py b/redbot/cogs/trivia/session.py index 45d177da8..2494e809a 100644 --- a/redbot/cogs/trivia/session.py +++ b/redbot/cogs/trivia/session.py @@ -1,5 +1,6 @@ """Module to manage trivia sessions.""" import asyncio +import contextlib import time import random from collections import Counter @@ -207,7 +208,8 @@ class TriviaSession: ) except asyncio.TimeoutError: if time.time() - self._last_response >= timeout: - await self.ctx.send(_("Guys...? Well, I guess I'll stop then.")) + with contextlib.suppress(discord.HTTPException): + await self.ctx.send(_("Guys...? Well, I guess I'll stop then.")) self.stop() return False if self.settings["reveal_answer"]: @@ -220,11 +222,19 @@ class TriviaSession: if self.settings["bot_plays"]: reply += _(" **+1** for me!") self.scores[self.ctx.guild.me] += 1 - await self.ctx.send(reply) + try: + await self.ctx.send(reply) + except (discord.NotFound, discord.Forbidden): + self.stop() + return False else: self.scores[message.author] += 1 reply = _("You got it {user}! **+1** to you!").format(user=message.author.display_name) - await self.ctx.send(reply) + try: + await self.ctx.send(reply) + except (discord.NotFound, discord.Forbidden): + self.stop() + return False return True def check_answer(self, answers):