Fixed initial default toke not loading into DB properly on server first boot.
This commit is contained in:
parent
de11803cea
commit
eb8ada7fa0
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,6 +3,7 @@ log/crash/*
|
||||||
www/doc/*/*
|
www/doc/*/*
|
||||||
package-lock.json
|
package-lock.json
|
||||||
config.json
|
config.json
|
||||||
|
config.json.old
|
||||||
state.json
|
state.json
|
||||||
chatexamples.txt
|
chatexamples.txt
|
||||||
server.cert
|
server.cert
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
//Dailymotion and Vimeo could work using official apis w/o keys, but you wouldn't have any raw file playback options :P
|
//Dailymotion and Vimeo could work using official apis w/o keys, but you wouldn't have any raw file playback options :P
|
||||||
"ytdlpPath": "/home/canopy/.local/pipx/venvs/yt-dlp/bin/yt-dlp",
|
"ytdlpPath": "/home/canopy/.local/pipx/venvs/yt-dlp/bin/yt-dlp",
|
||||||
//Be careful with what you keep in secrets, you should use special chars, but test your deployment, as some chars may break account registration
|
//Be careful with what you keep in secrets, you should use special chars, but test your deployment, as some chars may break account registration
|
||||||
//An update to either kill the server and bitch it's planned so it's not so confusing for new admins
|
//An update to either kill the server and bitch about the issue in console is planned so it's not so confusing for new admins
|
||||||
//Session secret used to secure session keys
|
//Session secret used to secure session keys
|
||||||
"sessionSecret": "CHANGE_ME",
|
"sessionSecret": "CHANGE_ME",
|
||||||
//Altacha secret used to generate altcha challenges
|
//Altacha secret used to generate altcha challenges
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ const {mongoose} = require('mongoose');
|
||||||
//Local Imports
|
//Local Imports
|
||||||
const defaultTokes = require("../../../defaultTokes.json");
|
const defaultTokes = require("../../../defaultTokes.json");
|
||||||
const server = require('../../server');
|
const server = require('../../server');
|
||||||
|
const loggerUtils = require('../../utils/loggerUtils');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mongoose Schema representing a toke command
|
* Mongoose Schema representing a toke command
|
||||||
|
|
@ -40,8 +41,11 @@ tokeCommandSchema.pre('save', async function (next){
|
||||||
//Get server tokebot object
|
//Get server tokebot object
|
||||||
const tokebot = server.channelManager.chatHandler.commandPreprocessor.tokebot;
|
const tokebot = server.channelManager.chatHandler.commandPreprocessor.tokebot;
|
||||||
|
|
||||||
//Pop the command on to the end
|
//If tokebot is up and running
|
||||||
tokebot.tokeCommands.push(this.command);
|
if(tokebot != null && tokebot.tokeCommands != null){
|
||||||
|
//Pop the command on to the end
|
||||||
|
tokebot.tokeCommands.push(this.command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -92,6 +96,7 @@ tokeCommandSchema.statics.loadDefaults = async function(){
|
||||||
|
|
||||||
//Ensure default comes first (.bind(this) doesn't seem to work here...)
|
//Ensure default comes first (.bind(this) doesn't seem to work here...)
|
||||||
await registerToke(defaultTokes.default);
|
await registerToke(defaultTokes.default);
|
||||||
|
|
||||||
//For each entry in the defaultTokes.json file
|
//For each entry in the defaultTokes.json file
|
||||||
defaultTokes.array.forEach(registerToke);
|
defaultTokes.array.forEach(registerToke);
|
||||||
|
|
||||||
|
|
@ -108,9 +113,9 @@ tokeCommandSchema.statics.loadDefaults = async function(){
|
||||||
|
|
||||||
}catch(err){
|
}catch(err){
|
||||||
if(toke != null){
|
if(toke != null){
|
||||||
console.log(`Error loading toke command: '!${toke}'`);
|
loggerUtils.dumpError(err);
|
||||||
}else{
|
}else{
|
||||||
console.log("Error, null toke!");
|
loggerUtils.consoleWarn("Error, null toke!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue