Descriptive error messages
This commit is contained in:
parent
dea0915d9b
commit
6d3659f84f
36
index.js
36
index.js
|
@ -794,11 +794,11 @@ dcClient.on("guildMemberRemove", (member) => {
|
||||||
deleteExtension(result.result.fetchExtension.user.extension).then((delResult) => {
|
deleteExtension(result.result.fetchExtension.user.extension).then((delResult) => {
|
||||||
sendLog(`${colors.cyan("[INFO]")} Deleted extension ${result.result.fetchExtension.user.extension} because the user left the server`);
|
sendLog(`${colors.cyan("[INFO]")} Deleted extension ${result.result.fetchExtension.user.extension} because the user left the server`);
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`);
|
sendLog(`${colors.red("[ERROR]")} Error deleting ext ${error}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`);
|
sendLog(`${colors.red("[ERROR]")} Error looking up extension to delete ${error}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -890,7 +890,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
// The user doesn't have an extension, create one
|
// The user doesn't have an extension, create one
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`)
|
sendLog(`${colors.red("[ERROR]")} Error looking up extension ${error}`)
|
||||||
interaction.editReply({
|
interaction.editReply({
|
||||||
content: "You don't have an extension!",
|
content: "You don't have an extension!",
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
|
@ -1054,7 +1054,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
interaction.editReply(`Error adding you to the paging group: ${error}`);
|
interaction.editReply(`Error adding you to the paging group: ${error}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`);
|
sendLog(`${colors.red("[ERROR]")} Error adding user to pg group ${error}`);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// They're already in the group, return an ephemeral message saying so
|
// They're already in the group, return an ephemeral message saying so
|
||||||
|
@ -1065,7 +1065,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
interaction.editReply(`Error adding you to the paging group: ${error}`);
|
interaction.editReply(`Error adding you to the paging group: ${error}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`);
|
sendLog(`${colors.red("[ERROR]")} Error looking up user in pg group ${error}`);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case "remove":
|
case "remove":
|
||||||
|
@ -1089,12 +1089,12 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
});
|
});
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
interaction.editReply(`Error removing you from the paging group: ${error}`);
|
interaction.editReply(`Error removing you from the paging group: ${error}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`);
|
sendLog(`${colors.red("[ERROR]")} Error while removing user from page group ${error}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
interaction.editReply(`Error removing you from the paging group: ${error}`);
|
interaction.editReply(`Error removing you from the paging group: ${error}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`);
|
sendLog(`${colors.red("[ERROR]")} Error while looking if user is in pg grp ${error}`);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1120,7 +1120,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
content: `Error killing calls: ${err}`,
|
content: `Error killing calls: ${err}`,
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
});
|
});
|
||||||
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
sendLog(`${colors.red("[ERROR]")} Error killing calls ${err}`);
|
||||||
}
|
}
|
||||||
stream.on("exit", (code) => {
|
stream.on("exit", (code) => {
|
||||||
interaction.reply({
|
interaction.reply({
|
||||||
|
@ -1139,13 +1139,13 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
sshConn.exec("fwconsole reload", (err, stream) => {
|
sshConn.exec("fwconsole reload", (err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.editReply(`Error reloading FreePBX: ${err}`);
|
interaction.editReply(`Error reloading FreePBX: ${err}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
sendLog(`${colors.red("[ERROR]")} Error manually reloading fwconsole ${err}`);
|
||||||
}
|
}
|
||||||
stream.on('exit', (code, signal) => {
|
stream.on('exit', (code, signal) => {
|
||||||
sshConn.exec("asterisk -x 'core reload'", (err, stream) => {
|
sshConn.exec("asterisk -x 'core reload'", (err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.editReply(`Error reloading Asterisk: ${err}`);
|
interaction.editReply(`Error reloading Asterisk: ${err}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
sendLog(`${colors.red("[ERROR]")} Error manually reloading asterisk ${err}`);
|
||||||
}
|
}
|
||||||
stream.on('exit', (code, signal) => {
|
stream.on('exit', (code, signal) => {
|
||||||
interaction.editReply("Reloaded FreePBX and Asterisk!");
|
interaction.editReply("Reloaded FreePBX and Asterisk!");
|
||||||
|
@ -1162,7 +1162,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
sshConn.exec("reboot", (err, stream) => {
|
sshConn.exec("reboot", (err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.editReply(`Error rebooting server: ${err}`);
|
interaction.editReply(`Error rebooting server: ${err}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
sendLog(`${colors.red("[ERROR]")} Error rebooting? ${err}`);
|
||||||
}
|
}
|
||||||
stream.on('exit', (code, signal) => {
|
stream.on('exit', (code, signal) => {
|
||||||
interaction.editReply("Rebooting server...\nThe bot will now disconnect and restart in 1 minute. Please stand by...").then(() => {
|
interaction.editReply("Rebooting server...\nThe bot will now disconnect and restart in 1 minute. Please stand by...").then(() => {
|
||||||
|
@ -1203,7 +1203,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
sshConn.exec(`fwconsole ${cmd}`, (err, stream) => {
|
sshConn.exec(`fwconsole ${cmd}`, (err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.editReply(`Error running command: ${err}`);
|
interaction.editReply(`Error running command: ${err}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
sendLog(`${colors.red("[ERROR]")} Error running fwconsole command ${err}`);
|
||||||
}
|
}
|
||||||
outputStream = ""
|
outputStream = ""
|
||||||
stream.on("data", (data) => {
|
stream.on("data", (data) => {
|
||||||
|
@ -1256,7 +1256,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
sshConn.exec(`asterisk -x '${cmd2}'`, (err, stream) => {
|
sshConn.exec(`asterisk -x '${cmd2}'`, (err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.editReply(`Error running command: ${err}`);
|
interaction.editReply(`Error running command: ${err}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
sendLog(`${colors.red("[ERROR]")} Error running asterisk cli command ${err}`);
|
||||||
}
|
}
|
||||||
outputStream = ""
|
outputStream = ""
|
||||||
stream.on("data", (data) => {
|
stream.on("data", (data) => {
|
||||||
|
@ -1293,7 +1293,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
sshConn.exec(cmd3, (err, stream) => {
|
sshConn.exec(cmd3, (err, stream) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.editReply(`Error running command: ${err}`);
|
interaction.editReply(`Error running command: ${err}`);
|
||||||
sendLog(`${colors.red("[ERROR]")} ${err}`);
|
sendLog(`${colors.red("[ERROR]")} Error running shell command ${err}`);
|
||||||
}
|
}
|
||||||
// if timeout is set, set a timeout before
|
// if timeout is set, set a timeout before
|
||||||
//timeout = setTimeout(() => {
|
//timeout = setTimeout(() => {
|
||||||
|
@ -1525,7 +1525,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
// The user doesn't have an extension, create one
|
// The user doesn't have an extension, create one
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`)
|
sendLog(`${colors.red("[ERROR]")} Error finding extension for user? ${error}`)
|
||||||
interaction.editReply({
|
interaction.editReply({
|
||||||
content: "You don't have an extension!",
|
content: "You don't have an extension!",
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
|
@ -1551,7 +1551,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
}
|
}
|
||||||
}).catch((error) => {
|
}).catch((error) => {
|
||||||
// The user doesn't have an extension, create one
|
// The user doesn't have an extension, create one
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error}`)
|
sendLog(`${colors.red("[ERROR]")} User has not ext (lookup) ${error}`)
|
||||||
interaction.editReply({
|
interaction.editReply({
|
||||||
content: "That user doesn't have an extension!",
|
content: "That user doesn't have an extension!",
|
||||||
ephemeral: true
|
ephemeral: true
|
||||||
|
@ -1664,7 +1664,7 @@ dcClient.on('interactionCreate', async interaction => {
|
||||||
// Lets actually handle exceptions now
|
// Lets actually handle exceptions now
|
||||||
process.on('unhandledRejection', (error) => {
|
process.on('unhandledRejection', (error) => {
|
||||||
// Log a full error with line number
|
// Log a full error with line number
|
||||||
sendLog(`${colors.red("[ERROR]")} ${JSON.stringify(error)}`);
|
sendLog(`${colors.red("[ERROR]")} Unhandled Rejection ${error}`);
|
||||||
// If config.ntfyUrl is set, Send the exception to ntfy
|
// If config.ntfyUrl is set, Send the exception to ntfy
|
||||||
if (config.ntfyUrl) fetch(config.ntfyUrl, {
|
if (config.ntfyUrl) fetch(config.ntfyUrl, {
|
||||||
method: 'POST', // PUT works too
|
method: 'POST', // PUT works too
|
||||||
|
@ -1679,7 +1679,7 @@ process.on('unhandledRejection', (error) => {
|
||||||
|
|
||||||
process.on('uncaughtException', (error) => {
|
process.on('uncaughtException', (error) => {
|
||||||
// Log a full error with line number
|
// Log a full error with line number
|
||||||
sendLog(`${colors.red("[ERROR]")} ${error.stack}`);
|
sendLog(`${colors.red("[ERROR]")} Uncaught Exception ${error.stack}`);
|
||||||
// If config.ntfyUrl is set, Send the exception to ntfy
|
// If config.ntfyUrl is set, Send the exception to ntfy
|
||||||
if (config.ntfyUrl) fetch(config.ntfyUrl, {
|
if (config.ntfyUrl) fetch(config.ntfyUrl, {
|
||||||
method: 'POST', // PUT works too
|
method: 'POST', // PUT works too
|
||||||
|
|
Loading…
Reference in a new issue