starboard: Change starred message format

master
Luther Wen Xu 2019-11-20 17:18:58 +07:00
parent a68dc0e9bf
commit 4d46fb1960
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 16 additions and 2 deletions

@ -1,6 +1,8 @@
package main
import (
"fmt"
"strings"
"time"
"github.com/bwmarrin/discordgo"
@ -45,12 +47,24 @@ func listenToStarboardReact(s *discordgo.Session, m *discordgo.MessageReactionAd
//White as fallback
color = 0xFFFFFF
}
content := msg.Content[:1000]
//Up to 10 line
splittedContent := strings.SplitN(content, "\n", 11)
content = strings.Join(splittedContent[:10], "\n")
if len(splittedContent) > 10 || len(content) > 1000 {
content += "..."
}
content += fmt.Sprintf(
"\n\n[Original Message](https://discordapp.com/channels/%s/%s/%s)",
m.GuildID, m.ChannelID, m.MessageID,
)
msg, err = s.ChannelMessageSendEmbed(
starChannel,
&discordgo.MessageEmbed{
Title: "Starred Message",
Description: msg.Content,
URL: "https://discordapp.com/channels/" + m.GuildID + "/" + m.ChannelID + "/" + m.MessageID,
Description: content,
Color: color,
Timestamp: messageTimestamp.Format(time.RFC3339),
Author: &discordgo.MessageEmbedAuthor{