Skip to content

Commit b57e886

Browse files
authored
Merge branch 'main' into lunny/avoid_create_temporary_cat_file
2 parents 9fd68eb + 013b268 commit b57e886

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

services/webhook/discord.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ var (
101101
redColor = color("ff3232")
102102
)
103103

104+
// https://discord.com/developers/docs/resources/message#embed-object-embed-limits
105+
// Discord has some limits in place for the embeds.
106+
// According to some tests, there is no consistent limit for different character sets.
107+
// For example: 4096 ASCII letters are allowed, but only 2490 emoji characters are allowed.
108+
// To keep it simple, we currently truncate at 2000.
109+
const discordDescriptionCharactersLimit = 2000
110+
104111
type discordConvertor struct {
105112
Username string
106113
AvatarURL string
@@ -313,7 +320,7 @@ func (d discordConvertor) createPayload(s *api.User, title, text, url string, co
313320
Embeds: []DiscordEmbed{
314321
{
315322
Title: title,
316-
Description: text,
323+
Description: util.TruncateRunes(text, discordDescriptionCharactersLimit),
317324
URL: url,
318325
Color: color,
319326
Author: DiscordEmbedAuthor{

0 commit comments

Comments
 (0)