Skip to content

Commit

Permalink
Hotfix issue with setting voice rules
Browse files Browse the repository at this point in the history
  • Loading branch information
denverquane committed May 14, 2024
1 parent 6744d1c commit 6354b55
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 1 addition & 7 deletions bot/setting/voiceRules.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,7 @@ func FnVoiceRules(sett *settings.GuildSettings, args []string) (interface{}, boo
}), false
}

var oldValue bool
if args[0] == "muted" {
oldValue = sett.GetVoiceRule(true, gamePhase, args[0])
} else {
oldValue = sett.GetVoiceRule(false, gamePhase, args[0])
}
oldValue := sett.GetVoiceRule(args[0] == "muted", gamePhase, args[2])

if len(args) == 3 {
// User was only querying
Expand All @@ -72,7 +67,6 @@ func FnVoiceRules(sett *settings.GuildSettings, args []string) (interface{}, boo
}), false
}
}

newValue := args[3] == "true"

if newValue == oldValue {
Expand Down
4 changes: 4 additions & 0 deletions bot/setting/voiceRules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,8 @@ func TestFnVoiceRules(t *testing.T) {
if !valid {
t.Error("Valid VR rules should result in a valid settings change")
}

if sett.VoiceRules.DeafRules[game.PhaseNames[game.LOBBY]]["alive"] == false {
t.Error("Valid VR rule change was not changed successfully!")
}
}
3 changes: 2 additions & 1 deletion pkg/settings/guild_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,9 @@ func (gs *GuildSettings) GetVoiceRule(isMute bool, phase game.Phase, alive strin
func (gs *GuildSettings) SetVoiceRule(isMute bool, phase game.Phase, alive string, val bool) {
if isMute {
gs.VoiceRules.MuteRules[phase.ToString()][alive] = val
} else {
gs.VoiceRules.DeafRules[phase.ToString()][alive] = val
}
gs.VoiceRules.DeafRules[phase.ToString()][alive] = val
}

func (gs *GuildSettings) GetVoiceState(alive bool, tracked bool, phase game.Phase) (bool, bool) {
Expand Down

0 comments on commit 6354b55

Please sign in to comment.