Skip to content

Commit 306a1df

Browse files
authored
Add missing exceptions when attempting to move entities before selecting (#2797)
1 parent 8db132c commit 306a1df

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/net/dv8tion/jda/internal/requests/restaction/order/OrderActionImpl.java

+4
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ public M moveTo(int position)
208208
{
209209
Checks.notNegative(position, "Provided position");
210210
Checks.check(position < orderList.size(), "Provided position is too big and is out of bounds.");
211+
if (selectedPosition == -1)
212+
throw new IllegalStateException("Cannot move until an item has been selected. Use #selectPosition first.");
211213

212214
T selectedItem = orderList.remove(selectedPosition);
213215
orderList.add(position, selectedItem);
@@ -250,6 +252,8 @@ public M swapPosition(int swapPosition)
250252
Checks.notNegative(swapPosition, "Provided swapPosition");
251253
Checks.check(swapPosition < orderList.size(), "Provided swapPosition is too big and is out of bounds. swapPosition: "
252254
+ swapPosition);
255+
if (selectedPosition == -1)
256+
throw new IllegalStateException("Cannot move until an item has been selected. Use #selectPosition first.");
253257

254258
T selectedItem = orderList.get(selectedPosition);
255259
T swapItem = orderList.get(swapPosition);

0 commit comments

Comments
 (0)