feat(commands/voice/queue): add immutability checks
This commit is contained in:
parent
b0e378105e
commit
74629ad984
@ -12,10 +12,6 @@ from state import client, players
|
||||
|
||||
|
||||
async def queue_or_play(message, edited=False):
|
||||
await ensure_joined(message)
|
||||
if not command_allowed(message):
|
||||
return
|
||||
|
||||
if message.guild.id not in players:
|
||||
players[message.guild.id] = youtubedl.QueuedPlayer()
|
||||
|
||||
@ -73,6 +69,13 @@ async def queue_or_play(message, edited=False):
|
||||
if not (args := await parser.parse_args(message, tokens)):
|
||||
return
|
||||
|
||||
await ensure_joined(message)
|
||||
if len(tokens) == 1 and tokens[0].lower() != "play":
|
||||
if not command_allowed(message, immutable=True):
|
||||
return
|
||||
elif not command_allowed(message):
|
||||
return
|
||||
|
||||
if edited:
|
||||
found = None
|
||||
for queued in players[message.guild.id].queue:
|
||||
@ -162,8 +165,7 @@ async def queue_or_play(message, edited=False):
|
||||
message,
|
||||
f"**{len(players[message.guild.id].queue)}.** {queued.format()}",
|
||||
)
|
||||
else:
|
||||
if tokens[0].lower() == "play":
|
||||
elif tokens[0].lower() == "play":
|
||||
await resume(message)
|
||||
else:
|
||||
if players[message.guild.id].queue:
|
||||
@ -419,7 +421,7 @@ async def ensure_joined(message):
|
||||
if message.author.voice:
|
||||
await message.author.voice.channel.connect()
|
||||
else:
|
||||
await utils.reply(message, "You are not connected to a voice channel.")
|
||||
await utils.reply(message, "you are not connected to a voice channel!")
|
||||
|
||||
|
||||
def command_allowed(message, immutable=False):
|
||||
|
Loading…
x
Reference in New Issue
Block a user