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.
This commit is contained in:
parent
525aea3f05
commit
08fa83f1f9
1 changed files with 1 additions and 1 deletions
|
@ -9,7 +9,7 @@ async def command_dice(room: MatrixRoom, event: RoomMessageText, bot):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sides = int(event.body.split()[2])
|
sides = int(event.body.split()[2])
|
||||||
except ValueError:
|
except (ValueError, IndexError):
|
||||||
sides = 6
|
sides = 6
|
||||||
|
|
||||||
if sides < 2:
|
if sides < 2:
|
||||||
|
|
Loading…
Reference in a new issue