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:
@@ -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.
|
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
|
## 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.
|
Please use the issue tracker.
|
||||||
|
|||||||
@@ -707,11 +707,23 @@ func onMessageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
go enqueuePlay(m.Author, guild, coll, sound)
|
go enqueuePlay(m.Author, guild, coll, sound)
|
||||||
|
go deleteCommandMessage(s, m.ChannelID, m.ID)
|
||||||
return
|
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() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
Token = flag.String("t", "", "Discord Authentication Token")
|
Token = flag.String("t", "", "Discord Authentication Token")
|
||||||
|
|||||||
Reference in New Issue
Block a user