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:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user