diff --git a/README.md b/README.md index ad89082..a0070c7 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/events/messageCreate.js b/src/events/messageCreate.js index 8704acb..95b55d7 100644 --- a/src/events/messageCreate.js +++ b/src/events/messageCreate.js @@ -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); + } + } })(); } diff --git a/src/index.js b/src/index.js index 6f81886..ebd7dac 100644 --- a/src/index.js +++ b/src/index.js @@ -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();