Closed lapochka8 closed 10 months ago
Seem to have fixed the issue by modifying the first half of factory.js
import` fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
import Discord from 'discord.js';
import sequelize from 'sequelize';
import AwnAPI from './utils/awn-api.js';
import Logger from 'core/logger';
import SquadServer from './index.js';
import Plugins from './plugins/index.js';
const { Sequelize } = sequelize;
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default class SquadServerFactory {
static async buildFromConfig(config) {
if (config.logger) {
Logger.setTimeStamps(config.logger.timestamps ? config.logger.timestamps : false);
// setup logging levels
for (const [module, verboseness] of Object.entries(config.logger.verboseness || {})) {
Logger.setVerboseness(module, verboseness);
}
for (const [module, color] of Object.entries(config.logger.colors || {})) {
Logger.setColor(module, color);
}
}
const plugins = await Plugins.getPlugins();
for (const plugin of Object.keys(plugins)) {
Logger.setColor(plugin, 'magentaBright');
}
// create SquadServer
Logger.verbose('SquadServerFactory', 1, 'Creating SquadServer...');
const server = new SquadServer(config.server);
// initialise connectors
Logger.verbose('SquadServerFactory', 1, 'Preparing connectors...');
const connectors = {};
for (const pluginConfig of config.plugins) {
if (!pluginConfig.enabled) continue;
if (!plugins[pluginConfig.plugin])
throw new Error(`Plugin ${pluginConfig.plugin} does not exist.`);
const Plugin = plugins[pluginConfig.plugin];
for (const [optionName, option] of Object.entries(Plugin.optionsSpecification)) {
// ignore non connectors
if (!option.connector) continue;
// check the connector is listed in the options
if (!(optionName in pluginConfig))
throw new Error(
`${Plugin.name}: ${optionName} (${option.connector} connector) is missing.`
);
// get the name of the connector
const connectorName = pluginConfig[optionName];
// skip already created connectors
if (connectors[connectorName]) continue;
// create the connector
connectors[connectorName] = await SquadServerFactory.createConnector(
server,
option.connector,
connectorName,
config.connectors ? config.connectors[connectorName] : undefined
);
}
}
// initialise plugins
Logger.verbose('SquadServerFactory', 1, 'Initialising plugins...');
for (const pluginConfig of config.plugins) {
if (!pluginConfig.enabled) continue;
if (!plugins[pluginConfig.plugin])
throw new Error(`Plugin ${pluginConfig.plugin} does not exist.`);
const Plugin = plugins[pluginConfig.plugin];
Logger.verbose('SquadServerFactory', 1, `Initialising ${Plugin.name}...`);
const plugin = new Plugin(server, pluginConfig, connectors);
// allow the plugin to do any asynchronous work needed before it can be mounted
await plugin.prepareToMount();
server.plugins.push(plugin);
}
return server;
}
}
Came across another issue with DiscordToken not working. Any advice?
This appears to be an config issue. If you require advanced support please ask in the discord. You will get more info as you are only giving us pieces at a time.
Description of Issue
Upon running node index.js, an error appears,
[SquadServerFactory][1] Reading config file... [SquadServerFactory][1] Parsing config string... file:///C:/Users/admin/Desktop/SquadJS-3.7.0/SquadJS-3.7.0/squad-server/factory.js:20 Logger.setTimeStamps(config.logger.timestamps ? config.logger.timestamps : false); ^
TypeError: Cannot read properties of undefined (reading 'timestamps') at SquadServerFactory.buildFromConfig (file:///C:/Users/admin/Desktop/SquadJS-3.7.0/SquadJS-3.7.0/squad-server/factory.js:20:40) at SquadServerFactory.buildFromConfigString (file:///C:/Users/admin/Desktop/SquadJS-3.7.0/SquadJS-3.7.0/squad-server/factory.js:154:31) at SquadServerFactory.buildFromConfigFile (file:///C:/Users/admin/Desktop/SquadJS-3.7.0/SquadJS-3.7.0/squad-server/factory.js:165:31) at main (file:///C:/Users/admin/Desktop/SquadJS-3.7.0/SquadJS-3.7.0/index.js:14:32) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Errors or Screenshots of Issue
Squad Information
If potentially relevant, please provide regarding the state of the Squad server at the time of error, e.g. the current layer.
System Information