From 5930f490ce29214b0c898d4a0322b2da8dc32c39 Mon Sep 17 00:00:00 2001 From: Ske Date: Fri, 7 Sep 2018 17:40:02 +0200 Subject: [PATCH] Add character limit to descriptions. Closes #14 --- src/pluralkit/bot/commands/member_commands.py | 4 ++++ src/pluralkit/bot/commands/system_commands.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/pluralkit/bot/commands/member_commands.py b/src/pluralkit/bot/commands/member_commands.py index 7bd622cd..a5d3afac 100644 --- a/src/pluralkit/bot/commands/member_commands.py +++ b/src/pluralkit/bot/commands/member_commands.py @@ -63,6 +63,10 @@ async def member_set(ctx: CommandContext): if bounds_error: return CommandError(bounds_error) + if prop == "description": + if len(value) > 1024: + return CommandError("You can't have a description longer than 1024 characters.") + if prop == "color": match = re.fullmatch("#?([0-9A-Fa-f]{6})", value) if not match: diff --git a/src/pluralkit/bot/commands/system_commands.py b/src/pluralkit/bot/commands/system_commands.py index cc23f4db..914a2724 100644 --- a/src/pluralkit/bot/commands/system_commands.py +++ b/src/pluralkit/bot/commands/system_commands.py @@ -59,6 +59,10 @@ async def system_set(ctx: CommandContext): if ctx.has_next(): value = ctx.remaining() # Sanity checking + if prop == "description": + if len(value) > 1024: + return CommandError("You can't have a description longer than 1024 characters.") + if prop == "tag": if len(value) > 32: return CommandError("You can't have a system tag longer than 32 characters.")