added a major crash prevention system, also responses to failed commands are now randomized

This commit is contained in:
ayeuhugyu 2024-02-16 22:22:57 -08:00
parent 9f6014ba4e
commit 2c2fd8b5ff
3 changed files with 172 additions and 7 deletions

View file

@ -17,6 +17,10 @@ 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.15 - added p/recent and p/rejoin, p/recent sends the most recently deleted message, p/rejoin calls rejoin function on voice connections. also added some broken code for a voiceStateUpdate event but im too lazy to fix it so ill do that basically never. also deleted some useless line from .gitignore
1.15.1 - fixed exploit with recursive p/recents
1.15.2 - fixed voiceStateUpdate event, also errors now ping me (please don't abuse i will disable it if you do)

View file

@ -4,9 +4,51 @@ dotenv.config();
import { default as log } from "../util/log.js";
import fs from "fs";
import discord from "discord.js";
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)",
];
const commandFiles = fs
.readdirSync("src/commands/")
.filter((file) => file.endsWith(".js"));
@ -29,6 +71,17 @@ function parseargs(string) {
const prefix = process.env.PREFIX;
async function sendMainMessage(message) {
try {
const channel = index.client.channels.cache.get("1148814162273763418");
const msg = await channel.send(message);
return msg;
} catch (err) {
console.log(err);
return undefined;
}
}
export default function (message, client) {
const blacklistnosplit = fs.readFileSync("data/blacklisted.log", "utf8");
const blacklist = blacklistnosplit.split("\n");
@ -60,7 +113,8 @@ export default function (message, client) {
const args = parseargs(message.content.slice(prefix.length + command.length));
if (!commands.has(command)) {
message.reply("idiot thats not a command");
let random = Math.floor(Math.random() * failresponses.length);
message.reply(failresponses[random].replace("{command}", command));
return;
}
log(
@ -71,6 +125,22 @@ export default function (message, client) {
true
);
(async () => {
commands.get(command).execute(message, args, client);
try {
commands.get(command).execute(message, args, client);
} catch (err) {
sendMainMessage(
"messageCreate event produced error; see crashes.log for details."
);
try {
fs.appendFileSync(
`../pepperbot/logs/crashes.log`,
`AT: ${Date()}`,
`ERROR: ${err}`,
`\n`
);
} catch (err2) {
console.log(err2);
}
}
})();
}

View file

@ -14,28 +14,119 @@ export const client = new Client({
partials: [Partials.Message, Partials.Channel],
});
async function sendMainMessage(message) {
try {
const channel = client.channels.cache.get("1148814162273763418");
const msg = await channel.send(message);
return msg;
} catch (err) {
console.log(err);
return undefined;
}
}
client.on("ready", (rclient) => {
events.ready(rclient);
});
client.on("guildMemberAdd", (member) => {
events.guildMemberAdd(member, client);
try {
events.guildMemberAdd(member, client);
} catch (err) {
sendMainMessage(
"guildMemberAdd event produced error; see crashes.log for details."
);
try {
fs.appendFileSync(
`../logs/crashes.log`,
`AT: ${Date()}`,
`ERROR: ${err}`,
`\n`
);
} catch (err2) {
console.log(err2);
}
}
});
client.on("messageDelete", async (message) => {
events.messageDelete(message, client);
try {
events.messageDelete(message, client);
} catch (err) {
sendMainMessage(
"messageDelete event produced error; see crashes.log for details."
);
try {
fs.appendFileSync(
`../pepperbot/logs/crashes.log`,
`AT: ${Date()}`,
`ERROR: ${err}`,
`\n`
);
} catch (err2) {
console.log(err2);
}
}
});
client.on("messageCreate", async (message) => {
events.messageCreate(message, client);
try {
events.messageCreate(message, client);
} catch (err) {
sendMainMessage(
"messageCreate event produced error; see crashes.log for details."
);
try {
fs.appendFileSync(
`../pepperbot/logs/crashes.log`,
`AT: ${Date()}`,
`ERROR: ${err}`,
`\n`
);
} catch (err2) {
console.log(err2);
}
}
});
client.on("interactionCreate", (interaction) => {
events.interactionCreate(interaction, client);
try {
events.interactionCreate(interaction, client);
} catch (err) {
sendMainMessage(
"interactionCreate event produced error; see crashes.log for details."
);
try {
fs.appendFileSync(
`../pepperbot/logs/crashes.log`,
`AT: ${Date()}`,
`ERROR: ${err}`,
`\n`
);
} catch (err2) {
console.log(err2);
}
}
});
client.on("voiceStateUpdate", (oldState, newState) => {
events.voiceStateUpdate(oldState, newState, client);
try {
events.voiceStateUpdate(oldState, newState, client);
} catch (err) {
sendMainMessage(
"voiceStateUpdate event produced error; see crashes.log for details."
);
try {
fs.appendFileSync(
`../pepperbot/logs/crashes.log`,
`AT: ${Date()}`,
`ERROR: ${err}`,
`\n`
);
} catch (err2) {
console.log(err2);
}
}
});
register();