From cabdb07796a8c57abd25200adb7478fa180f239e Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sat, 4 Mar 2023 21:04:40 +1100 Subject: [PATCH] Will continue investigation later. --- src/client.ts | 11 ++++++----- src/index.ts | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/client.ts b/src/client.ts index 634312b..cc580f1 100644 --- a/src/client.ts +++ b/src/client.ts @@ -93,13 +93,14 @@ export default class TClient extends Client { async init(){ mongoose.set('strictQuery', true); await mongoose.connect(this.tokens.mongodb_uri, { + replicaSet: 'toastyy', autoIndex: true, - serverSelectionTimeoutMS: 12000, - socketTimeoutMS: 30000, - family: 4, keepAlive: true, - waitQueueTimeoutMS: 50000 - }).then(()=>console.log(this.logTime(), 'Successfully connected to MongoDB')).catch(()=>{console.log(this.logTime(), 'Failed to connect to MongoDB'); exec('pm2 stop Daggerbot')}) + serverSelectionTimeoutMS: 15000, + waitQueueTimeoutMS: 50000, + socketTimeoutMS: 30000, + family: 4 + }).then(()=>console.log(this.logTime(), 'Successfully connected to MongoDB')).catch((err)=>{console.error(this.logTime(), `Failed to connect to MongoDB\n${err.reason}`); exec('pm2 stop Daggerbot')}) await this.login(this.tokens.main); const commandFiles = fs.readdirSync('src/commands').filter(file=>file.endsWith('.ts')); for (const file of commandFiles){ diff --git a/src/index.ts b/src/index.ts index f73bf7e..8872ffb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -29,10 +29,10 @@ function DZ(error:Error, location:string){// Yes, I may have shiternet but I don const channel = client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel | null channel?.send({embeds: [new client.embed().setColor('#420420').setTitle('Error caught!').setFooter({text: location}).setDescription(`**Error:** \`${error.message}\`\n\n**Stack:** \`${`${error.stack}`.slice(0, 2500)}\``)]}) } -process.on('unhandledRejection', async(error: Error)=>DZ(error, 'unhandledRejection')); -process.on('uncaughtException', async(error: Error)=>DZ(error, 'uncaughtException')); -process.on('error', async(error: Error)=>DZ(error, 'process-error')); -client.on('error', async(error: Error)=>DZ(error, 'client-error')); +process.on('unhandledRejection', (error: Error)=>DZ(error, 'unhandledRejection')); +process.on('uncaughtException', (error: Error)=>DZ(error, 'uncaughtException')); +process.on('error', (error: Error)=>DZ(error, 'process-error')); +client.on('error', (error: Error)=>DZ(error, 'client-error')); // Daggerwin MP loop setInterval(async()=>{