Upload files to "/"
11/08/2023
This commit is contained in:
parent
85419ab630
commit
dd8127052a
2 changed files with 75 additions and 0 deletions
32
notclyde.js
Normal file
32
notclyde.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
import { default as log } from "../util/log.js";
|
||||
import * as action from "../util/discordAction.js";
|
||||
import { Configuration, OpenAIApi } from "openai"; // npm i openai
|
||||
import readline from "readline";
|
||||
|
||||
const configuration = new Configuration({
|
||||
organization: "org-0nmrFWw6wSm6xIJXSbx4FpTw",// platform.openai.com/account/org-settings
|
||||
apiKey: "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", // platform.openai.com/account/api-keys
|
||||
});
|
||||
const openai = new OpenAIApi(configuration);
|
||||
|
||||
const prefix = process.env.PREFIX;
|
||||
|
||||
export default {
|
||||
name: "notclyde",
|
||||
description: "ask a chatbot that is Powered by OpenAI:tm: whatever the fk you want",
|
||||
arguments: "message",
|
||||
execute(message, args) {
|
||||
const msgnoprefix = message.content.slice(prefix.length + this.name.length);
|
||||
openai
|
||||
.createChatCompletion({
|
||||
model: "gpt-3.5-turbo",
|
||||
messages: [{ role: "user", content: message.content }],
|
||||
})
|
||||
.then((res) => {
|
||||
action.reply(message, res.data.choices[0].message.content);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e);
|
||||
});
|
||||
},
|
||||
};
|
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