Skip to content

Commit

Permalink
Add file too big warning for cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
maxwofford committed Jan 19, 2022
1 parent 937f58e commit 10beba8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/interactions/fileShare.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,12 @@ export default async (bot = initBot(), message) => {
])
}
} catch (err) {
if (Math.random() > 0.5) {
await bot.replyInThread(message, transcript('fileShare.error'))
const maxFileSize = 100000000 // 100MB in bytes
const fileTooBig = files.filter(f => f.size > maxFileSize).length > 0
if (fileTooBig) {
await bot.replyInThread(message, transcript('fileShare.errorTooBig'))
} else {
await bot.replyInThread(message, transcript('fileShare.errorGeneric'))
}

await Promise.all([
Expand Down
11 changes: 10 additions & 1 deletion src/utils/transcript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -550,13 +550,22 @@ fileShare:
success: |
Yeah! Here's yo' links <@${this.user}>
${this.links.join('\n')}
error:
errorTooBig:
- https://cloud-3tq9t10za-hack-club-bot.vercel.app/2too_big_4.png
- https://cloud-3tq9t10za-hack-club-bot.vercel.app/3too_big_2.png
- https://cloud-3tq9t10za-hack-club-bot.vercel.app/4too_big_1.png
- https://cloud-3tq9t10za-hack-club-bot.vercel.app/6too_big_5.png
- https://cloud-3tq9t10za-hack-club-bot.vercel.app/7too_big_3.png
errorGeneric:
- |
_orpheus sneezes and drops the files on the ground before blowing her nose on a blank jpeg._
- |
_orpheus trips and your files slip out of her hands and into an inconveniently placed sewer grate._
- |
_orpheus accidentally slips the files into a folder in her briefcase labeled "homework". she starts sweating profusely._
- https://cloud-3tq9t10za-hack-club-bot.vercel.app/0generic_3.png
- https://cloud-3tq9t10za-hack-club-bot.vercel.app/1generic_2.png
- https://cloud-3tq9t10za-hack-club-bot.vercel.app/5generic_1.png
extensions:
gif:
- _gif_ that file to me and i'll upload it
Expand Down

0 comments on commit 10beba8

Please sign in to comment.