Add error alerting in Discord, revert last fix to test alerting
All checks were successful
NodBot PE Dockerization / build (push) Successful in 20s

This commit is contained in:
Skylar Grant 2026-10-01 13:15:28 -04:00
parent 23a282a8a5
commit acfe540148
2 changed files with 33 additions and 6 deletions

View File

@ -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);
}
},
};

View File

@ -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);
});
}
};