Skip to content

Commit 46df7e5

Browse files
committed
Truncate at 2000-th character for simplicity
1 parent 8876d34 commit 46df7e5

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

services/webhook/discord.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ var (
101101
redColor = color("ff3232")
102102
)
103103

104-
const discordDescriptionBytesLimit = 2048
104+
const discordDescriptionCharactersLimit = 2000
105105

106106
type discordConvertor struct {
107107
Username string
@@ -309,16 +309,13 @@ func parseHookPullRequestEventType(event webhook_module.HookEventType) (string,
309309
}
310310

311311
func (d discordConvertor) createPayload(s *api.User, title, text, url string, color int) DiscordPayload {
312-
if len(text) > discordDescriptionBytesLimit {
313-
text = text[:discordDescriptionBytesLimit]
314-
}
315312
return DiscordPayload{
316313
Username: d.Username,
317314
AvatarURL: d.AvatarURL,
318315
Embeds: []DiscordEmbed{
319316
{
320317
Title: title,
321-
Description: text,
318+
Description: util.TruncateRunes(text, discordDescriptionCharactersLimit), // Discord has some limits in place for the embeds, to keep it simple we currently truncate at 2000
322319
URL: url,
323320
Color: color,
324321
Author: DiscordEmbedAuthor{

0 commit comments

Comments
 (0)