modules/starboard: Add thumbnails of pictures when a file is attached

This prevents seemingly empty starred messages from appearing
master
Luther Wen Xu 2019-12-12 12:53:18 +07:00
parent 70655246ac
commit f4aa441899
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 19 additions and 12 deletions

@ -80,9 +80,7 @@ func ReactListener(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
m.GuildID, m.ChannelID, m.MessageID,
)
msg, err = s.ChannelMessageSendEmbed(
config.StarChannel,
&discordgo.MessageEmbed{
embed := discordgo.MessageEmbed{
Title: "Starred Message",
Description: content,
Color: color,
@ -91,8 +89,17 @@ func ReactListener(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
Name: msg.Author.Username + "#" + msg.Author.Discriminator,
IconURL: "https://cdn.discordapp.com/avatars/" + msg.Author.ID + "/" + msg.Author.Avatar + ".png",
},
},
)
}
if len(msg.Embeds) > 0 && msg.Embeds[0].Image != nil {
img := msg.Embeds[0].Image
embed.Thumbnail = &discordgo.MessageEmbedThumbnail{
URL: img.URL,
ProxyURL: img.ProxyURL,
Width: img.Width,
Height: img.Height,
}
}
msg, err = s.ChannelMessageSendEmbed(config.StarChannel, &embed)
if err != nil {
log.Error(s, "listenToStarboardReact", "channelMessageSendEmbed", err)
return