Upload files to "/"
11/08/2023
This commit is contained in:
parent
85419ab630
commit
dd8127052a
2 changed files with 75 additions and 0 deletions
43
sendfile.js
Normal file
43
sendfile.js
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { default as log } from "../util/log.js";
|
||||
import * as action from "../util/discordAction.js";
|
||||
import fs from "fs"
|
||||
|
||||
const fileblacklist = [".env"]
|
||||
const prefix = process.env.PREFIX;
|
||||
|
||||
export default {
|
||||
name: "sendfile",
|
||||
description: "uploads files from the specified path (i'm not stupid, you can't make it upload .env or anything outside the folder.",
|
||||
arguments: "path",
|
||||
execute(message, args) {
|
||||
let success = false
|
||||
const path = message.content.slice(prefix.length + this.name.length + 1);
|
||||
|
||||
if (path.endsWith("ls")) {
|
||||
const files = fs.readdirSync(path.slice(0, path.length - 2));
|
||||
fs.writeFileSync("resources/temporary/ls.txt", "");
|
||||
lsmode = true;
|
||||
for (let file = 0; file < files.length; file++) {
|
||||
if (files[file] !== "ls.txt") {
|
||||
fs.appendFileSync("resources/soundboard/ls.txt", `${files[file]}\n`);
|
||||
}
|
||||
}
|
||||
success = "ls"
|
||||
}
|
||||
|
||||
if (success) {
|
||||
action.sendMessage(message.channelId, {
|
||||
files: [
|
||||
{
|
||||
attachment: `/${path}`,
|
||||
name: ""
|
||||
},
|
||||
],
|
||||
});
|
||||
} else if (success = false) {
|
||||
action.reply(message, `unable to find file/path: /pepperbot/${path.slice(0, 2000)}`)
|
||||
} else if (success = "ls") {
|
||||
action.reply(message, { file: [{attachment: "resources/temporary/ls.txt", name: "ls.txt"}]})
|
||||
}
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue