From 5ba95090d9fe0ce3ea1189473ffc956af303788c Mon Sep 17 00:00:00 2001 From: Toby Harradine Date: Mon, 15 Oct 2018 22:31:14 +1100 Subject: [PATCH] [Streams] Suppress HTTPExceptions on load (#2228) Resolves #2227. Signed-off-by: Toby Harradine --- redbot/cogs/streams/streams.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/redbot/cogs/streams/streams.py b/redbot/cogs/streams/streams.py index 901ca6803..9665b4755 100644 --- a/redbot/cogs/streams/streams.py +++ b/redbot/cogs/streams/streams.py @@ -626,8 +626,13 @@ class Streams(commands.Cog): raw_stream["_messages_cache"] = [] for raw_msg in raw_msg_cache: chn = self.bot.get_channel(raw_msg["channel"]) - msg = await chn.get_message(raw_msg["message"]) - raw_stream["_messages_cache"].append(msg) + if chn is not None: + try: + msg = await chn.get_message(raw_msg["message"]) + except discord.HTTPException: + pass + else: + raw_stream["_messages_cache"].append(msg) token = await self.db.tokens.get_raw(_class.__name__, default=None) if token is not None: raw_stream["token"] = token @@ -646,8 +651,13 @@ class Streams(commands.Cog): raw_community["_messages_cache"] = [] for raw_msg in raw_msg_cache: chn = self.bot.get_channel(raw_msg["channel"]) - msg = await chn.get_message(raw_msg["message"]) - raw_community["_messages_cache"].append(msg) + if chn is not None: + try: + msg = await chn.get_message(raw_msg["message"]) + except discord.HTTPException: + pass + else: + raw_community["_messages_cache"].append(msg) token = await self.db.tokens.get_raw(_class.__name__, default=None) communities.append(_class(token=token, **raw_community))