Skip to content

Commit

Permalink
Merge pull request #129 from ApocalypseCalculator/develop
Browse files Browse the repository at this point in the history
Fix Notifs and Update Dependencies
  • Loading branch information
ApocalypseCalculator authored Mar 24, 2023
2 parents 29dc14c + b6eb995 commit 407a8bb
Show file tree
Hide file tree
Showing 3 changed files with 216 additions and 170 deletions.
20 changes: 17 additions & 3 deletions notif.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ module.exports.sendNotif = (name, id, hostname, ip, size) => {
inline: true
}, {
name: "Access URL",
value: `[Click me](https://${hostname}/uploads/${id}/${encodeURIComponent(name)})`,
value: `[Click me](https://${hostname}/uploads/?fileid=${id})`,
inline: true
}, {
name: "File Size",
value: `${size}`,
value: `${formatSize(parseInt(size))}`,
inline: true
}, {
name: "Uploader IP",
Expand All @@ -43,4 +43,18 @@ module.exports.sendNotif = (name, id, hostname, ip, size) => {
resolve();
}
})
}
}

function formatSize(number) {
if (number >= 1024 * 1024) {
let mbSize = number / (1024 * 1024);
return `${mbSize.toFixed(1)}`.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + "MB";
}
else if (number >= 1024) {
let kbSize = number / (1024);
return `${kbSize.toFixed(1)}KB`;
}
else {
return `${number}B`;
}
}
Loading

0 comments on commit 407a8bb

Please sign in to comment.