From 99a7bbf2ae9503b232e0f57813f4b05e67eb00d2 Mon Sep 17 00:00:00 2001 From: Dan Dryaev <48590492+ShadiestGoat@users.noreply.github.com> Date: Thu, 6 Oct 2022 09:34:22 +0000 Subject: [PATCH] feat(ui): use name for group DMs and usernames as fallback (#228) --- ui/util.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/ui/util.go b/ui/util.go index e0a73ca..c99bcfb 100644 --- a/ui/util.go +++ b/ui/util.go @@ -35,12 +35,16 @@ func channelToString(c discord.Channel) string { rp := c.DMRecipients[0] repr = rp.Username + "#" + rp.Discriminator case discord.GroupDM: - rps := make([]string, len(c.DMRecipients)) - for i, r := range c.DMRecipients { - rps[i] = r.Username + "#" + r.Discriminator + repr = c.Name + // if the name wasn't loaded, use it as a backup + if repr == "" { + rps := make([]string, len(c.DMRecipients)) + for i, r := range c.DMRecipients { + rps[i] = r.Username + "#" + r.Discriminator + } + + repr = strings.Join(rps, ", ") } - - repr = strings.Join(rps, ", ") default: repr = c.Name }