Compare commits

..

2 Commits

Author SHA1 Message Date
09fd78bd79 no auto update if DOES include thing because i keep forgetting
!@
2021-08-23 20:44:44 -07:00
bb4049ac5e somehow had some undefined image data 2021-08-23 20:43:15 -07:00
2 changed files with 5 additions and 3 deletions

View File

@ -29,7 +29,7 @@ client.on("messageCreate", async message => {
for (let image of images) {
image.data = await (await fetch(image.url, {headers: {"Referer": "https://www.pixiv.net/"}})).buffer();
}
await message.channel.send({files: images.map(image => ({attachment: image.data, name: image.url.split('/').pop()}))});
await message.channel.send({files: images.map(image => ({attachment: image.data || "error", name: image.url.split('/').pop()}))});
} catch (error) {
if (error.message == "Request entity too large") await fallback();
else throw error;
@ -38,7 +38,9 @@ client.on("messageCreate", async message => {
function fallback() {
// save the data already downloaded
for (let image of images) {
try {
fs.writeFileSync(config.data_dir + "pixiv-cache/" + image.url.split('?')[0].replace(/\//g, '\\'), image.data);
} catch(e) { console.error(image, error) }
}
return message.channel.send(images.map(image => image.url.replace("https://i.pximg.net/", `https://${config.web_hostname}/pixiv-proxy/`)).join('\n'));
}

2
www.js
View File

@ -11,7 +11,7 @@ app.get("/update", (req, res) => {
return res.status(400).send("Signature verification failed");
let data = JSON.parse(req.query.payload);
res.sendStatus(200);
if (!data.commits.some(commit => commit.message.includes("!@"))) return;
if (data.commits.some(commit => commit.message.includes("%%"))) return;
child_process.exec("git pull", function(error) {
if (error) return void client.channels.resolve(config.bot_channel)?.send(`git pull: ${error.message}`);
child_process.exec("npm install", async function(error) {