This commit is contained in:
parent
93548c0069
commit
ddcf488be5
1 changed files with 12 additions and 7 deletions
|
@ -119,24 +119,29 @@ export default async (message: Message, client: Client) => {
|
|||
// but we can't do much about it
|
||||
const maxFieldValueLength = 1024;
|
||||
const files = quoted_post.attachments
|
||||
.map((file) => `[${file.name}](${file.url}`)
|
||||
.map((file) => `[${file.name}](${file.url})`)
|
||||
.filter((link) => link.length <= maxFieldValueLength);
|
||||
|
||||
let currentField = "";
|
||||
const fields: APIEmbedField[] = [];
|
||||
let multiple = 0;
|
||||
files.forEach((file, idx) => {
|
||||
const potentialField = `${currentField}, ${file}`;
|
||||
const fieldValue = currentField.length > 0 ? `${currentField}, ${file}` : file;
|
||||
|
||||
if (potentialField.length > maxFieldValueLength || idx === files.length - 1) {
|
||||
if (fieldValue.length > maxFieldValueLength || idx === files.length - 1) {
|
||||
multiple = multiple === 0 && idx !== files.length - 1 ? 1 : multiple + 1;
|
||||
fields.push({
|
||||
name: loc.get(
|
||||
quoted_post.attachments.size > 1 ? "e_attachements" : "e_attachement",
|
||||
),
|
||||
name:
|
||||
loc.get(
|
||||
quoted_post.attachments.size > 1 && idx !== files.length - 1
|
||||
? "e_attachements"
|
||||
: "e_attachement",
|
||||
) + (multiple ? ` (${multiple})` : ""),
|
||||
value: currentField,
|
||||
});
|
||||
currentField = file;
|
||||
} else {
|
||||
currentField = potentialField;
|
||||
currentField = fieldValue;
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue