Adding some error handling
This commit is contained in:
parent
f1d65a65d1
commit
88b2ec26c9
@ -27,6 +27,7 @@ const dotCommandFiles = fs.readdirSync('./dot-commands/').filter(file => file.en
|
|||||||
|
|
||||||
// MySQL database connection
|
// MySQL database connection
|
||||||
const mysql = require('mysql');
|
const mysql = require('mysql');
|
||||||
|
try {
|
||||||
const db = new mysql.createPool({
|
const db = new mysql.createPool({
|
||||||
connectionLimit: 10,
|
connectionLimit: 10,
|
||||||
host: dbHost,
|
host: dbHost,
|
||||||
@ -35,6 +36,9 @@ const db = new mysql.createPool({
|
|||||||
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
13
main.js
@ -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);
|
Loading…
Reference in New Issue
Block a user