connector: sort recent private channels properly

This commit is contained in:
Skip R
2025-11-25 14:46:12 -08:00
parent 56f05bc02c
commit 31c1cdda0c

View File

@@ -17,7 +17,6 @@
package connector
import (
"cmp"
"context"
"errors"
"fmt"
@@ -181,7 +180,9 @@ func (d *DiscordClient) syncPrivateChannels(ctx context.Context) {
dms := slices.Clone(d.Session.State.PrivateChannels)
// Only sync the top n private channels with recent activity.
slices.SortFunc(dms, func(a, b *discordgo.Channel) int {
return cmp.Compare(b.LastMessageID, a.LastMessageID)
ats, _ := discordgo.SnowflakeTimestamp(a.LastMessageID)
bts, _ := discordgo.SnowflakeTimestamp(b.LastMessageID)
return bts.Compare(ats)
})
// TODO(skip): This is startup_private_channel_create_limit. Support this in the config.
for _, dm := range dms[:10] {