From a5e5442d31b08d1177a58781bfc4ae908e297961 Mon Sep 17 00:00:00 2001 From: ayeuhugyu Date: Sat, 16 Sep 2023 08:11:35 -0700 Subject: [PATCH] cleaned up p/vileimagery a bit --- README.md | 1 + src/commands/vileimagery.js | 31 +++++++++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index eb98ddd..d6393b1 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ clean up p/vileimagery, its horrendous **_Note:_** _versions before this were not uploaded to the repo, this is not the first version._ 1.8 - reorganized files some more, moved all events from index.js to seperate scripts in events folder, + 1.8.1 - cleaned up p/vileimagery a bit --- diff --git a/src/commands/vileimagery.js b/src/commands/vileimagery.js index 46697c7..bedad57 100644 --- a/src/commands/vileimagery.js +++ b/src/commands/vileimagery.js @@ -17,24 +17,24 @@ module.exports = { let lsMode = false; let path; - if (images.includes(proposedfilename)) { - file = proposedfilename; - } else if (images.includes(proposedfilename.replaceAll(" ", "_"))) { - file = proposedfilename.replaceAll(" ", "_"); - } else if ( - images.includes(proposedfilename.replaceAll(" ", "_") + ".png") - ) { - file = proposedfilename.replaceAll(" ", "_") + ".png"; - } else if ( - images.includes(proposedfilename + ".png") && - proposedfilename !== "ls" - ) { - file = proposedfilename += ".png"; - } else if (proposedfilename === "ls") { + let possibleFilenames = { + regular: proposedfilename, + spaced: proposedfilename.replaceAll(" ", "_"), + spacedPng: proposedfilename.replaceAll(" ", "_") + ".png", + png: proposedfilename + ".png", + }; + for (const value of Object.values(possibleFilenames)) { + if (images.includes(value)) { + file = value; + } + } + if (proposedfilename === "ls") { lsMode = true; file = "ls"; path = "../pepperbot/resources/vileimagery/ls.txt"; - } else { + } + + if (!file) { embed.setDescription( "unable to find your file in the vile imagery folder, instead it has been replaced with a random one. put `ls` as your args to upload a file of all names. try replacing spaces with _s." ); @@ -42,7 +42,6 @@ module.exports = { const randomnum = Math.floor(Math.random() * maxRan); file = images[randomnum]; } - if (!lsMode) { embed.setTitle(file.replaceAll("_", " ").replaceAll(".png", "")); embed.setImage(`attachment://${file}`);