Team-Silver-Sphere / SquadJS

Squad Server Script Framework
Boost Software License 1.0
166 stars 124 forks source link

TypeError: Cannot read properties of undefined (reading 'cache') #369

Closed denizetkar closed 3 months ago

denizetkar commented 3 months ago

Description of Issue

SquadJS randomly crashes due to a bug in discord.js dependency, likely caused by SquadJS.

Note that I'm pretty much using vanilla SquadJS, with only the following switch plugin in addition:

Here is my anonymized config.json:

{
  "server": {
    "id": 1,
    "host": "127.0.0.1",
    "queryPort": 27165,
    "rconPort": 21114,
    "rconPassword": "****",
    "logReaderMode": "tail",
    "logDir": "C:/steamcmd/squad_server/SquadGame/Saved/Logs",
    "ftp": {
      "host": "xxx.xxx.xxx.xxx",
      "port": 21,
      "user": "FTP Username",
      "password": "FTP Password",
      "useListForSize": false
    },
    "adminLists": [
      {
        "type": "local",
        "source": "C:/steamcmd/squad_server/SquadGame/ServerConfig/Admins.cfg"
      }
    ]
  },
  "connectors": {
    "discord": "****",
    "awnAPI": {
      "orgID": "YourOrgID",
      "creds": {
        "username": "AwnUsername",
        "password": "AwnPassword"
      }
    },
    "mysql": {
      "host": "host",
      "port": 3306,
      "username": "squadjs",
      "password": "password",
      "database": "squadjs",
      "dialect": "mysql"
    },
    "sqlite": {
      "dialect": "sqlite",
      "storage": "C:/Users/<USERNAME>/Desktop/SquadServer/SquadJS/db.sqlite"
    }
  },
  "plugins": [
    {
      "plugin": "AutoKickUnassigned",
      "enabled": true,
      "warningMessage": "Join a squad, you are unassigned and will be kicked",
      "kickMessage": "Unassigned - automatically removed",
      "frequencyOfWarnings": 30,
      "unassignedTimer": 360,
      "playerThreshold": 93,
      "roundStartDelay": 900,
      "ignoreAdmins": false,
      "ignoreWhitelist": false
    },
    {
      "plugin": "AutoTKWarn",
      "enabled": true,
      "attackerMessage": "Please apologise for ALL TKs in ALL chat!",
      "victimMessage": "You were killed by your own team."
    },
    {
      "plugin": "CBLInfo",
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "threshold": 6
    },
    {
      "plugin": "ChatCommands",
      "enabled": false,
      "commands": [
        {
          "command": "squadjs",
          "type": "warn",
          "response": "This server is powered by SquadJS.",
          "ignoreChats": []
        }
      ]
    },
    {
      "plugin": "DBLog",
      "enabled": false,
      "database": "mysql",
      "overrideServerID": null
    },
    {
      "plugin": "DiscordAdminBroadcast",
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "color": 16761867
    },
    {
      "plugin": "DiscordAdminCamLogs",
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "color": 16761867
    },
    {
      "plugin": "DiscordAdminRequest",
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "ignoreChats": [],
      "ignorePhrases": [],
      "command": "admin",
      "pingGroups": [],
      "pingHere": false,
      "pingDelay": 60000,
      "color": 16761867,
      "warnInGameAdmins": false,
      "showInGameAdmins": true
    },
    {
      "plugin": "DiscordChat",
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "chatColors": {},
      "color": 16761867,
      "ignoreChats": ["ChatSquad"]
    },
    {
      "plugin": "DiscordDebug",
      "enabled": false,
      "discordClient": "discord",
      "channelID": "****",
      "events": []
    },
    {
      "plugin": "DiscordFOBHABExplosionDamage",
      "enabled": false,
      "discordClient": "discord",
      "channelID": "",
      "color": 16761867
    },
    {
      "plugin": "DiscordKillFeed",
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "color": 16761867,
      "disableCBL": false
    },
    {
      "plugin": "DiscordPlaceholder",
      "enabled": false,
      "discordClient": "discord",
      "command": "!placeholder",
      "channelID": ""
    },
    {
      "plugin": "DiscordRcon",
      "enabled": false,
      "discordClient": "discord",
      "channelID": "",
      "permissions": {},
      "prependAdminNameInBroadcast": false
    },
    {
      "plugin": "DiscordRoundWinner",
      "enabled": false,
      "discordClient": "discord",
      "channelID": "",
      "color": 16761867
    },
    {
      "plugin": "DiscordRoundEnded",
      "enabled": false,
      "discordClient": "discord",
      "channelID": "",
      "color": 16761867
    },
    {
      "plugin": "DiscordServerStatus",
      "enabled": true,
      "discordClient": "discord",
      "messageStore": "sqlite",
      "command": "!status",
      "disableSubscriptions": true,
      "updateInterval": 10000,
      "setBotStatus": true
    },
    {
      "plugin": "DiscordSquadCreated",
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "color": 16761867,
      "useEmbed": true
    },
    {
      "plugin": "DiscordSubsystemRestarter",
      "enabled": true,
      "discordClient": "discord",
      "role": "****"
    },
    {
      "plugin": "DiscordTeamkill",
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "color": 16761867,
      "disableCBL": false
    },
    {
      "plugin": "FogOfWar",
      "enabled": false,
      "mode": 1,
      "delay": 10000
    },
    {
      "plugin": "IntervalledBroadcasts",
      "enabled": false,
      "broadcasts": ["This server is powered by SquadJS."],
      "interval": 300000
    },
    {
      "plugin": "SeedingMode",
      "enabled": false,
      "interval": 150000,
      "seedingThreshold": 50,
      "seedingMessage": "Seeding Rules Active! Fight only over the middle flags! No FOB Hunting!",
      "liveEnabled": true,
      "liveThreshold": 52,
      "liveMessage": "Live!",
      "waitOnNewGames": true,
      "waitTimeOnNewGame": 30
    },
    {
      "plugin": "SocketIOAPI",
      "enabled": false,
      "websocketPort": "",
      "securityToken": ""
    },
    {
      "plugin": "Switch",
      "commandPrefix": ["!switch", "!change"],
      "enabled": true,
      "discordClient": "discord",
      "channelID": "****",
      "switchCooldownHours": 3,
      "switchEnabledMinutes": 5,
      "doubleSwitchCommands": ["!bug", "!stuck", "!doubleswitch"],
      "doubleSwitchCooldownHours": 0.5,
      "doubleSwitchEnabledMinutes": 5,
      "maxUnbalancedSlots": 5,
      "switchToOldTeamAfterRejoin": false,
      "database": "sqlite"
    },
    {
      "plugin": "TeamRandomizer",
      "enabled": false,
      "command": "randomize"
    }
  ],
  "logger": {
    "verboseness": {
      "SquadServer": 1,
      "LogParser": 1,
      "RCON": 1
    },
    "colors": {
      "SquadServer": "yellowBright",
      "SquadServerFactory": "yellowBright",
      "LogParser": "blueBright",
      "RCON": "redBright"
    }
  }
}

Errors or Screenshots of Issue

image

Squad Information

If potentially relevant, please provide regarding the state of the Squad server at the time of error, e.g. the current layer. Although I don't think it's relevant, here is what ShowServerInfo returned:

{
  "MaxPlayers": 100,
  "GameMode_s": "Training",
  "MapName_s": "JensensRange_USA-RGF",
  "SEARCHKEYWORDS_s": "xxxx,jensensrangeusa-rgf,training",
  "GameVersion_s": "v8.0.2.302549.755",
  "LICENSEDSERVER_b": false,
  "PLAYTIME_I": "1812",
  "Flags_I": "7",
  "MATCHHOPPER_s": "TeamDeathmatch",
  "MatchTimeout_d": 120,
  "SESSIONTEMPLATENAME_s": "GameSession",
  "Password_b": false,
  "PlayerCount_I": "5",
  "ServerName_s": "xxxx",
  "TagLanguage_s": ";1;16;",
  "TagGameMode-0_s": "003;006;009;012;015;018;021;027;030;033;036;039;042;045;051;054;057;060;063;066;069;075;078;081;084;087;090;093;099;102;105;108;111;114;117;123;126;129;132;135;138;141;147;150;153;156;159;162;165;171;174;177;180;183;186;189;195;198;201;204;207;210;213;219;222;225;228;231;234;237;243;246;249;252;255;258;261;267;270;273;276;279;282;285;291;294;297;300;303;306;309;315;318;321;324;327;330;333;339;342;345;348;351;354;357;363;366;369;372;375;378;381;387;390;393;396;399;402;405;411;414;417;420;423;426;429;435;438;441;444;447;450;453;459;462;465;468;471;474;477;483;486;489;492;495;498;501;507;510;",
  "TagGameMode-1_s": "001;004;007;010;013;019;022;025;028;031;034;037;043;046;049;052;055;058;061;067;070;073;076;079;082;085;091;094;097;100;103;106;109;115;118;121;124;127;130;133;139;142;145;148;151;154;157;163;166;169;172;175;178;181;187;190;193;196;199;202;205;211;214;217;220;223;226;229;235;238;241;244;247;250;253;259;262;265;268;271;274;277;283;286;289;292;295;298;301;307;310;313;316;319;322;325;331;334;337;340;343;346;349;355;358;361;364;367;370;373;379;382;385;388;391;394;397;403;406;409;412;415;418;421;427;430;433;436;439;442;445;451;454;457;460;463;466;469;475;478;481;484;487;490;493;499;502;505;508;511;",
  "TagGameMode-2_s": "002;005;011;014;017;020;023;026;029;035;038;041;044;047;050;053;059;062;065;068;071;074;077;083;086;089;092;095;098;101;107;110;113;116;119;122;125;131;134;137;140;143;146;149;155;158;161;164;167;170;173;179;182;185;188;191;194;197;203;206;209;212;215;218;221;227;230;233;236;239;242;245;251;254;257;260;263;266;269;275;278;281;284;287;290;293;299;302;305;308;311;314;317;323;326;329;332;335;338;341;347;350;353;356;359;362;365;371;374;377;380;383;386;389;395;398;401;404;407;410;413;419;422;425;428;431;434;437;443;446;449;452;455;458;461;467;470;473;476;479;482;485;491;494;497;500;503;506;509;",
  "TagGameMode_s": ";1;2;4;",
  "TagPlaystyle_s": ";1;",
  "TagExperience_s": ";1;",
  "TagMapRotation_s": ";2;",
  "TagRules_s": ";1;4;8;16;32;",
  "CurrentModLoadedCount_I": "0",
  "AllModsWhitelisted_b": false,
  "TeamTwo_s": "FSTemplate_RGF",
  "TeamOne_s": "FSTemplate_USA",
  "eu-west-2_I": "26",
  "eu-central-1_I": "25",
  "us-east-1_I": "111",
  "me-central-1_I": "93",
  "us-west-1_I": "157",
  "ap-east-1_I": "274",
  "eu-north-1_I": "53",
  "ap-southeast-2_I": "293",
  "ap-southeast-1_I": "407",
  "Region_s": "eu-central-1",
  "PlayerReserveCount_I": "2",
  "PublicQueueLimit_I": "25",
  "PublicQueue_I": "0",
  "ReservedQueue_I": "0",
  "BeaconPort_I": "15000"
}

System Information

werewolfboy13 commented 3 months ago

We don't provide support for npm. Make a ticket if/when you use yarn.

denizetkar commented 3 months ago

I see. Then, I will test with yarn by removing node_modules and installing the dependencies again.

watchful-eyes commented 3 months ago

I don't think that this is related to yarn or npm. This generally happens when you use an outdated version of DiscordJS, due to the new channel type which is text channel embedded in voice channel or other stuff came with the last big update of Discord. So this will continue to happen unless you update the package itself. Shortcut is putting an if check before the action it tries to execute.

denizetkar commented 3 months ago

Then this means that the discord.js dependency version here needs to be upgraded, right?

That line was last changed 4 years ago.

Also, if so, can someone please contribute a working set of versions please?

werewolfboy13 commented 3 months ago

Will be fixed by #350