Skip to content

Commit bf7bc1e

Browse files
author
Mg Grignard
committed
Merge branch 'audio-repeatcurrent' into audio-keepinqueue
2 parents bf06613 + c8e7061 commit bf7bc1e

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

redbot/cogs/audio/core/commands/controller.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ async def command_now(self, ctx: commands.Context):
142142
+ ": "
143143
+ ("\N{WHITE HEAVY CHECK MARK}" if repeat else "\N{CROSS MARK}")
144144
)
145+
text += (
146+
(" | " if text else "")
147+
+ _("Repeat Current")
148+
+ ": "
149+
+ ("\N{WHITE HEAVY CHECK MARK}" if player.repeat_current else "\N{CROSS MARK}")
150+
)
145151

146152
message = await self.send_embed_msg(ctx, embed=embed, footer=text)
147153

@@ -784,6 +790,46 @@ async def command_repeat(self, ctx: commands.Context):
784790
if self._player_check(ctx):
785791
await self.set_player_settings(ctx)
786792

793+
@commands.command(name="repeatcurrent")
794+
@commands.guild_only()
795+
@commands.bot_has_permissions(embed_links=True)
796+
async def command_repeat_current(self, ctx: commands.Context):
797+
"""Toggle repeat current."""
798+
dj_enabled = self._dj_status_cache.setdefault(
799+
ctx.guild.id, await self.config.guild(ctx.guild).dj_enabled()
800+
)
801+
can_skip = await self._can_instaskip(ctx, ctx.author)
802+
if dj_enabled and not can_skip and not await self._has_dj_role(ctx, ctx.author):
803+
return await self.send_embed_msg(
804+
ctx,
805+
title=_("Unable To Toggle Repeat Current"),
806+
description=_("You need the DJ role to toggle repeat current."),
807+
)
808+
if not self._player_check(ctx):
809+
return await self.send_embed_msg(
810+
ctx,
811+
title=_("Unable To Toggle Repeat Current"),
812+
description=_("Nothing playing."),
813+
)
814+
815+
await self.set_player_settings(ctx)
816+
player = lavalink.get_player(ctx.guild.id)
817+
if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip:
818+
return await self.send_embed_msg(
819+
ctx,
820+
title=_("Unable To Toggle Repeat Current"),
821+
description=_("You must be in the voice channel to toggle repeat current."),
822+
)
823+
player.store("notify_channel", ctx.channel.id)
824+
825+
msg = _("Repeat current track: {true_or_false}.").format(
826+
true_or_false=_("Enabled") if not player.repeat_current else _("Disabled")
827+
)
828+
player.repeat_current = not player.repeat_current
829+
830+
embed = discord.Embed(title=_("Setting Changed"), description=msg)
831+
await self.send_embed_msg(ctx, embed=embed)
832+
787833
@commands.command(name="remove")
788834
@commands.guild_only()
789835
@commands.bot_has_permissions(embed_links=True)

redbot/cogs/audio/core/commands/queue.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ async def _queue_menu(
106106
+ ": "
107107
+ ("\N{WHITE HEAVY CHECK MARK}" if repeat else "\N{CROSS MARK}")
108108
)
109+
text += (
110+
(" | " if text else "")
111+
+ _("Repeat Current")
112+
+ ": "
113+
+ ("\N{WHITE HEAVY CHECK MARK}" if player.repeat_current else "\N{CROSS MARK}")
114+
)
109115
embed.set_footer(text=text)
110116
message = await self.send_embed_msg(ctx, embed=embed)
111117
dj_enabled = self._dj_status_cache.setdefault(ctx.guild.id, guild_data["dj_enabled"])

redbot/cogs/audio/core/utilities/player.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ async def is_requester(self, ctx: commands.Context, member: discord.Member) -> b
127127

128128
async def _skip_action(self, ctx: commands.Context, skip_to_track: int = None) -> None:
129129
player = lavalink.get_player(ctx.guild.id)
130+
player.repeat_current = False
130131
autoplay = await self.config.guild(player.guild).auto_play()
131132
if not player.current or (not player.queue and not autoplay):
132133
try:

redbot/cogs/audio/core/utilities/queue.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ async def _build_queue_page(
110110
+ ": "
111111
+ ("\N{WHITE HEAVY CHECK MARK}" if repeat else "\N{CROSS MARK}")
112112
)
113+
text += (
114+
(" | " if text else "")
115+
+ _("Repeat Current")
116+
+ ": "
117+
+ ("\N{WHITE HEAVY CHECK MARK}" if player.repeat_current else "\N{CROSS MARK}")
118+
)
113119
embed.set_footer(text=text)
114120
return embed
115121

0 commit comments

Comments
 (0)