From 7423b40337e00bbc3d4cdc0312d8233e2758abc2 Mon Sep 17 00:00:00 2001
From: Romain J <romain.ordi@gmail.com>
Date: Thu, 11 Feb 2021 18:40:00 +0100
Subject: [PATCH] fix(core): close TUXBOT-BOT-11, close TUXBOT-BOT-19

---
 tuxbot/core/bot.py                    | 9 +++++++--
 tuxbot/core/utils/functions/prefix.py | 8 +++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/tuxbot/core/bot.py b/tuxbot/core/bot.py
index 1071afc..eb921c8 100644
--- a/tuxbot/core/bot.py
+++ b/tuxbot/core/bot.py
@@ -107,11 +107,16 @@ class Tux(commands.AutoShardedBot):
             return True
 
         if (
-            search_for(self.config.Servers, message.guild.id, "blacklisted")
+            search_for(self.config.Users, message.author.id, "blacklisted")
             or search_for(
                 self.config.Channels, message.channel.id, "blacklisted"
             )
-            or search_for(self.config.Users, message.author.id, "blacklisted")
+            or (
+                message.guild
+                and search_for(
+                    self.config.Servers, message.guild.id, "blacklisted"
+                )
+            )
         ):
             return True
 
diff --git a/tuxbot/core/utils/functions/prefix.py b/tuxbot/core/utils/functions/prefix.py
index 58f4e92..d64da59 100644
--- a/tuxbot/core/utils/functions/prefix.py
+++ b/tuxbot/core/utils/functions/prefix.py
@@ -1,22 +1,24 @@
-from typing import List
+from typing import List, Union
 
 import discord
 
 from tuxbot.core.config import search_for
 
 
-def get_prefixes(tux, guild: discord.Guild) -> List[str]:
+def get_prefixes(tux, guild: Union[discord.Guild, None]) -> List[str]:
     """Get custom  prefixes for one guild.
     Parameters
     ----------
     tux:Tux
         The bot instance.
 
-    guild:discord.Guild
+    guild:Union[discord.Guild, None]
         The required guild prefixes.
     Returns
     -------
     List[str]
         List of all prefixes.
     """
+    if not guild:
+        return []
     return search_for(tux.config.Servers, guild.id, "prefixes", [])