Song/playlist is now skipped when submitter skips
This commit is contained in:
parent
3ecee614ca
commit
2393727137
20
commands.go
20
commands.go
|
@ -241,12 +241,16 @@ func skip(user *gumble.User, username string, admin, playlistSkip bool) {
|
||||||
if playlistSkip {
|
if playlistSkip {
|
||||||
if dj.queue.CurrentSong().playlist != nil {
|
if dj.queue.CurrentSong().playlist != nil {
|
||||||
if err := dj.queue.CurrentSong().playlist.AddSkip(username); err == nil {
|
if err := dj.queue.CurrentSong().playlist.AddSkip(username); err == nil {
|
||||||
|
submitterSkipped := false
|
||||||
if admin {
|
if admin {
|
||||||
dj.client.Self.Channel.Send(ADMIN_PLAYLIST_SKIP_MSG, false)
|
dj.client.Self.Channel.Send(ADMIN_PLAYLIST_SKIP_MSG, false)
|
||||||
|
} else if dj.queue.CurrentSong().submitter == username {
|
||||||
|
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SUBMITTER_SKIP_HTML, username), false)
|
||||||
|
submitterSkipped = true
|
||||||
} else {
|
} else {
|
||||||
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SKIP_ADDED_HTML, username), false)
|
dj.client.Self.Channel.Send(fmt.Sprintf(PLAYLIST_SKIP_ADDED_HTML, username), false)
|
||||||
}
|
}
|
||||||
if dj.queue.CurrentSong().playlist.SkipReached(len(dj.client.Self.Channel.Users)) || admin {
|
if submitterSkipped || dj.queue.CurrentSong().playlist.SkipReached(len(dj.client.Self.Channel.Users)) || admin {
|
||||||
id := dj.queue.CurrentSong().playlist.id
|
id := dj.queue.CurrentSong().playlist.id
|
||||||
dj.queue.CurrentSong().playlist.DeleteSkippers()
|
dj.queue.CurrentSong().playlist.DeleteSkippers()
|
||||||
for i := 0; i < len(dj.queue.queue); i++ {
|
for i := 0; i < len(dj.queue.queue); i++ {
|
||||||
|
@ -261,7 +265,9 @@ func skip(user *gumble.User, username string, admin, playlistSkip bool) {
|
||||||
// Set dontSkip to true to avoid audioStream.Stop() callback skipping the new first song.
|
// Set dontSkip to true to avoid audioStream.Stop() callback skipping the new first song.
|
||||||
dj.queue.CurrentSong().dontSkip = true
|
dj.queue.CurrentSong().dontSkip = true
|
||||||
}
|
}
|
||||||
dj.client.Self.Channel.Send(PLAYLIST_SKIPPED_HTML, false)
|
if !(submitterSkipped || admin) {
|
||||||
|
dj.client.Self.Channel.Send(PLAYLIST_SKIPPED_HTML, false)
|
||||||
|
}
|
||||||
if err := dj.audioStream.Stop(); err != nil {
|
if err := dj.audioStream.Stop(); err != nil {
|
||||||
panic(errors.New("An error occurred while stopping the current song."))
|
panic(errors.New("An error occurred while stopping the current song."))
|
||||||
}
|
}
|
||||||
|
@ -272,13 +278,19 @@ func skip(user *gumble.User, username string, admin, playlistSkip bool) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := dj.queue.CurrentSong().AddSkip(username); err == nil {
|
if err := dj.queue.CurrentSong().AddSkip(username); err == nil {
|
||||||
|
submitterSkipped := false
|
||||||
if admin {
|
if admin {
|
||||||
dj.client.Self.Channel.Send(ADMIN_SONG_SKIP_MSG, false)
|
dj.client.Self.Channel.Send(ADMIN_SONG_SKIP_MSG, false)
|
||||||
|
} else if dj.queue.CurrentSong().submitter == username {
|
||||||
|
dj.client.Self.Channel.Send(fmt.Sprintf(SUBMITTER_SKIP_HTML, username), false)
|
||||||
|
submitterSkipped = true
|
||||||
} else {
|
} else {
|
||||||
dj.client.Self.Channel.Send(fmt.Sprintf(SKIP_ADDED_HTML, username), false)
|
dj.client.Self.Channel.Send(fmt.Sprintf(SKIP_ADDED_HTML, username), false)
|
||||||
}
|
}
|
||||||
if dj.queue.CurrentSong().SkipReached(len(dj.client.Self.Channel.Users)) || admin {
|
if submitterSkipped || dj.queue.CurrentSong().SkipReached(len(dj.client.Self.Channel.Users)) || admin {
|
||||||
dj.client.Self.Channel.Send(SONG_SKIPPED_HTML, false)
|
if !(submitterSkipped || admin) {
|
||||||
|
dj.client.Self.Channel.Send(SONG_SKIPPED_HTML, false)
|
||||||
|
}
|
||||||
if err := dj.audioStream.Stop(); err != nil {
|
if err := dj.audioStream.Stop(); err != nil {
|
||||||
panic(errors.New("An error occurred while stopping the current song."))
|
panic(errors.New("An error occurred while stopping the current song."))
|
||||||
}
|
}
|
||||||
|
|
10
strings.go
10
strings.go
|
@ -155,11 +155,21 @@ const SKIP_ADDED_HTML = `
|
||||||
<b>%s</b> has voted to skip the current song.
|
<b>%s</b> has voted to skip the current song.
|
||||||
`
|
`
|
||||||
|
|
||||||
|
// Message shown to users when the submitter of a song decides to skip their song.
|
||||||
|
const SUBMITTER_SKIP_HTML = `
|
||||||
|
The current song has been skipped by <b>%s</b>, the submitter.
|
||||||
|
`
|
||||||
|
|
||||||
// Message shown to users when another user votes to skip the current playlist.
|
// Message shown to users when another user votes to skip the current playlist.
|
||||||
const PLAYLIST_SKIP_ADDED_HTML = `
|
const PLAYLIST_SKIP_ADDED_HTML = `
|
||||||
<b>%s</b> has voted to skip the current playlist.
|
<b>%s</b> has voted to skip the current playlist.
|
||||||
`
|
`
|
||||||
|
|
||||||
|
// Message shown to users when the submitter of a song decides to skip their song.
|
||||||
|
const PLAYLIST_SUBMITTER_SKIP_HTML = `
|
||||||
|
The current playlist has been skipped by <b>%s</b>, the submitter.
|
||||||
|
`
|
||||||
|
|
||||||
// Message shown to users when they successfully change the volume.
|
// Message shown to users when they successfully change the volume.
|
||||||
const VOLUME_SUCCESS_HTML = `
|
const VOLUME_SUCCESS_HTML = `
|
||||||
<b>%s</b> has changed the volume to <b>%.2f</b>.
|
<b>%s</b> has changed the volume to <b>%.2f</b>.
|
||||||
|
|
Reference in a new issue