From 08fa83f1f9c38d6844f50d3d58b40a906229317b Mon Sep 17 00:00:00 2001 From: Kumi Date: Sun, 18 Aug 2024 10:54:03 +0200 Subject: [PATCH] fix(dice): handle missing dice roll parameter Adjust exception handling to catch both ValueError and IndexError. This ensures the command gracefully defaults to 6 sides when input parameters are insufficient or improperly formatted. Improves robustness against user errors. --- src/gptbot/commands/dice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gptbot/commands/dice.py b/src/gptbot/commands/dice.py index 5d14eb5..fe0823d 100644 --- a/src/gptbot/commands/dice.py +++ b/src/gptbot/commands/dice.py @@ -9,7 +9,7 @@ async def command_dice(room: MatrixRoom, event: RoomMessageText, bot): try: sides = int(event.body.split()[2]) - except ValueError: + except (ValueError, IndexError): sides = 6 if sides < 2: