slash-create/docs-bot

feat(`/code *`): add option to override content trim behaviour

sudojunior opened this issue · 0 comments

Add an option that allows resulting content to be oversized, and fallback to processing the result as a file if it is too large - similar to the behaviour of all /debug * commands (chat, user and message).

/code * ... {option}: boolean

  1. disable_trim = false
  2. trim_content = true

while (content.length > 2000) {
amendNotes.add('Requested content was trimmed.');
const lines = content.split('\n');
// #region trim location
if (subCommand === 'entity' && trimTopThisTime) {
lines.splice(notesCount + 2, 1);
actualStart++;
} else {
lines.splice(-2, 1);
actualEnd--;
}
trimTopThisTime = !trimTopThisTime;
// #endregion
// #region notes re-injection
if (amendNotes.size !== notesCount) {
const notesLines = [...amendNotes].map((note) => `> ${note}`);
lines.splice(1, notesCount, ...notesLines);
notesCount = amendNotes.size;
}
// #endregion
lines[0] = this.generateContentHeader(file, [startLine, actualStart], [endLine, actualEnd]);
content = lines.join('\n');
}

It is worth noting that Discord stable doesn't appear to have the file preview which its siblings have had for some time.