added p/vileimagery
This commit is contained in:
parent
94ebebf7f6
commit
a2f620d5ee
2 changed files with 67 additions and 0 deletions
67
src/commands/vileimagery.js
Normal file
67
src/commands/vileimagery.js
Normal file
|
@ -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",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue