From e566276fc45516edb1c0efc834623b9e92bebad6 Mon Sep 17 00:00:00 2001 From: Jeremy Zhang Date: Sat, 5 Jan 2019 20:54:50 +0000 Subject: [PATCH] Bugfix if guild not initialized yet and no reactions --- discordbot/titanembeds/bot.py | 3 ++- discordbot/titanembeds/redisqueue.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/discordbot/titanembeds/bot.py b/discordbot/titanembeds/bot.py index 5ddb28a..1d4b0cd 100644 --- a/discordbot/titanembeds/bot.py +++ b/discordbot/titanembeds/bot.py @@ -229,7 +229,8 @@ class Titan(discord.AutoShardedClient): me = channel.guild.get_member(self.user.id) if channel.permissions_for(me).read_messages: message = await channel.get_message(message_id) - await self.on_reaction_add(message.reactions[0], None) + if len(message.reactions): + await self.on_reaction_add(message.reactions[0], None) async def on_raw_reaction_remove(self, payload): message_id = payload.message_id diff --git a/discordbot/titanembeds/redisqueue.py b/discordbot/titanembeds/redisqueue.py index 5be81af..79474e7 100644 --- a/discordbot/titanembeds/redisqueue.py +++ b/discordbot/titanembeds/redisqueue.py @@ -139,8 +139,11 @@ class RedisQueue: guild = self.bot.get_guild(int(params["guild_id"])) query = params["query"] result = None - members = guild.members - if len(query) > 5 and query[-5] == '#': + if guild: + members = guild.members + else: + members = None + if members and len(query) > 5 and query[-5] == '#': potential_discriminator = query[-4:] result = discord.utils.get(members, name=query[:-5], discriminator=potential_discriminator) if not result: