diff --git a/README.md b/README.md index 68b5324..66dc3b9 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,6 @@ Typing only the `!command` without an argument results in a random sound of this The idea is to be able to have a detailed listing of available sound files in a responsive interface and a simple button to trigger the sound playback in a channel. ## Known issues -- None that I know of. +- enqueuePlay is not 99% of the time "OK", enqueueing has to be redesigned threadsafe. Please use the issue tracker. diff --git a/main.go b/main.go index c2ab6c1..1e12443 100644 --- a/main.go +++ b/main.go @@ -707,11 +707,23 @@ func onMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { } go enqueuePlay(m.Author, guild, coll, sound) + go deleteCommandMessage(s, m.ChannelID, m.ID) return } } } +// Delete the message after a delay so the channel does not get cluttered +func deleteCommandMessage(s *discordgo.Session, channelID string, messageID string) { + time.Sleep(30 * time.Second) + err := s.ChannelMessageDelete(channelID, messageID) + if err != nil { + log.WithFields(log.Fields{ + "error": err, + }).Error("Failed to delete message.") + } +} + func main() { var ( Token = flag.String("t", "", "Discord Authentication Token")