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", [])