Deleting voice commands from channel

Voice commands will now be deletedd from channel after 30 seconds. It happens quite often that the bot gets a voice channel time out if it is used heavily by 2 users. I suspect enqueuePlay to be the cause of that.
This commit is contained in:
da
2017-01-08 14:57:26 +01:00
parent 0525062e3f
commit b04eaf6978
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -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.
+12
View File
@@ -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")