diff --git a/main.py b/main.py index 3180474..720eaaf 100644 --- a/main.py +++ b/main.py @@ -52,7 +52,17 @@ async def on_ready(): @bot.command() async def grant_role(ctx, study_group_name: str): - author_id = ctx.author.id + # Check study group format + if not words[1].startswith('kruh-') or not words[1][5:].isdigit(): + reply_error(ctx, 'Invalid study group format.') + reply(ctx, HELP_MESSAGE) + return False + + # Check UKCO format + if not words[2].isdigit() or not len(words[2]) == 8: + reply_error(ctx, 'Invalid UKCO format.') + reply(ctx, HELP_MESSAGE) + return False for guild_id in server_ids: guild = bot.get_guild(guild_id) @@ -104,17 +114,6 @@ def check_command(message): reply(message.channel, HELP_MESSAGE) return False - # Check study group format - if not words[1].startswith('kruh-') or not words[1][5:].isdigit(): - reply_error(message.channel, 'Invalid study group format.') - reply(message.channel, HELP_MESSAGE) - return False - - if not words[2].isdigit() or not len(words[2]) == 8: - reply_error(message.channel, 'Invalid UKCO format.') - reply(message.channel, HELP_MESSAGE) - return False - return True