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 package main
import ( import (
"fmt"
"strings"
"time" "time"
"github.com/bwmarrin/discordgo" "github.com/bwmarrin/discordgo"
@ -45,12 +47,24 @@ func listenToStarboardReact(s *discordgo.Session, m *discordgo.MessageReactionAd
//White as fallback //White as fallback
color = 0xFFFFFF 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( msg, err = s.ChannelMessageSendEmbed(
starChannel, starChannel,
&discordgo.MessageEmbed{ &discordgo.MessageEmbed{
Title: "Starred Message", Title: "Starred Message",
Description: msg.Content, Description: content,
URL: "https://discordapp.com/channels/" + m.GuildID + "/" + m.ChannelID + "/" + m.MessageID,
Color: color, Color: color,
Timestamp: messageTimestamp.Format(time.RFC3339), Timestamp: messageTimestamp.Format(time.RFC3339),
Author: &discordgo.MessageEmbedAuthor{ Author: &discordgo.MessageEmbedAuthor{