From 1129e9b780ad686d8beea07e0f357be2868a9ad4 Mon Sep 17 00:00:00 2001 From: PuzzlingGGG <138084889+PuzzlingGGG@users.noreply.github.com> Date: Tue, 26 Nov 2024 01:47:43 -0500 Subject: [PATCH 1/2] make update image on homepage not poop itself --- main.go | 1 + 1 file changed, 1 insertion(+) diff --git a/main.go b/main.go index 8cc3a62..d992194 100644 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ func backgroundTask() { for { time.Sleep(15 * time.Minute) getRecentsCommits() + refreshLatestUpdate(dg) } } From 4fe4b868de7e1f1df85161d53e615337e787eedc Mon Sep 17 00:00:00 2001 From: PuzzlingGGG <138084889+PuzzlingGGG@users.noreply.github.com> Date: Tue, 26 Nov 2024 01:52:35 -0500 Subject: [PATCH 2/2] i for got to update this --- discord.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/discord.go b/discord.go index 60aae23..721423b 100644 --- a/discord.go +++ b/discord.go @@ -133,3 +133,31 @@ func startDiscordBot() { } defer dg.Close() } + +func refreshLatestUpdate(dg *discordgo.Session) { + updateMessages, err := dg.ChannelMessages(discordUpdateChannel, 1, "", "", "") + if err != nil { + log.Printf("failed to fetch the latest update: %s", err) + return + } + + if len(updateMessages) > 0 { + m := updateMessages[0] + if len(m.Attachments) > 0 { + currentUpdate = Update{ + ID: m.ID, + GuildID: m.GuildID, + ChannelID: m.ChannelID, + CreatedTs: m.Timestamp.UnixMilli(), + EditedTs: m.Timestamp.UnixMilli(), + AuthorID: m.Author.ID, + AuthorName: m.Author.Username, + AuthorImage: m.Author.AvatarURL(""), + Content: m.Content, + CleanContent: m.ContentWithMentionsReplaced(), + Image: m.Attachments[0].URL, + } + log.Printf("updated latest update: %s", currentUpdate.Content) + } + } +}