From f17522a5d1f286fcdc4a728ac1e79705b1b9e828 Mon Sep 17 00:00:00 2001 From: r4 Date: Wed, 28 Jul 2021 19:10:57 +0200 Subject: [PATCH] some code simplifications --- commands.go | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/commands.go b/commands.go index ff373dc..0ed7ae7 100644 --- a/commands.go +++ b/commands.go @@ -62,10 +62,10 @@ func secsToMinsSecs(secs int) string { // Removes/replaces some characters with special formatting meaning in discord // messages (for example *). func dcSanitize(in string) string { - in = strings.ReplaceAll(in, "*", "\u2217") - in = strings.ReplaceAll(in, "~~", "\u02dc\u02dc") - in = strings.ReplaceAll(in, "`", "'") - return strings.ReplaceAll(in, "||", "\u2758\u2758") + in = strings.ReplaceAll(in, "*", "\\*") + in = strings.ReplaceAll(in, "~~", "\\~\\~") + in = strings.ReplaceAll(in, "`", "\\`") + return strings.ReplaceAll(in, "||", "\\|\\|") } //////////////////////////////// @@ -240,18 +240,12 @@ func commandAdd(c *Client, args []string, inPlace bool) { MediaUrl: mediaUrl, } if inPlace && !isPlaylist { + // To replace the currently playing track (if one is currently + // playing), insert the new one at Queue[0] and skip the current + // one. + c.QueuePushFront(track) if playback, ok := c.GetPlaybackInfo(); ok { - // To replace the currently playing track, insert the new one - // at Queue[0] and skip the current one. - if c.QueueLen() == 0 { - c.QueuePushBack(track) - } else { - c.QueuePushFront(track) - } - // Skip the current track. playback.CmdCh <- dca0.CommandStop{} - } else { - c.QueuePushFront(track) } } else { c.QueuePushBack(track)