1
0
forked from noxious/server

╭∩╮( •̀_•́ )╭∩╮

This commit is contained in:
2024-07-01 00:39:03 +02:00
parent ad9b7f8892
commit 39e8f52595
3 changed files with 34 additions and 47 deletions

View File

@ -32,7 +32,7 @@ export default function (socket: TSocket, io: Server) {
for (const key in data) {
// the files in the folder are named 0.png, 1.png, 2.png etc... check the last file name and add 1
const files = fs.readdirSync(public_folder);
const lastFile = files.reduce((a, b) => a > b ? a : b);
const lastFile = files.reduce((a, b) => a > b ? a : b, '0.png');
const lastFileName = lastFile?.split('.')[0];
const filename = `${parseInt(lastFileName ?? '0') + 1}.png`;
const finalFilePath = path.join(public_folder, filename);