rf: command argument checks in command function
This commit is contained in:
parent
a4cf15ce1d
commit
16f26119aa
1 changed files with 11 additions and 12 deletions
23
main.py
23
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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue