Adding some error handling

This commit is contained in:
Skylar Grant 2022-06-03 14:44:45 -04:00
parent f1d65a65d1
commit 88b2ec26c9
2 changed files with 25 additions and 10 deletions

View File

@ -27,14 +27,18 @@ const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.en
// MySQL database connection // MySQL database connection
const mysql = require('mysql'); const mysql = require('mysql');
const db = new mysql.createPool({ try {
const db = new mysql.createPool({
connectionLimit: 10, connectionLimit: 10,
host: dbHost, host: dbHost,
user: dbUser, user: dbUser,
password: dbPass, password: dbPass,
database: dbName, database: dbName,
port: dbPort, port: dbPort,
}); });
} catch (error) {
console.error(error);
}
const functions = { const functions = {
// Functions for managing and creating Collections // Functions for managing and creating Collections

13
main.js
View File

@ -191,8 +191,14 @@ client.on('messageCreate', message => {
if (lowerContent.includes('ligma')) message.reply('ligma balls, goteem'); if (lowerContent.includes('ligma')) message.reply('ligma balls, goteem');
// Break the message down into its components and analyze it // Break the message down into its components and analyze it
try {
const commandData = fn.dot.getCommandData(message); const commandData = fn.dot.getCommandData(message);
console.log(commandData); if(isDev) console.log(commandData);
} catch(error) {
console.error(error);
message.reply('There was an error trying to execute that command.');
}
if (commandData.isValid && commandData.isCommand) { if (commandData.isValid && commandData.isCommand) {
try { try {
@ -206,4 +212,9 @@ client.on('messageCreate', message => {
return; return;
}); });
process.on("uncaughtException", err => {
console.error('There was an uncaught error: ', err);
process.exit(1);
});
client.login(token); client.login(token);