From 193f7f2bf8d9110475ea51aa0b1dfb527dd276f1 Mon Sep 17 00:00:00 2001 From: Izwzyzx <184772711+Izwzyzx@users.noreply.github.com> Date: Wed, 16 Oct 2024 16:18:03 -0500 Subject: [PATCH] Improved fallback for database commands --- Onequestionmark.hx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Onequestionmark.hx b/Onequestionmark.hx index cb98fe8..e84bd59 100644 --- a/Onequestionmark.hx +++ b/Onequestionmark.hx @@ -41,7 +41,7 @@ class Onequestionmark { hugDB = Json.parse(File.getContent("hug-db.json")); } else { Sys.println('[${timestamp()}] Did not find hug-db.json, skipping'); - hugDB = ["https://cdn.discordapp.com/attachments/270113422232911883/445026464623099907/brohugbump.gif"]; // Fallback + hugDB = []; // Fallback } if (FileSystem.exists("motd-db.json")) { @@ -49,7 +49,7 @@ class Onequestionmark { motdDB = Json.parse(File.getContent("motd-db.json")); } else { Sys.println('[${timestamp()}] Did not find motd-db.json, skipping'); - motdDB = Json.parse('{"sunday": [],"monday": [],"tuesday": [],"wednesday": [],"thursday": [],"friday": [],"saturday": []}'); // Fallback + motdDB = Json.parse('{}'); // Fallback } if (FileSystem.exists("yesno-db.json")) { @@ -277,13 +277,19 @@ class Onequestionmark { m.reply({content:"https://cdn.discordapp.com/attachments/1071547517847732305/1147983375701921892/opinions.jpg"}, false); // Image database commands case "hug": - m.reply({content:'🫂 *hugs ${msg}*\n${hugDB[randInt(0, hugDB.length-1)]}'}, false); + if (hugDB.length > 0) { + m.reply({content:'🫂 *hugs ${msg}*\n${hugDB[randInt(0, hugDB.length-1)]}'}, false); + } case "yes": var yes = yesnoDB.yes; - m.reply({content:'${yes[randInt(0, yes.length-1)]}'}, false); + if (yes.length > 0) { + m.reply({content:'${yes[randInt(0, yes.length-1)]}'}, false); + } case "no": var no = yesnoDB.no; - m.reply({content:'${no[randInt(0, no.length-1)]}'}, false); + if (no.length > 0) { + m.reply({content:'${no[randInt(0, no.length-1)]}'}, false); + } // Echobox case "echobox": // Create Echobox array for the server if missing