Add swipe id validation for /delswipe

This commit is contained in:
Cohee 2023-11-21 23:33:20 +02:00
parent 284bd76589
commit 1b4d955aec
1 changed files with 6 additions and 0 deletions

View File

@ -176,6 +176,12 @@ async function deleteSwipeCallback(_, arg) {
} }
const swipeId = arg && !isNaN(Number(arg)) ? (Number(arg) - 1) : lastMessage.swipe_id; const swipeId = arg && !isNaN(Number(arg)) ? (Number(arg) - 1) : lastMessage.swipe_id;
if (swipeId < 0 || swipeId >= lastMessage.swipes.length) {
toastr.warning(`Invalid swipe ID: ${swipeId + 1}`);
return;
}
lastMessage.swipes.splice(swipeId, 1); lastMessage.swipes.splice(swipeId, 1);
if (Array.isArray(lastMessage.swipe_info) && lastMessage.swipe_info.length) { if (Array.isArray(lastMessage.swipe_info) && lastMessage.swipe_info.length) {