fix(core): close TUXBOT-BOT-11, close TUXBOT-BOT-19

This commit is contained in:
Romain J 2021-02-11 18:40:00 +01:00
parent fa98d67276
commit 7423b40337
2 changed files with 12 additions and 5 deletions

View file

@ -107,11 +107,16 @@ class Tux(commands.AutoShardedBot):
return True return True
if ( if (
search_for(self.config.Servers, message.guild.id, "blacklisted") search_for(self.config.Users, message.author.id, "blacklisted")
or search_for( or search_for(
self.config.Channels, message.channel.id, "blacklisted" 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 return True

View file

@ -1,22 +1,24 @@
from typing import List from typing import List, Union
import discord import discord
from tuxbot.core.config import search_for 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. """Get custom prefixes for one guild.
Parameters Parameters
---------- ----------
tux:Tux tux:Tux
The bot instance. The bot instance.
guild:discord.Guild guild:Union[discord.Guild, None]
The required guild prefixes. The required guild prefixes.
Returns Returns
------- -------
List[str] List[str]
List of all prefixes. List of all prefixes.
""" """
if not guild:
return []
return search_for(tux.config.Servers, guild.id, "prefixes", []) return search_for(tux.config.Servers, guild.id, "prefixes", [])