diff --git a/notclyde.js b/notclyde.js new file mode 100644 index 0000000..4e91b9b --- /dev/null +++ b/notclyde.js @@ -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); + }); + }, +}; diff --git a/sendfile.js b/sendfile.js new file mode 100644 index 0000000..fa52eee --- /dev/null +++ b/sendfile.js @@ -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"}]}) + } + }, +};