codePreviews: fix files less than 30 lines

This commit is contained in:
Cynthia Foxwell 2023-04-03 13:50:00 -06:00
parent 05c1ef07cb
commit 7abd01a125

View file

@ -60,12 +60,20 @@ async function processFile(link) {
: "Lines " + startLine + "-" + endLine; : "Lines " + startLine + "-" + endLine;
const targetLines = ( const targetLines = (
entireFile ? lines.slice(0, 30) : lines.slice(startLine - 1, endLine) entireFile
? lines.length > 30
? lines.slice(0, 30)
: lines
: lines.slice(startLine - 1, endLine)
).join("\n"); ).join("\n");
return `**${fileName}: **${whichLines}\n\`\`\`${fileType}\n${unindent( return `**${fileName}: **${whichLines}\n\`\`\`${fileType}\n${unindent(
targetLines targetLines
)}${entireFile ? `\n... (${lines.length - 30} lines left)` : ""}\n\`\`\``; )}${
entireFile && lines.length > 30
? `\n... (${lines.length - 30} lines left)`
: ""
}\n\`\`\``;
} }
events.add("messageCreate", "codePreviews", async function (msg) { events.add("messageCreate", "codePreviews", async function (msg) {