From a2f620d5ee939ae71fa2f54ffcd76f7dd060c961 Mon Sep 17 00:00:00 2001 From: ayeuhugyu Date: Sat, 9 Sep 2023 16:43:15 -0700 Subject: [PATCH] added p/vileimagery --- src/commands/pastguildmembers.js | 0 src/commands/vileimagery.js | 67 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 src/commands/pastguildmembers.js create mode 100644 src/commands/vileimagery.js diff --git a/src/commands/pastguildmembers.js b/src/commands/pastguildmembers.js new file mode 100644 index 0000000..e69de29 diff --git a/src/commands/vileimagery.js b/src/commands/vileimagery.js new file mode 100644 index 0000000..64a1b6b --- /dev/null +++ b/src/commands/vileimagery.js @@ -0,0 +1,67 @@ +const { EmbedBuilder } = require("discord.js"); +const fs = require("fs"); +const prefix = process.env.PREFIX; + +module.exports = { + name: "vileimagery", + description: "Do NOT run.", + execute(message, args) { + let proposedfilename = message.content.slice( + prefix.length + this.name.length + 1 + ); + const embed = new EmbedBuilder(); + const images = fs + .readdirSync("../pepperbot/src/vileimagery") + .filter((file) => file.endsWith(".png")); + let file; + 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") { + lsMode = true; + file = "ls"; + path = "../pepperbot/src/vileimagery/ls.txt"; + } else { + 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." + ); + const maxRan = images.length; + const randomnum = Math.floor(Math.random() * maxRan); + file = images[randomnum]; + } + + if (!lsMode) { + embed.setTitle(file.replaceAll("_", " ").replaceAll(".png", "")); + embed.setImage(`attachment://${file}`); + } + embed.setColor(0xff0000); + if (!lsMode) { + message.reply({ + embeds: [embed], + files: [`../pepperbot/src/vileimagery/${file}`], + }); + } else { + message.channel.send({ + files: [ + { + attachment: path, + name: "ls.txt", + }, + ], + }); + } + }, +};