diff --git a/ClemBot.Bot/bot/__main__.py b/ClemBot.Bot/bot/__main__.py index 43d94d73..b8d9a41c 100644 --- a/ClemBot.Bot/bot/__main__.py +++ b/ClemBot.Bot/bot/__main__.py @@ -7,6 +7,7 @@ import bot.bot_secrets as bot_secrets from bot.clem_bot import ClemBot +from bot.consts import INVALID_PREFIXES from bot.custom_prefix import CustomPrefix from bot.messaging.messenger import Messenger from bot.utils.scheduler import Scheduler @@ -36,6 +37,9 @@ async def main() -> None: # get the default prefix for the bot instance prefix = bot_secrets.secrets.bot_prefix + if prefix in INVALID_PREFIXES: + bot_log.fatal(f"Invalid bot prefix") + sys.exit(0) # Initialize the messenger here and inject it into the base bot class, # this is so it can be reused later on diff --git a/ClemBot.Bot/bot/cogs/custom_prefix_cog.py b/ClemBot.Bot/bot/cogs/custom_prefix_cog.py index 5cc04d58..36e39d38 100644 --- a/ClemBot.Bot/bot/cogs/custom_prefix_cog.py +++ b/ClemBot.Bot/bot/cogs/custom_prefix_cog.py @@ -4,7 +4,7 @@ import bot.bot_secrets as bot_secrets import bot.extensions as ext from bot.clem_bot import ClemBot -from bot.consts import Claims, Colors +from bot.consts import INVALID_PREFIXES, Claims, Colors from bot.utils.logging_utils import get_logger log = get_logger(__name__) @@ -45,6 +45,15 @@ async def prefix(self, ctx: ext.ClemBotCtx, *, prefix: str | None = None) -> Non await ctx.send(embed=embed) return + if prefix in INVALID_PREFIXES: + embed = discord.Embed(title="Error", color=Colors.Error) + embed.add_field( + name="Invalid prefix", + value=f"The given prefix `{prefix}` is not supported.", + ) + await ctx.send(embed=embed) + return + if "`" in prefix: embed = discord.Embed(title="Error", color=Colors.Error) embed.add_field(name="Invalid prefix", value='Prefix can not contain " ` "') diff --git a/ClemBot.Bot/bot/consts.py b/ClemBot.Bot/bot/consts.py index c0c8dd97..762175c8 100644 --- a/ClemBot.Bot/bot/consts.py +++ b/ClemBot.Bot/bot/consts.py @@ -97,3 +97,4 @@ class Moderation: TAG_INVOKE_REGEX = r"{tag_prefix}([^\s]+)" +INVALID_PREFIXES = ["<"]