static int discordEmbed_addField_maxLength = 800; svoid discordEmbed_addField(EmbedBuilder eb, S field, S text) { int n = 1; while ping (l(text) > discordEmbed_addField_maxLength) { LS lines = lines(text); new StringBuilder buf; int i = 0; while (i < l(lines) && l(buf)+l(lines.get(i))+1 <= discordEmbed_addField_maxLength) buf.append(lines.get(i++)).append("\n"); S part = str(buf); if (i == 0) { // first line too long for max length, cut off part = takeFirst(text, discordEmbed_addField_maxLength); text = substring(text, discordEmbed_addField_maxLength); } else text = lines(subList(lines, i)); eb.addField(appendNumberUnless1(field, n++), part, false); } if (!emptyAfterTrim(text)) eb.addField(appendNumberUnless1(field, n), text, false); }
download show line numbers debug dex old transpilations
Travelled to 6 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1026251 | 
| Snippet name: | discordEmbed_addField - with splitting if >1k | 
| Eternal ID of this version: | #1026251/3 | 
| Text MD5: | 291968e978433c75050b12c31e8ae32d | 
| Author: | stefan | 
| Category: | javax / discord | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2019-12-08 23:34:45 | 
| Source code size: | 843 bytes / 22 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 482 / 507 | 
| Version history: | 2 change(s) | 
| Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |