mirror of
https://github.com/diamondburned/cchat-discord.git
synced 2024-11-22 14:12:47 +00:00
Fixed guilds not loading because deleted; minor bug fixes
This commit is contained in:
parent
15143bfc09
commit
d37d24c8e3
2
guild.go
2
guild.go
|
@ -69,7 +69,7 @@ func (gf *GuildFolder) Servers(container cchat.ServersContainer) error {
|
|||
for i, id := range gf.GuildIDs {
|
||||
g, err := gf.session.Guild(id)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get guild ID "+id.String())
|
||||
continue
|
||||
}
|
||||
|
||||
servers[i] = NewGuild(gf.session, g)
|
||||
|
|
|
@ -70,7 +70,8 @@ func (r *TextRenderer) renderEmbed(embed discord.Embed, m *discord.Message, s st
|
|||
// If we have a thumbnail, then write one.
|
||||
if embed.Thumbnail != nil {
|
||||
r.append(EmbedThumbnail(r.buf.Len(), *embed.Thumbnail))
|
||||
r.ensureBreak()
|
||||
// Guarantee 2 lines because thumbnail needs its own.
|
||||
r.startBlockN(2)
|
||||
}
|
||||
|
||||
if embed.Description != "" {
|
||||
|
@ -120,7 +121,9 @@ func (r *TextRenderer) renderEmbed(embed discord.Embed, m *discord.Message, s st
|
|||
// Write an image if there's one.
|
||||
if embed.Image != nil {
|
||||
r.append(EmbedImage(r.buf.Len(), *embed.Image))
|
||||
r.ensureBreak()
|
||||
// Images take up its own empty line, so we should guarantee 2 empty
|
||||
// lines.
|
||||
r.startBlockN(2)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
service.go
11
service.go
|
@ -133,8 +133,11 @@ func (s *Session) Icon(ctx context.Context, iconer cchat.IconContainer) (func(),
|
|||
// Thanks to arikawa, AvatarURL is never empty.
|
||||
iconer.SetIcon(AvatarURL(u.AvatarURL()))
|
||||
|
||||
return s.AddHandler(func(u *gateway.UserUpdateEvent) {
|
||||
iconer.SetIcon(AvatarURL(u.AvatarURL()))
|
||||
return s.AddHandler(func(*gateway.UserUpdateEvent) {
|
||||
// Bypass the event and use the state cache.
|
||||
if u, err := s.Store.Me(); err == nil {
|
||||
iconer.SetIcon(AvatarURL(u.AvatarURL()))
|
||||
}
|
||||
}), nil
|
||||
}
|
||||
|
||||
|
@ -166,7 +169,7 @@ func (s *Session) Servers(container cchat.ServersContainer) error {
|
|||
case len(folder.GuildIDs) == 1:
|
||||
g, err := NewGuildFromID(s, folder.GuildIDs[0])
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get guild in folder")
|
||||
continue
|
||||
}
|
||||
toplevels = append(toplevels, g)
|
||||
}
|
||||
|
@ -182,7 +185,7 @@ func (s *Session) Servers(container cchat.ServersContainer) error {
|
|||
for _, id := range s.Ready.Settings.GuildPositions {
|
||||
g, err := NewGuildFromID(s, id)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "Failed to get guild in position")
|
||||
continue
|
||||
}
|
||||
guilds = append(guilds, g)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue