fix: Fix "Hang status" for new Discord version
All checks were successful
Build artifact / build (push) Successful in 32s
Build artifact / release (push) Successful in 40s

This commit is contained in:
Matte23
2024-07-09 23:19:28 +02:00
parent c20a3fdbc8
commit 30687e2271
4 changed files with 42 additions and 72 deletions

View File

@@ -93,11 +93,16 @@ func removeUserFromChannels(s *discordgo.Session, vs *discordgo.VoiceStateUpdate
}
} else {
createdChannels[vs.GuildID][channelID] = remove(channel, index)
updateChannelName(s, vs.GuildID, channelID)
}
}
}
}
func updateNameOnJoin(s *discordgo.Session, vs *discordgo.VoiceStateUpdate) {
updateChannelName(s, vs.GuildID, vs.ChannelID)
}
func updateChannelName(s *discordgo.Session, guildID string, channelID string) {
programs := make(map[string]int)
@@ -109,7 +114,7 @@ func updateChannelName(s *discordgo.Session, guildID string, channelID string) {
name := "Stanza"
for program, count := range programs {
if count > max {
if program != "Stanza" && count > max {
max = count
name = program
}
@@ -142,5 +147,11 @@ func getActivity(st *discordgo.State, guildID string, userID string) string {
return "Stanza"
}
return presence.Activities[len(presence.Activities)-1].Name
for _, activity := range presence.Activities {
if activity.Name != "Hang Status" {
return activity.Name
}
}
return "Stanza"
}