Skip to content
This repository was archived by the owner on Nov 24, 2022. It is now read-only.

Commit 60fe2a2

Browse files
committed
CodeMessageWatcher: Only reply when message length is within API limits
1 parent fc65c53 commit 60fe2a2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

TabletBot.Discord/Watchers/GitHub/CodeMessageWatcher.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.IO;
3+
using System.Linq;
34
using System.Text;
45
using System.Text.RegularExpressions;
56
using System.Threading.Tasks;
@@ -49,7 +50,9 @@ public async Task Receive(IMessage message)
4950
sb.AppendLine(Formatting.CodeString(path));
5051
sb.AppendCodeBlock(lines, extension);
5152

52-
await message.Channel.SendMessageAsync(sb.ToString(), messageReference: userMessage.ToReference());
53+
var text = sb.ToString();
54+
if (text.Length <= 2000)
55+
await message.Channel.SendMessageAsync(text, messageReference: userMessage.ToReference());
5356
}
5457
}
5558
}

0 commit comments

Comments
 (0)