From affdd9857279277e441c79fbb99504ee50b54947 Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Wed, 5 Nov 2025 18:35:48 -0500 Subject: [PATCH] Fixed errors loading default items --- README.md | 2 +- src/schemas/emoteSchema.js | 7 +++++-- src/schemas/tokebot/tokeCommandSchema.js | 19 ++++++++++++------- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3be348e..d04e2ca 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Canopy -0.4-INDEV +0.4-INDEV Hotfix 1 ========= Canopy - /ˈkæ.nə.pi/: diff --git a/src/schemas/emoteSchema.js b/src/schemas/emoteSchema.js index c059a0c..8a35dc5 100644 --- a/src/schemas/emoteSchema.js +++ b/src/schemas/emoteSchema.js @@ -51,8 +51,11 @@ const emoteSchema = new mongoose.Schema({ * Post-Save function, ensures all new emotes are broadcastes to actively connected clients */ emoteSchema.post('save', async function (next){ - //broadcast updated emotes - server.channelManager.broadcastSiteEmotes(); + //Ensure the channel manager is actually up + if(server.channelManager != null){ + //broadcast updated emotes + server.channelManager.broadcastSiteEmotes(); + } }); /** diff --git a/src/schemas/tokebot/tokeCommandSchema.js b/src/schemas/tokebot/tokeCommandSchema.js index 892b7d0..19283f8 100644 --- a/src/schemas/tokebot/tokeCommandSchema.js +++ b/src/schemas/tokebot/tokeCommandSchema.js @@ -36,15 +36,20 @@ const tokeCommandSchema = new mongoose.Schema({ * Pre-Save middleware, ensures tokebot receives all new toke commands */ tokeCommandSchema.pre('save', async function (next){ - //if the command was changed + //if the channel manager, chat handler, and chat post-processor are all loaded up... if(this.isModified("command")){ - //Get server tokebot object - const tokebot = server.channelManager.chatHandler.chatPreprocessor.tokebot; + if(server.channelManager != null && + server.channelManager.chatHandler != null && + server.channelManager.chatHandler.chatPreprocessor == null){ - //If tokebot is up and running - if(tokebot != null && tokebot.tokeCommands != null){ - //Pop the command on to the end - tokebot.tokeCommands.push(this.command); + //Get server tokebot object + const tokebot = server.channelManager.chatHandler.chatPreprocessor.tokebot; + + //If tokebot is up and running + if(tokebot != null && tokebot.tokeCommands != null){ + //Pop the command on to the end + tokebot.tokeCommands.push(this.command); + } } }