From f1a79fb65a98c4c483b3e77dfb1c910c8702165b Mon Sep 17 00:00:00 2001 From: PureFunctor Date: Thu, 25 Jun 2020 23:47:30 +0800 Subject: Add offset validation --- bot/exts/evergreen/fun.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index 75b0e2b0..364ce74b 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -154,7 +154,10 @@ class Fun(Cog): Also accepts a valid Discord Message ID or link. """ - await self._caesar_cipher(ctx, offset, text) + if offset < 0: + await ctx.send(":no_entry: Cannot use a negative offset.") + else: + await self._caesar_cipher(ctx, offset, text) @caesarcipher_group.command(name="decrypt", aliases=("leftshift", "lshift")) async def caesarcipher_decrypt(self, ctx: Context, offset: int, *, text: str) -> None: @@ -165,7 +168,10 @@ class Fun(Cog): Also accepts a valid Discord Message ID or link. """ - await self._caesar_cipher(ctx, -offset, text) + if offset < 0: + await ctx.send(":no_entry: Cannot use a negative offset.") + else: + await self._caesar_cipher(ctx, -offset, text) @staticmethod async def _get_text_and_embed(ctx: Context, text: str) -> Tuple[str, Union[Embed, None]]: -- cgit v1.2.3