final major commit before rewrite in typescript

This commit is contained in:
ayeuhugyu 2024-02-20 16:59:51 -08:00
parent 2c2fd8b5ff
commit fd6a98d80c
11 changed files with 346 additions and 46 deletions

View file

@ -18,6 +18,7 @@ clean up p/vileimagery, its horrendous
**_Note:_** _versions before this were not uploaded to the repo, this is not the first version._
1.16 - added a major crash prevention system, also responses to failed commands are now randomized
1.16.1 - added a terrible ai response, add failed response command, also beta terrible garbage training data generator, also retrievesound command
---

41
cfg/failresponses.json Normal file
View file

@ -0,0 +1,41 @@
[
"nah, i'd win",
"nah",
"yuh huh",
"{command} is a sin",
"nah not yet",
"really. {command}ing right now??",
"i don't take comments like that",
"{command} will NOT be tolerated in this establishment.",
"you're a baffoon for that one",
"GEOMETRY DASH {command} (gone wrong) (gone sexual) (in the hood) (this was generated by copilot 😭😭😭😭😭)",
"dude you gotta hop off the {command}",
"hop on {command}",
"i'm not in the mood for {command}",
"mmmmmmmm",
"no",
"unacceptable behavior.",
"DESPICABLE ME: {command}",
"***IM IN YOUR WALLS***",
"such a https://www.youtube.com/watch?v=6x_6UOj8vRw moment",
"( ͡° ͜ʖ ͡°)",
"https://spax.zone/tests/horse girl.mp4 (-- github copilot)",
"p/vileimagery the problem",
"foop? foop.",
"tried {command}ing once. didn't like it.",
"YOU ARE ARE {command}ER",
"*If you're seeing this message, 12122212314231 was unable to be reached.*",
"We're sorry, the number you have tried to dial is not available at this time. Please try again later.",
"Are you sure you weren't in Guatemala?",
"new discord.Collection();",
"@Xx_Johanes_Bach_Gamer69_xX type beat",
"YO YO YO, WHATS POPPIN FELLAS, ITS YA BOI {command}GOD420 HERE BACK WITH YET ANOTHER BANGER VIDEO. -- github copilot",
"Github Copilot is a great tool for generating code, but it's not perfect. -- github copilot -- github copilot",
"p/recent",
"Noah. -- github copilot -- github copilot",
"https://www.youtube.com/watch?v=6x_6UOj8vRw",
"Horse Feedback Loop Approachment",
"https://bargainballoons.com 🎈🎈🎈",
"It's [time to feast!](https://tenor.com/view/robert-mueller-time-to-feast-gif-13779665)",
"|| https://cdn.discordapp.com/attachments/612085389041336320/1208301630571937862/SPOILER_IMG_4637.jpg?ex=65e2c995&is=65d05495&hm=55bee618c4cb9b6ef61fe5745633af8908aa19de68b278e14291574bd975b748& ||"
]

80
package-lock.json generated
View file

@ -10,6 +10,7 @@
"license": "ISC",
"dependencies": {
"@discordjs/voice": "^0.16.0",
"axios": "^1.6.7",
"discord.js": "^14.13.0",
"discord.js-collector": "^1.8.9",
"dotenv": "^16.3.1",
@ -306,6 +307,29 @@
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz",
"integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg=="
},
"node_modules/axios": {
"version": "1.6.7",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
"integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
"dependencies": {
"follow-redirects": "^1.15.4",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/axios/node_modules/form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/base-64": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
@ -640,6 +664,25 @@
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
},
"node_modules/follow-redirects": {
"version": "1.15.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
@ -1217,6 +1260,11 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"node_modules/psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
@ -1833,6 +1881,28 @@
"resolved": "https://registry.npmjs.org/aws4/-/aws4-1.12.0.tgz",
"integrity": "sha512-NmWvPnx0F1SfrQbYwOi7OeaNGokp9XhzNioJ/CSBs8Qa4vxug81mhJEAVZwxXuBmYB5KDRfMq/F3RR0BIU7sWg=="
},
"axios": {
"version": "1.6.7",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.6.7.tgz",
"integrity": "sha512-/hDJGff6/c7u0hDkvkGxR/oy6CbCs8ziCsC7SqmhjfozqiJGc8Z11wrv9z9lYfY4K8l+H9TpjcMDX0xOZmx+RA==",
"requires": {
"follow-redirects": "^1.15.4",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
},
"dependencies": {
"form-data": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
"integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
}
}
}
},
"base-64": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
@ -2082,6 +2152,11 @@
"resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz",
"integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw=="
},
"follow-redirects": {
"version": "1.15.5",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
"integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw=="
},
"forever-agent": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz",
@ -2516,6 +2591,11 @@
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag=="
},
"proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
},
"psl": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",

