MCPcopy Create free account
hub / github.com/MMadmer/EpicAssetsNotifyBot / NormalizeGuildConfigs

Method NormalizeGuildConfigs

internal/model/normalize.go:59–105  ·  view source on GitHub ↗
(payload any)

Source from the content-addressed store, hash-verified

57}
58
59func (n Normalizer) NormalizeGuildConfigs(payload any) []GuildConfig {
60 items, ok := payload.([]any)
61 if !ok {
62 return nil
63 }
64
65 seen := make(map[int64]GuildConfig)
66 for _, item := range items {
67 m, ok := item.(map[string]any)
68 if !ok {
69 continue
70 }
71
72 guildID, ok := asInt64(m["guild_id"])
73 if !ok {
74 continue
75 }
76
77 cfg := GuildConfig{
78 GuildID: guildID,
79 ShownAssets: asBool(m["shown_assets"]),
80 Locale: n.normalizeLocaleFromAny(m["locale"]),
81 Enabled: asBoolDefault(m["enabled"], true),
82 IncludeImages: asBoolDefault(m["include_images"], true),
83 }
84 if cfg.Locale == "" {
85 cfg.Locale = n.baseLocale
86 }
87 if channelID, ok := asInt64Ptr(m["channel_id"]); ok {
88 cfg.ChannelID = channelID
89 }
90 if threadID, ok := asInt64Ptr(m["thread_id"]); ok {
91 cfg.ThreadID = threadID
92 }
93 if roleID, ok := asInt64Ptr(m["mention_role_id"]); ok {
94 cfg.MentionRoleID = roleID
95 }
96
97 seen[guildID] = cfg
98 }
99
100 out := make([]GuildConfig, 0, len(seen))
101 for _, v := range seen {
102 out = append(out, v)
103 }
104 return out
105}
106
107func (n Normalizer) NormalizeUserProfiles(payload any) []UserProfile {
108 items, ok := payload.([]any)

Callers

nothing calls this directly

Calls 5

asInt64Function · 0.85
asBoolFunction · 0.85
asBoolDefaultFunction · 0.85
asInt64PtrFunction · 0.85

Tested by

no test coverage detected