Skip to content
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion services/webhook/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ var (
redColor = color("ff3232")
)

// https://discord.com/developers/docs/resources/message#embed-object-embed-limits
// Discord has some limits in place for the embeds.
// According to some tests, there is no consistent limit for different characet sets.
// For example: 4096 ASCII letters are allowed, but only 2490 emoji characters are allowed.
// To keep it simple, we currently truncate at 2000.
const discordDescriptionCharactersLimit = 2000

type discordConvertor struct {
Username string
AvatarURL string
Expand Down Expand Up @@ -313,7 +320,7 @@ func (d discordConvertor) createPayload(s *api.User, title, text, url string, co
Embeds: []DiscordEmbed{
{
Title: title,
Description: text,
Description: util.TruncateRunes(text, discordDescriptionCharactersLimit),
URL: url,
Color: color,
Author: DiscordEmbedAuthor{
Expand Down
Loading