Adding some error handling
This commit is contained in:
parent
f1d65a65d1
commit
88b2ec26c9
20
functions.js
20
functions.js
@ -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 {
|
||||||
connectionLimit: 10,
|
const db = new mysql.createPool({
|
||||||
host: dbHost,
|
connectionLimit: 10,
|
||||||
user: dbUser,
|
host: dbHost,
|
||||||
password: dbPass,
|
user: dbUser,
|
||||||
database: dbName,
|
password: dbPass,
|
||||||
port: dbPort,
|
database: dbName,
|
||||||
});
|
port: dbPort,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
const functions = {
|
const functions = {
|
||||||
// Functions for managing and creating Collections
|
// Functions for managing and creating Collections
|
||||||
|
15
main.js
15
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
|
||||||
const commandData = fn.dot.getCommandData(message);
|
try {
|
||||||
console.log(commandData);
|
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) {
|
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