From c9163219175e7f7911204d74c1dcabe5af56ae55 Mon Sep 17 00:00:00 2001 From: AnxietyisReal <96593068+AnxietyisReal@users.noreply.github.com> Date: Sun, 10 Sep 2023 20:21:54 +1000 Subject: [PATCH] Fix fetch failing to get data due to slow host connection --- src/funcs/MPModule.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/funcs/MPModule.ts b/src/funcs/MPModule.ts index 27b39da..e7c54c0 100644 --- a/src/funcs/MPModule.ts +++ b/src/funcs/MPModule.ts @@ -32,7 +32,8 @@ export default async(client:TClient, Channel:string, Message:string, Server:TSer // Truncate unnecessary parts of the name for the MPServerCache // This is a mess, but it works. for (const filter of ['Official Daggerwin Game Server', 'Daggerwin Multifarm']) { - if (hitDSS.server.name.includes(filter)) client.MPServerCache[ServerName].name = ['Daggerwin', 'DagMF'][['Official Daggerwin Game Server', 'Daggerwin Multifarm'].indexOf(filter)]; + if (hitDSS.server?.name === undefined) return; + if (hitDSS.server?.name.includes(filter)) client.MPServerCache[ServerName].name = ['Daggerwin', 'DagMF'][['Official Daggerwin Game Server', 'Daggerwin Multifarm'].indexOf(filter)]; } //Timescale formatting @@ -89,6 +90,7 @@ export default async(client:TClient, Channel:string, Message:string, Server:TSer } } catch(err) { if (err.message === 'The operation was aborted due to timeout') return msg.edit({content: 'Connection timed out.', embeds: [serverErrorEmbed]}); + if (err.message === 'Cannot read properties of undefined (reading \'name\')') return msg.edit({content: 'Connection to the host has been disrupted.', embeds: [serverErrorEmbed]}); msg.edit({content: null, embeds: [serverErrorEmbed]}); console.log(client.logTime(), LogPrefix('MPModule'),`Failed to make a request for ${ServerName}:`, err.message) }