mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-12-27 20:35:38 -05:00
Notify over DM channel regarding I/O issues
This commit is contained in:
parent
274eab725f
commit
702bf39df4
16
src/index.ts
16
src/index.ts
@ -8,13 +8,27 @@ import MPModule, {refreshTimerSecs} from './modules/MPModule.js';
|
|||||||
import UsernameHelper from './helpers/UsernameHelper.js';
|
import UsernameHelper from './helpers/UsernameHelper.js';
|
||||||
import {Punishment, RawGatewayPacket, RawMessageDelete, RawMessageUpdate} from 'src/interfaces';
|
import {Punishment, RawGatewayPacket, RawMessageDelete, RawMessageUpdate} from 'src/interfaces';
|
||||||
import {readFileSync} from 'node:fs';
|
import {readFileSync} from 'node:fs';
|
||||||
|
import {execSync} from 'node:child_process';
|
||||||
export const disabledChannels = ['548032776830582794', '541677709487505408', '949380187668242483'];
|
export const disabledChannels = ['548032776830582794', '541677709487505408', '949380187668242483'];
|
||||||
|
|
||||||
// Error handler
|
// Error handler
|
||||||
function _(error:Error, type:string) {
|
function _(error:Error, type:string) {
|
||||||
if (JSON.parse(readFileSync('src/errorBlocklist.json', 'utf8')).includes(error.message)) return;
|
if (JSON.parse(readFileSync('src/errorBlocklist.json', 'utf8')).includes(error.message)) return;
|
||||||
console.error(error);
|
console.error(error);
|
||||||
(client.channels.resolve(client.config.dcServer.channels.errors) as Discord.TextChannel | null)?.send({embeds: [new client.embed().setColor('#560000').setTitle('Error caught!').setFooter({text: 'Error type: ' + type}).setDescription(`**Error:**\n\`\`\`${error.message}\`\`\`**Stack:**\n\`\`\`${`${UsernameHelper(error.stack)}`.slice(0, 2500)}\`\`\``)]})
|
(client.channels.resolve(client.config.dcServer.channels.errors) as Discord.TextChannel | null)?.send({embeds: [new client.embed().setColor('#560000').setTitle('Error caught!').setFooter({text: `Error type: ${type}`}).setDescription(`**Error:**\n\`\`\`${error.message}\`\`\`**Stack:**\n\`\`\`${`${UsernameHelper(error.stack)}`.slice(0, 2500)}\`\`\``)]})
|
||||||
|
|
||||||
|
if (error.message.includes('could not fdatasync file')) {
|
||||||
|
client.users.createDM(client.config.whitelist[1]).then(u=>u.send({
|
||||||
|
embeds: [new client.embed()
|
||||||
|
.setColor(client.config.embedColorYellow)
|
||||||
|
.setTitle('Database error')
|
||||||
|
.setDescription('I couldn\'t write to the database due to filesystem issues, shutting down...')
|
||||||
|
.setFields({name: 'Error message', value: `\`\`\`${error.message}\`\`\``})
|
||||||
|
.setFooter({text: `Error type: ${type}`})
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
setTimeout(()=>execSync('pm2 stop 0', {shell: 'bash'}), 5500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
process.on('unhandledRejection', (error: Error)=>_(error, 'unhandledRejection'));
|
process.on('unhandledRejection', (error: Error)=>_(error, 'unhandledRejection'));
|
||||||
process.on('uncaughtException', (error: Error)=>_(error, 'uncaughtException'));
|
process.on('uncaughtException', (error: Error)=>_(error, 'uncaughtException'));
|
||||||
|
Loading…
Reference in New Issue
Block a user