mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-09 20:58:54 -05:00
[V3 Audio] Queue clean and queue clear addition (#2476)
* [V3 Audio] Queue clean and queue clear addition * Use DJ role and existing checks inst. of mod/admin * Remove unneeded .format()
This commit is contained in:
parent
c7608aeb17
commit
80fc639480
@ -2051,7 +2051,7 @@ class Audio(commands.Cog):
|
|||||||
)
|
)
|
||||||
await ctx.send(embed=embed)
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
@commands.command()
|
@commands.group(invoke_without_command=True)
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def queue(self, ctx, *, page="1"):
|
async def queue(self, ctx, *, page="1"):
|
||||||
"""List the queue.
|
"""List the queue.
|
||||||
@ -2237,6 +2237,55 @@ class Audio(commands.Cog):
|
|||||||
)
|
)
|
||||||
return embed
|
return embed
|
||||||
|
|
||||||
|
@queue.command(name="clear")
|
||||||
|
@commands.guild_only()
|
||||||
|
async def _queue_clear(self, ctx):
|
||||||
|
"""Clears the queue."""
|
||||||
|
player = lavalink.get_player(ctx.guild.id)
|
||||||
|
dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
|
||||||
|
if not self._player_check(ctx) or not player.queue:
|
||||||
|
return await self._embed_msg(ctx, _("There's nothing in the queue."))
|
||||||
|
player = lavalink.get_player(ctx.guild.id)
|
||||||
|
if dj_enabled:
|
||||||
|
if not await self._can_instaskip(ctx, ctx.author) and not await self._is_alone(
|
||||||
|
ctx, ctx.author
|
||||||
|
):
|
||||||
|
return await self._embed_msg(ctx, _("You need the DJ role to clear the queue."))
|
||||||
|
player.queue.clear()
|
||||||
|
await self._embed_msg(ctx, _("The queue has been cleared."))
|
||||||
|
|
||||||
|
@queue.command(name="clean")
|
||||||
|
@commands.guild_only()
|
||||||
|
async def _queue_clean(self, ctx):
|
||||||
|
"""Removes songs from the queue if the requester is not in the voice channel."""
|
||||||
|
player = lavalink.get_player(ctx.guild.id)
|
||||||
|
dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
|
||||||
|
if not self._player_check(ctx) or not player.queue:
|
||||||
|
return await self._embed_msg(ctx, _("There's nothing in the queue."))
|
||||||
|
if dj_enabled:
|
||||||
|
if not await self._can_instaskip(ctx, ctx.author) and not await self._is_alone(
|
||||||
|
ctx, ctx.author
|
||||||
|
):
|
||||||
|
return await self._embed_msg(ctx, _("You need the DJ role to clean the queue."))
|
||||||
|
clean_tracks = []
|
||||||
|
removed_tracks = 0
|
||||||
|
listeners = player.channel.members
|
||||||
|
for track in player.queue:
|
||||||
|
if track.requester in listeners:
|
||||||
|
clean_tracks.append(track)
|
||||||
|
else:
|
||||||
|
removed_tracks += 1
|
||||||
|
player.queue = clean_tracks
|
||||||
|
if removed_tracks == 0:
|
||||||
|
await self._embed_msg(ctx, _("Removed 0 tracks."))
|
||||||
|
else:
|
||||||
|
await self._embed_msg(
|
||||||
|
ctx,
|
||||||
|
_(
|
||||||
|
"Removed {removed_tracks} tracks queued by members outside of the voice channel."
|
||||||
|
).format(removed_tracks=removed_tracks),
|
||||||
|
)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@commands.guild_only()
|
@commands.guild_only()
|
||||||
async def repeat(self, ctx):
|
async def repeat(self, ctx):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user