View file

@ -12,6 +12,7 @@
"license": "ISC",
"dependencies": {
"@discordjs/voice": "^0.16.0",
"axios": "^1.6.7",
"discord.js": "^14.13.0",
"discord.js-collector": "^1.8.9",
"dotenv": "^16.3.1",

View file

@ -0,0 +1,26 @@
import fs from "fs";
import * as action from "../util/discordAction.js";
const prefix = process.env.PREFIX;
export default {
name: "addresponse",
description:
"adds a response to the failed command response list, type '{command}' to insert the command name. (i will not be fixing the fact that that notation does not make sense lmfao)",
arguments: "msg",
execute(message, args) {
if (message.author.bot) return;
const msgnoprefix = message.content.slice(
prefix.length + this.name.length + 1
);
const msg = msgnoprefix.slice(0, 2000);
const jsonstring = fs.readFileSync("cfg/failresponses.json");
const failresponses = JSON.parse(jsonstring);
failresponses.push(msg);
const jsonrestringed = JSON.stringify(failresponses);
fs.writeFileSync("cfg/failresponses.json", jsonrestringed);
if (msg !== "") {
action.reply(message, `it is done.`);
}
},
};

View file

@ -0,0 +1,57 @@
import * as action from "../util/discordAction.js";
import axios from "axios";
import fs from "fs";
const whitelist = ["440163494529073152removeme"];
const prefix = process.env.PREFIX;
export default {
name: "generateresponse",
description: "generative AI test (private, requires whitelist)",
arguments: "query",
async execute(message, args) {
if (!whitelist.includes(message.author.id)) {
let res = await axios.get(
`http://api.brainshop.ai/get?bid=153868&key=rcKonOgrUFmn5usX&uid=1&msg=${encodeURIComponent(
message.content
)}`
);
message.reply(res.data.cnt);
/*
if (message.author.bot || message.channel.id != process.env.DISCORD_CHANNEL_ID || !bot || processing) return
processing = true
body.text += `\n${bot.userLabel}: ${message.content.slice(0, 128)}\n${bot.botLabel}:`
message.channel.sendTyping()
fetch("https://model-api-shdxwd54ta-nw.a.run.app/generate/gptj", {
"headers": {
"content-type": "application/json",
"developer_key": process.env.CHAI_DEV_KEY,
"developer_uid": process.env.CHAI_DEV_UID,
},
"body": JSON.stringify(body),
"method": "POST"
}).then(res => res.json()).then(d => {
if (d.error) throw newError('Error while fetching response', d.error.message)
body.text += d.data
message.reply({
content: d.data
}).catch(error => {
throw newError('Error while sending message', error)
}).finally(
processing = false
)
})
*/
} else {
action.reply(
message,
"baffoon shush up! -- XxTheGlopMasterxX2021, 2022 (c) All Rights Reserved. 2021-2022."
); // thanks copilot..?
}
},
};

View file

@ -0,0 +1,56 @@
import fs from "fs";
import * as action from "../util/discordAction.js";
const prefix = process.env.PREFIX;
export default {
name: "retrievesound",
description: 'sends a specified "sound"',
execute(message, args) {
if (message.author.bot) return;
let proposedfilename = message.content.slice(
prefix.length + this.name.length + 1
);
const files = fs.readdirSync("resources/soundboard");
let file;
let possibleFilenames = {
regular: proposedfilename,
spaced: proposedfilename.replaceAll(" ", "_"),
spacedmp3: proposedfilename.replaceAll(" ", "_") + ".mp3",
mp3: proposedfilename + ".mp3",
spacedogg: proposedfilename.replaceAll(" ", "_") + ".ogg",
ogg: proposedfilename + ".ogg",
spacedwav: proposedfilename.replaceAll(" ", "_") + ".wav",
wav: proposedfilename + ".wav",
spacedwebm: proposedfilename.replaceAll(" ", "_") + ".webm",
webm: proposedfilename + ".webm",
spacedm4a: proposedfilename.replaceAll(" ", "_") + ".m4a",
m4a: proposedfilename + ".m4a",
spacedmp4: proposedfilename.replaceAll(" ", "_") + ".mp4",
mp4: proposedfilename + ".mp4",
};
for (const value of Object.values(possibleFilenames)) {
if (files.includes(value)) {
file = value;
}
}
if (!file) {
action.reply(message, "There's no such thing!");
return;
}
action.reply(
message,
"uploading your sound, this may take a while if you're uploading something large"
);
action.reply(message, {
files: [
{
attachment: `resources/soundboard/${file}`,
name: file,
},
],
});
},
};

View file

@ -0,0 +1,18 @@
import { default as log } from "../util/log.js";
import * as action from "../util/discordAction.js";
export default {
name: "sendknowledgebase",
description: "uploads knowledgebase file",
arguments: "none",
execute(message, args) {
action.sendMessage(message.channelId, {
files: [
{
attachment: "data/knowledgebase.json",
name: "knowledgebase.json",
},
],
});
},
};

View file

@ -8,46 +8,7 @@ import * as index from "../index.js";
let commands = new discord.Collection();
let failresponses = [
"nah, i'd win",
"nah",
"yuh huh",
"{command}",
"nah not yet",
"really. {command}ing right now??",
"i don't take comments like that",
"{command} will NOT be tolerated in this establishment.",
"you're a baffoon for that one",
"GEOMETRY DASH {command} (gone wrong) (gone sexual) (in the hood) (this was generated by copilot 😭😭😭😭😭)",
"dude you gotta hop off the {command}",
"hop on {command}",
"i'm not in the mood for {command}",
"mmmmmmmm",
"no",
"unacceptable behavior.",
"DESPICABLE ME: {command}",
"***IM IN YOUR WALLS***",
"such a https://www.youtube.com/watch?v=6x_6UOj8vRw moment",
"( ͡° ͜ʖ ͡°)",
"https://spax.zone/tests/horse girl.mp4 (-- github copilot)",
"p/vileimagery the problem",
"foop? foop.",
"tried {command}ing once. didn't like it.",
"YOU ARE ARE {command}ER",
"*If you're seeing this message, 12122212314231 was unable to be reached.*",
"We're sorry, the number you have tried to dial is not available at this time. Please try again later.",
"Are you sure you weren't in Guatemala?",
"new discord.Collection();",
"@Xx_Johanes_Bach_Gamer69_xX type beat",
"YO YO YO, WHATS POPPIN FELLAS, ITS YA BOI {command}GOD420 HERE BACK WITH YET ANOTHER BANGER VIDEO. -- github copilot",
"Github Copilot is a great tool for generating code, but it's not perfect. -- github copilot -- github copilot",
"p/recent",
"Noah. -- github copilot -- github copilot",
"https://www.youtube.com/watch?v=6x_6UOj8vRw",
"Horse Feedback Loop Approachment", // https://www.youtube.com/watch?v=6x_6UOj8vRw // -- github copilot (idk why it wanted me to put this here) // dude holy shit why is it so obsessed with this video
"https://bargainballoons.com 🎈🎈🎈",
"It's [time to feast!](https://tenor.com/view/robert-mueller-time-to-feast-gif-13779665)",
];
let qora = true; // true = question false = answer
const commandFiles = fs
.readdirSync("src/commands/")
@ -82,10 +43,36 @@ async function sendMainMessage(message) {
}
}
let question = "";
let answer = "";
export default function (message, client) {
const blacklistnosplit = fs.readFileSync("data/blacklisted.log", "utf8");
const blacklist = blacklistnosplit.split("\n");
if (!message.content.startsWith(prefix)) {
if (!message.author.bot) {
const jsonstring = fs.readFileSync("data/knowledgebase.json", "utf8");
const qandas = JSON.parse(jsonstring);
if (qora) {
question = message.content;
qora = false;
} else {
answer = message.content;
qora = true;
}
if (question != "" && answer != "") {
qandas.questions.push({ question: question, answer: answer });
fs.writeFileSync(
"data/knowledgebase.json",
JSON.stringify(qandas, null, 2)
);
question = "";
answer = "";
}
}
}
if (message.channel.type === 1) {
log(
"directmessages.log",
@ -99,6 +86,9 @@ export default function (message, client) {
`direct message from ${message.author.username} (\`${message.author.id}\`) with: "${message.content}"`
);
}
if (message.content.includes("fortnite")) {
message.reply("unacceptable.");
}
if (!message.content.startsWith(prefix)) return;
if (blacklist.includes(message.author.id)) {
message.reply("blacklisted smh");
@ -113,8 +103,16 @@ export default function (message, client) {
const args = parseargs(message.content.slice(prefix.length + command.length));
if (!commands.has(command)) {
const jsonstring = fs.readFileSync("cfg/failresponses.json");
const failresponses = JSON.parse(jsonstring);
let random = Math.floor(Math.random() * failresponses.length);
message.reply(failresponses[random].replace("{command}", command));
let text = failresponses[random].replace("{command}", command);
if (text.length == 0) {
text = "you think you're funny, don't you?";
}
if (!message.content.includes("fortnite")) {
message.reply(text);
}
return;
}
log(
@ -131,9 +129,10 @@ export default function (message, client) {
sendMainMessage(
"messageCreate event produced error; see crashes.log for details."
);
console.log(err);
try {
fs.appendFileSync(
`../pepperbot/logs/crashes.log`,
`logs/crashes.log`,
`AT: ${Date()}`,
`ERROR: ${err}`,
`\n`

View file

@ -1,6 +1,7 @@
import { GatewayIntentBits, Partials, Client } from "discord.js";
import events from "./events/importEvents.js";
import register from "./register-commands.js";
import fs from "fs";
export const client = new Client({
intents: [
@ -76,6 +77,7 @@ client.on("messageCreate", async (message) => {
sendMainMessage(
"messageCreate event produced error; see crashes.log for details."
);
console.log(err);
try {
fs.appendFileSync(
`../pepperbot/logs/crashes.log`,

View file

@ -1,13 +1,14 @@
import discord from "discord.js";
import { default as log } from "./log.js";
import * as index from "../index.js";
import { IntegrationExpireBehavior } from "discord.js";
const client = index.client;
export async function sendMainMessage(message) {
try {
const channel = client.channels.cache.get("1148814162273763418");
channel.sendTyping();
const msg = await channel.send(message);
//channel.stopTyping();
return msg;
} catch (err) {
sendError(toString(err).slice(err.length - 1750, err.length));
@ -59,10 +60,20 @@ export async function sendMessage(channelId, message) {
let msg;
if (channel) {
try {
channel.sendTyping();
msg = await channel.send(message);
//channel.stopTyping();
return msg;
} catch (err) {
sendError(err.rawError.message);
try {
let msg = err.rawError.message;
sendError(msg);
} catch (err2) {
sendError(
"this shit is REALLY fucked, i have no clue wtf happened 😭😭😭"
);
}
console.log(err);
return undefined;
}
@ -73,12 +84,20 @@ export async function sendMessage(channelId, message) {
export async function reply(triggerMessage, message) {
try {
triggerMessage.channel.sendTyping();
let msg = await triggerMessage.reply(message);
//triggerMessage.channel.sendTyping();
return msg;
} catch (err) {
sendError(err.rawError.message);
console.log(err);
return undefined;
try {
let msg = err.rawError.message;
sendError(msg);
} catch (err2) {
sendError(
"this shit is REALLY fucked, i have no clue wtf happened 😭😭😭"
);
}
}
}