new attempt to add clearQueue()
This commit is contained in:
@@ -20,6 +20,7 @@ import (
|
|||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/bwmarrin/discordgo"
|
"github.com/bwmarrin/discordgo"
|
||||||
humanize "github.com/dustin/go-humanize"
|
humanize "github.com/dustin/go-humanize"
|
||||||
|
"os/user"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -369,6 +370,17 @@ func playSound(play *Play, vc *discordgo.VoiceConnection) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func clearQueue(user *discordgo.User) {
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"user": user,
|
||||||
|
}).Info(user.Username + " triggered queue clearing")
|
||||||
|
for key, _ := range queues {
|
||||||
|
delete(queues, key)
|
||||||
|
}
|
||||||
|
discord.Close()
|
||||||
|
discord.Open()
|
||||||
|
}
|
||||||
|
|
||||||
func onReady(s *discordgo.Session, event *discordgo.Ready) {
|
func onReady(s *discordgo.Session, event *discordgo.Ready) {
|
||||||
log.Info("Received READY payload.")
|
log.Info("Received READY payload.")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,11 @@ func handlePlaySound(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
if user != nil && guild != nil && soundCollection != nil {
|
if user != nil && guild != nil && soundCollection != nil {
|
||||||
if sound != nil {
|
if sound != nil {
|
||||||
|
if sound.Name == "clearqueue" && soundCollection.Prefix == "1" {
|
||||||
|
clearQueue()
|
||||||
|
} else {
|
||||||
go enqueuePlay(user, guild, soundCollection, sound)
|
go enqueuePlay(user, guild, soundCollection, sound)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
go enqueuePlay(user, guild, soundCollection, soundCollection.Random())
|
go enqueuePlay(user, guild, soundCollection, soundCollection.Random())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user