From acfe540148a74b84f7537ba3c238ecbc009abfb0 Mon Sep 17 00:00:00 2001 From: Skylar Grant Date: Thu, 1 Oct 2026 13:15:28 -0400 Subject: [PATCH] Add error alerting in Discord, revert last fix to test alerting --- dot-commands/request.js | 11 ++++++++--- functions.js | 28 +++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/dot-commands/request.js b/dot-commands/request.js index 67f2a7a..1bf7f82 100644 --- a/dot-commands/request.js +++ b/dot-commands/request.js @@ -13,12 +13,17 @@ module.exports = { try { fn.upload.request(requester, requestText, messageUrl, message.client); // Set the content to sent a text embed notifying the user of success - commandData.content = `Your request has been submitted!\nRequest: ${requestText}`; - message.reply(fn.embeds.text(commandData)); + commandData.content = `Your request has been submitted!\nRequest: ${request}`; + const replyEmbed = fn.embeds.text(commandData); + message.reply({ embeds: [ replyEmbed ]}); } catch(err) { console.error(err); commandData.content = "An error occurred while saving the request, please try again later."; - message.reply(fn.embeds.text(commandData)); + const replyEmbed = fn.embeds.text(commandData); + message.reply({ embeds: [ replyEmbed ]}); + + const errorEmbed = fn.embeds.error(`An error has occurred in command ${this.name}:\n${JSON.stringify(err)}`); + fn.sendAlert(errorEmbed); } }, }; \ No newline at end of file diff --git a/functions.js b/functions.js index 7061a53..b83bff7 100644 --- a/functions.js +++ b/functions.js @@ -9,6 +9,7 @@ const dbPass = process.env.dbPass; const dbPort = process.env.dbPort; const isDev = process.env.isDev; const ownerId = process.env.ownerId; +const statusChannelId = process.env.statusChannelId; // filesystem const fs = require('fs'); @@ -302,11 +303,13 @@ const functions = { return { embeds: [jointsEmbed], components: [jointsPageAR], ephemeral: true }; }, text(commandData) { - return { embeds: [new Discord.MessageEmbed() - .setAuthor({name: commandData.command}) + const textEmbed = new Discord.MessageEmbed() + .setAuthor({ name: commandData.command }) .setDescription(commandData.content) .setTimestamp() - .setFooter({text: commandData.author})]}; + .setFooter({text: commandData.author}); + + return textEmbed; }, requests(commandData, indexedRequests) { const requestsEmbed = new Discord.MessageEmbed() @@ -458,6 +461,14 @@ const functions = { .setDescription('* Data Collection – NodBot does collect personal data, including but not limited to: location, IP address, MAC address, physical address, mother\'s maiden name, social security number, credit card numbers, phone fingerprints, physical fingerprints, penis length and girth, first pet\'s name, city where you met your spouse, and city where your parents met.\n* Payment Info – All payments are processed through a sketchy-looking PayPal link. NodBot and voidf1sh take no responsibility if your bank, CPA, lawyer, or local PD calls you afterward.\n* Chat Logs – NodBot may or may not remember every dumbass thing you’ve ever typed. Just assume it does.\n* Third-Party Sharing – Your usage data may be shared with savage\'s mom\n* Right to Be Forgotten – You can request NodBot forget your existence, but that requires a one-time processing fee of $50.'); return { content: announcement, embeds: [ embed1, embed2 ] }; + }, + error(errorText) { + const errorEmbed = new Discord.MessageEmbed() + .setAuthor({ name: "Error!" }) + .setDescription({ text: errorText }) + .setFooter({ text: appVersion }); + + return errorEmbed; } }, collect: { @@ -909,6 +920,17 @@ const functions = { } const errorId = digits.join(""); return errorId; + }, + async sendAlert(embed) { + const statusChannel = await client.channels.fetch(statusChannelId) + .catch(err => { + console.error(err); + }); + + await statusChannel.send({ embeds: [ embed ] }) + .catch(err => { + console.error(err); + }); } };