Add /shuffle command

Signed-off-by: mctaylors <cantsendmails@mctaylors.ru>
This commit is contained in:
Macintxsh 2023-12-21 17:07:49 +03:00
parent 7337bc4024
commit 090d3e426d
Signed by: mctaylors
GPG key ID: 7181BEBE676903C1
2 changed files with 28 additions and 2 deletions

View file

@ -165,6 +165,27 @@ public sealed class ControlsCommandGroup(
feedbackService.Theme.Success);
}
[Command("shuffle")]
[Description("Changes player repeat mode")]
[DiscordDefaultDMPermission(false)]
[UsedImplicitly]
public async Task<Result> ShuffleCommandAsync(
[Description("Enable shuffle mode")] bool enable)
{
var player = await LavalinkPlayer.GetPlayerAsync(
commandContext, audioService, feedbackService);
if (player is null)
{
return Result.FromSuccess();
}
player.Shuffle = enable;
return await feedbackService.SendContextualMessageResult(
$"Shuffle mode is now {Markdown.Bold(enable ? "enabled" : "disabled")}",
feedbackService.Theme.Success);
}
[Command("seek")]
[Description("Rewinds the current track to a specific position")]
[DiscordDefaultDMPermission(false)]

View file

@ -84,15 +84,20 @@ public sealed class InfoCommandGroup(
var repeatMode = player.RepeatMode;
if (repeatMode is not TrackRepeatMode.None)
{
builder.AppendLine($"> The current repeat mode is set to {Markdown.Bold(repeatMode.ToString())}");
builder.AppendLine($"> Repeat mode was set to {Markdown.Bold(repeatMode.ToString())}");
}
if (repeatMode is TrackRepeatMode.Track)
{
builder.AppendLine("Use **/nowplaying** to show current playing track");
builder.AppendLine($"Use {Markdown.Bold("/nowplaying")} to show current playing track");
return Result.FromSuccess();
}
if (player.Shuffle)
{
builder.AppendLine($"> Shuffle mode was {Markdown.Bold("enabled")}");
}
for (var i = 0; i < queue.Count; i++)
{
var track = queue[i].Track;