codePreviews: ignore markdown, limit full to 20 line files, fix
reactions (hopefully)
This commit is contained in:
parent
e212bade7b
commit
932d24d6a4
1 changed files with 7 additions and 11 deletions
|
@ -36,6 +36,8 @@ async function processFile(link) {
|
|||
? ""
|
||||
: fileName.substring(fileName.lastIndexOf(".") + 1);
|
||||
|
||||
if (fileType == "md") return "";
|
||||
|
||||
const lineStr = link.match(/#L\d+(-L?\d+)?/)?.[0];
|
||||
let startLine, endLine;
|
||||
let entireFile = false;
|
||||
|
@ -60,21 +62,15 @@ async function processFile(link) {
|
|||
? "Line " + startLine
|
||||
: "Lines " + startLine + "-" + endLine;
|
||||
|
||||
if (entireFile && lines.length > 20) return "";
|
||||
|
||||
const targetLines = (
|
||||
entireFile
|
||||
? lines.length > 30
|
||||
? lines.slice(0, 30)
|
||||
: lines
|
||||
: lines.slice(startLine - 1, endLine)
|
||||
entireFile ? lines : lines.slice(startLine - 1, endLine)
|
||||
).join("\n");
|
||||
|
||||
return `**${fileName}: **${whichLines}\n\`\`\`${fileType}\n${unindent(
|
||||
targetLines
|
||||
)}${
|
||||
entireFile && lines.length > 30
|
||||
? `\n... (${lines.length - 30} lines left)`
|
||||
: ""
|
||||
}\n\`\`\``;
|
||||
)}\n\`\`\``;
|
||||
}
|
||||
|
||||
events.add("messageCreate", "codePreviews", async function (msg) {
|
||||
|
@ -168,7 +164,7 @@ events.add(
|
|||
const ref = await channel.getMessage(msg.messageReference.messageID);
|
||||
if (!ref) return;
|
||||
if (
|
||||
ref.author.id != reactor.id ||
|
||||
ref.author.id != reactor.id &&
|
||||
!channel.permissionsOf(reactor.id).has("manageMessages")
|
||||
)
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue