feat(commands/voice/queue): replace queued song on message edit
This commit is contained in:
parent
186eda4934
commit
d5623502b0
@ -11,7 +11,7 @@ import youtubedl
|
|||||||
from state import client, players
|
from state import client, players
|
||||||
|
|
||||||
|
|
||||||
async def queue_or_play(message):
|
async def queue_or_play(message, edited=False):
|
||||||
await ensure_joined(message)
|
await ensure_joined(message)
|
||||||
if not command_allowed(message):
|
if not command_allowed(message):
|
||||||
return
|
return
|
||||||
@ -73,6 +73,15 @@ async def queue_or_play(message):
|
|||||||
if not (args := await parser.parse_args(message, tokens)):
|
if not (args := await parser.parse_args(message, tokens)):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if edited:
|
||||||
|
found = None
|
||||||
|
for queued in players[message.guild.id].queue:
|
||||||
|
if queued.trigger_message.id == message.id:
|
||||||
|
found = queued
|
||||||
|
break
|
||||||
|
if found:
|
||||||
|
players[message.guild.id].queue.remove(found)
|
||||||
|
|
||||||
if args.clear:
|
if args.clear:
|
||||||
players[message.guild.id].queue.clear()
|
players[message.guild.id].queue.clear()
|
||||||
await utils.add_check_reaction(message)
|
await utils.add_check_reaction(message)
|
||||||
|
4
core.py
4
core.py
@ -15,7 +15,7 @@ import utils
|
|||||||
from state import client, command_locks, executed_messages
|
from state import client, command_locks, executed_messages
|
||||||
|
|
||||||
|
|
||||||
async def on_message(message):
|
async def on_message(message, edited=False):
|
||||||
if not message.content.startswith(constants.PREFIX) or message.author.bot:
|
if not message.content.startswith(constants.PREFIX) or message.author.bot:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ async def on_message(message):
|
|||||||
await commands.voice.leave(message)
|
await commands.voice.leave(message)
|
||||||
case C.QUEUE | C.PLAY:
|
case C.QUEUE | C.PLAY:
|
||||||
async with command_locks[message.guild.id]:
|
async with command_locks[message.guild.id]:
|
||||||
await commands.voice.queue_or_play(message)
|
await commands.voice.queue_or_play(message, edited=True)
|
||||||
case C.SKIP:
|
case C.SKIP:
|
||||||
async with command_locks[message.guild.id]:
|
async with command_locks[message.guild.id]:
|
||||||
await commands.voice.skip(message)
|
await commands.voice.skip(message)
|
||||||
|
@ -28,7 +28,7 @@ async def on_message_edit(before, after):
|
|||||||
if before.content == after.content:
|
if before.content == after.content:
|
||||||
return
|
return
|
||||||
|
|
||||||
await core.on_message(after)
|
await core.on_message(after, edited=True)
|
||||||
|
|
||||||
|
|
||||||
async def on_voice_state_update(member, before, after):
|
async def on_voice_state_update(member, before, after):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user