mirror of
https://github.com/Luzifer/discord-community.git
synced 2024-12-20 10:21:22 +00:00
Force Discord to fetch fresh previews for the streams
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
19c1c4d7b5
commit
08c096ddb2
1 changed files with 13 additions and 1 deletions
|
@ -222,6 +222,18 @@ func (m modLivePosting) sendLivePost(username, displayName, title, game, preview
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Discord caches the images and the URLs do not change every time
|
||||||
|
// so we force Discord to load a new image every time
|
||||||
|
previewImageURL, err := url.Parse(
|
||||||
|
strings.NewReplacer(
|
||||||
|
"{width}", strconv.Itoa(livePostingPreviewWidth),
|
||||||
|
"{height}", strconv.Itoa(livePostingPreviewHeight),
|
||||||
|
).Replace(previewImage),
|
||||||
|
)
|
||||||
|
previewImageQuery := previewImageURL.Query()
|
||||||
|
previewImageQuery.Add("_discordNoCache", time.Now().Format(time.RFC3339))
|
||||||
|
previewImageURL.RawQuery = previewImageQuery.Encode()
|
||||||
|
|
||||||
msgEmbed := &discordgo.MessageEmbed{
|
msgEmbed := &discordgo.MessageEmbed{
|
||||||
Author: &discordgo.MessageEmbedAuthor{
|
Author: &discordgo.MessageEmbedAuthor{
|
||||||
Name: displayName,
|
Name: displayName,
|
||||||
|
@ -232,7 +244,7 @@ func (m modLivePosting) sendLivePost(username, displayName, title, game, preview
|
||||||
{Name: "Game", Value: game},
|
{Name: "Game", Value: game},
|
||||||
},
|
},
|
||||||
Image: &discordgo.MessageEmbedImage{
|
Image: &discordgo.MessageEmbedImage{
|
||||||
URL: strings.NewReplacer("{width}", strconv.Itoa(livePostingPreviewWidth), "{height}", strconv.Itoa(livePostingPreviewHeight)).Replace(previewImage),
|
URL: previewImageURL.String(),
|
||||||
Width: livePostingPreviewWidth,
|
Width: livePostingPreviewWidth,
|
||||||
Height: livePostingPreviewHeight,
|
Height: livePostingPreviewHeight,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue