diff --git a/GoBot/discord/modules/invite.go b/GoBot/discord/modules/invite.go index 404ce1c..3db573f 100644 --- a/GoBot/discord/modules/invite.go +++ b/GoBot/discord/modules/invite.go @@ -8,6 +8,7 @@ import ( "TerraOceanBot/db" "TerraOceanBot/discord/config" + "TerraOceanBot/server" ) var pendingInviteConfirmation = make(map[string]invite) @@ -175,4 +176,5 @@ func CheckForInvite(s *discordgo.Session, r *discordgo.MessageReactionAdd) { s.MessageReactionAdd(config.VoteChannel, msg.ID, emojiFour) s.MessageReactionAdd(config.VoteChannel, msg.ID, emojiFive) s.MessageReactionAdd(config.VoteChannel, msg.ID, emojiCheck) + server.VoteNotification() } diff --git a/GoBot/discord/modules/minecraft.go b/GoBot/discord/modules/minecraft.go index 174a15a..ff071e3 100644 --- a/GoBot/discord/modules/minecraft.go +++ b/GoBot/discord/modules/minecraft.go @@ -4,7 +4,9 @@ import ( "github.com/bwmarrin/discordgo" "TerraOceanBot/db" + "TerraOceanBot/discord/backend" "TerraOceanBot/discord/config" + "TerraOceanBot/server" ) var minecraftConfirmReact = make(map[string]string) @@ -66,6 +68,7 @@ func ConfirmMinecraftUsername(s *discordgo.Session, r *discordgo.MessageReaction } func processUsernameUpdate(s *discordgo.Session, discordID, channelID, newUsername string) { + oldUsername, oldErr := db.GetMinecraftUsername(discordID) err := db.SetMinecraftUsername(discordID, newUsername) if err == db.ErrAlreadyExists { initNewEmbed( @@ -75,6 +78,12 @@ func processUsernameUpdate(s *discordgo.Session, discordID, channelID, newUserna ).Send(s, channelID) return } + + backend.UpdateVoiceChannelState(s) + if oldErr == nil { + server.WhitelistRemove(oldUsername) + } + initNewEmbed( config.SetMCUsernameSuccessTitle, config.SetMCUsernameSuccessDescription, diff --git a/GoBot/discord/modules/vote.go b/GoBot/discord/modules/vote.go index 0d85ce0..f96ecf1 100644 --- a/GoBot/discord/modules/vote.go +++ b/GoBot/discord/modules/vote.go @@ -3,6 +3,7 @@ package modules import "github.com/bwmarrin/discordgo" type voteType struct { + //TODO Add FormatName(name string) to clean up vote name EmbedBuilder func(id int, name string) *embed ResultHandler func(s *discordgo.Session, id int, name string, isPositive bool) } diff --git a/GoBot/discord/modules/vote_listener.go b/GoBot/discord/modules/vote_listener.go index 7174a45..0e72a5a 100644 --- a/GoBot/discord/modules/vote_listener.go +++ b/GoBot/discord/modules/vote_listener.go @@ -9,6 +9,7 @@ import ( "TerraOceanBot/db" "TerraOceanBot/discord/config" + "TerraOceanBot/server" ) const ( @@ -132,6 +133,7 @@ func VoteSuggestion(s *discordgo.Session, m *discordgo.MessageCreate) { s.MessageReactionAdd(config.VoteChannel, msg.ID, emojiThree) s.MessageReactionAdd(config.VoteChannel, msg.ID, emojiFour) s.MessageReactionAdd(config.VoteChannel, msg.ID, emojiFive) + server.VoteNotification() default: initNewEmbed( config.VoteSuggestionErrorTitle, diff --git a/GoBot/server/hub.go b/GoBot/server/hub.go index bfd37ff..14de4d4 100644 --- a/GoBot/server/hub.go +++ b/GoBot/server/hub.go @@ -50,3 +50,15 @@ func DisconnectUser(mcUsername string) { func RequestSync() { broadcast("sync") } + +func VoteNotification() { + broadcast("vote") +} + +func WhitelistAdd(minecraftUsername string) { + broadcast("whitelistadd " + minecraftUsername) +} + +func WhitelistRemove(minecraftUsername string) { + broadcast("whitelistremove " + minecraftUsername) +}