Add exempt_users config to skip muting specific users

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-01 18:02:30 +03:00
parent c4160603e9
commit cecd50361c
3 changed files with 17 additions and 8 deletions
+10 -5
View File
@@ -14,10 +14,11 @@ import (
)
type Config struct {
Token string `json:"token"`
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id"`
Keybind string `json:"keybind"`
Token string `json:"token"`
GuildID string `json:"guild_id"`
ChannelID string `json:"channel_id"`
Keybind string `json:"keybind"`
ExemptUsers []string `json:"exempt_users"`
}
func loadConfig() (*Config, error) {
@@ -103,9 +104,13 @@ func toggleMute(dg *discordgo.Session, cfg *Config, muted bool) {
log.Printf("guild not in state cache (is the bot in the server?): %v", err)
return
}
exempt := make(map[string]bool, len(cfg.ExemptUsers))
for _, id := range cfg.ExemptUsers {
exempt[id] = true
}
count := 0
for _, vs := range guild.VoiceStates {
if vs.ChannelID == cfg.ChannelID {
if vs.ChannelID == cfg.ChannelID && !exempt[vs.UserID] {
if err := dg.GuildMemberMute(cfg.GuildID, vs.UserID, muted); err != nil {
log.Printf(" warning: user %s: %v", vs.UserID, err)
}