fix (setprofile): Add check for max tasks.

This commit is contained in:
2021-12-29 20:49:49 +02:00
parent 46bf03ae25
commit c519725755

View File

@@ -12,7 +12,7 @@ from .data import profile_tags
from .module import module from .module import module
MAX_TAGS = 5 MAX_TAGS = 10
MAX_LENGTH = 30 MAX_LENGTH = 30
@@ -33,8 +33,6 @@ async def cmd_setprofile(ctx, flags):
Description: Description:
Set or update the tags appearing in your study server profile. Set or update the tags appearing in your study server profile.
You can have at most `5` tags at once.
Moderators can clear a user's tags with `--clear --for @user`. Moderators can clear a user's tags with `--clear --for @user`.
Examples``: Examples``:
{prefix}setprofile Mathematics, Bioloyg, Medicine, Undergraduate, Europe {prefix}setprofile Mathematics, Bioloyg, Medicine, Undergraduate, Europe
@@ -147,6 +145,9 @@ async def cmd_setprofile(ctx, flags):
to_add = [split.strip().upper() for split in ctx.args.split(',')] to_add = [split.strip().upper() for split in ctx.args.split(',')]
validate_tag(*to_add) validate_tag(*to_add)
if len(to_add) > MAX_TAGS:
return await ctx.error_reply(f"You can have a maximum of {MAX_TAGS} tags!")
# Remove the existing badges # Remove the existing badges
deleted_rows = profile_tags.delete_where( deleted_rows = profile_tags.delete_where(
guildid=ctx.guild.id, guildid=ctx.guild.id,
@@ -181,7 +182,7 @@ async def cmd_setprofile(ctx, flags):
embed = discord.Embed( embed = discord.Embed(
colour=discord.Colour.red(), colour=discord.Colour.red(),
description=( description=(
"Use this command to edit your study profile " "Edit your study profile "
"tags so other people can see what you do!" "tags so other people can see what you do!"
) )
) )