|
|
|
@ -9,28 +9,25 @@ import (
|
|
|
|
|
"TerraOceanBot/server"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func UpdateVoiceChannelState(s *discordgo.Session) {
|
|
|
|
|
for _, guild := range s.State.Guilds {
|
|
|
|
|
if guild.ID != config.GuildID {
|
|
|
|
|
func UpdateVoiceChannelState(s *discordgo.Session, guild *discordgo.GuildCreate) {
|
|
|
|
|
if guild.ID != config.GuildID {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
for _, vs := range guild.VoiceStates {
|
|
|
|
|
if vs.ChannelID != config.VoiceChannel {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if vs.Deaf || vs.SelfDeaf {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
for _, vs := range guild.VoiceStates {
|
|
|
|
|
if vs.ChannelID != config.VoiceChannel {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if vs.Deaf || vs.SelfDeaf {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
username, err := db.GetMinecraftUsername(vs.UserID)
|
|
|
|
|
if err == db.ErrNotFound {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
message.AuditError(s, "", err)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
server.ConnectUser(username)
|
|
|
|
|
username, err := db.GetMinecraftUsername(vs.UserID)
|
|
|
|
|
if err == db.ErrNotFound {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
if err != nil {
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
server.ConnectUser(username)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|