fix(commands/voice/queue): don't allow negative indices

This commit is contained in:
2025-01-01 15:11:02 -05:00
parent 7e27c9158b
commit 2f0e849c84

View File

@@ -1,11 +1,12 @@
import math import math
import arguments import arguments
import commands
import utils
import youtubedl import youtubedl
from state import client, players from state import client, players
import commands
import utils
async def queue_or_play(message): async def queue_or_play(message):
await ensure_joined(message) await ensure_joined(message)
@@ -97,12 +98,13 @@ async def queue_or_play(message):
await utils.add_check_reaction(message) await utils.add_check_reaction(message)
return return
elif i := args.remove_index: elif i := args.remove_index:
try: if i <= 0 or i > len(players[message.guild.id].queue):
queued = players[message.guild.id].queue[i - 1]
del players[message.guild.id].queue[i - 1]
await utils.reply(message, f"**x** {queued.format()}")
except:
await utils.reply(message, "invalid index!") await utils.reply(message, "invalid index!")
return
queued = players[message.guild.id].queue[i - 1]
del players[message.guild.id].queue[i - 1]
await utils.reply(message, f"**x** {queued.format()}")
elif args.remove_title or args.remove_queuer: elif args.remove_title or args.remove_queuer:
targets = [] targets = []
for queued in players[message.guild.id].queue: for queued in players[message.guild.id].queue: