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
const mysql = require('mysql');
const db = new mysql.createPool({
connectionLimit: 10,
host: dbHost,
user: dbUser,
password: dbPass,
database: dbName,
port: dbPort,
});
try {
const db = new mysql.createPool({
connectionLimit: 10,
host: dbHost,
user: dbUser,
password: dbPass,
database: dbName,
port: dbPort,
});
} catch (error) {
console.error(error);
}
const functions = {
// Functions for managing and creating Collections

15
main.js
View File

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