codePreviews: null check

This commit is contained in:
Cynthia Foxwell 2022-05-07 16:51:27 -06:00
parent 98a3dfe26c
commit e0d67ff501

View file

@ -28,6 +28,7 @@ events.add("messageCreate", "codePreviews", async function (msg) {
const gitlabLinks = msg.content.match(REGEX_GITLAB); const gitlabLinks = msg.content.match(REGEX_GITLAB);
const giteaLinks = msg.content.match(REGEX_GITEA); const giteaLinks = msg.content.match(REGEX_GITEA);
if (githubLinks?.length) {
for (const link of githubLinks) { for (const link of githubLinks) {
const rawLink = link.replace("/blob/", "/raw/"); const rawLink = link.replace("/blob/", "/raw/");
const file = await fetch(rawLink).then((res) => res.text()); const file = await fetch(rawLink).then((res) => res.text());
@ -86,6 +87,7 @@ events.add("messageCreate", "codePreviews", async function (msg) {
unindent(targetLines) + unindent(targetLines) +
"\n```\n"; "\n```\n";
} }
}
if (out !== "") if (out !== "")
msg.channel.createMessage({ msg.channel.createMessage({