Discord.js Error

I get this error randomly and the bot crashes
Error [TypeError]: Cannot read properties of null (reading 'id')
at ShardClientUtil._handleMessage (C:\Users\e\Desktop\bot\node_modules\discord.js\src\sharding\ShardClientUtil.js:193:48)
at process.emit (node:events:513:28)
at emit (node:internal/child_process:937:14)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
Error [TypeError]: Cannot read properties of null (reading 'id')
at ShardClientUtil._handleMessage (C:\Users\e\Desktop\bot\node_modules\discord.js\src\sharding\ShardClientUtil.js:193:48)
at process.emit (node:events:513:28)
at emit (node:internal/child_process:937:14)
at process.processTicksAndRejections (node:internal/process/task_queues:83:21)
4 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Polar
PolarOP2y ago
Node version: v18.14.2
monbrey
monbrey2y ago
discord.js version?
Polar
PolarOP2y ago
14.8.0 I don't use fetchClientValues anywhere I don't think I use any third party packs nope, none of them outside of d.js files shard manager
try {
const { ShardingManager } = require("discord.js");
const manager = new ShardingManager("./bot.js", {
token: process.env.TOKEN,
totalShards: "auto",
});

manager.on("shardCreate", shard =>
console.log(`Launching shard ${shard.id}...`),
);

const statcord = new Statcord.ShardingClient({
key: process.env.STATCORD_KEY,
manager,
postCpuStatistics: true,
postMemStatistics: true,
postNetworkStatistics: true,
autopost: true,
});

manager.spawn({
amount: 1,
delay: 20000,
timeout: -1,
});

statcord.on("autopost-start", () => {
console.log("Started autopost");
});

statcord.on("post", status => {
if (status) console.error(status);
});
} catch (err) {
console.log(err);
}
try {
const { ShardingManager } = require("discord.js");
const manager = new ShardingManager("./bot.js", {
token: process.env.TOKEN,
totalShards: "auto",
});

manager.on("shardCreate", shard =>
console.log(`Launching shard ${shard.id}...`),
);

const statcord = new Statcord.ShardingClient({
key: process.env.STATCORD_KEY,
manager,
postCpuStatistics: true,
postMemStatistics: true,
postNetworkStatistics: true,
autopost: true,
});

manager.spawn({
amount: 1,
delay: 20000,
timeout: -1,
});

statcord.on("autopost-start", () => {
console.log("Started autopost");
});

statcord.on("post", status => {
if (status) console.error(status);
});
} catch (err) {
console.log(err);
}
keeps track of server counts, and stuff usage ah yea could be
└── discord.js@14.8.0
└── discord.js@14.8.0
├── @napi-rs/canvas@0.1.30
├── @prisma/client@4.12.0
├── agile@0.0.2
├── amaribot.js@1.6.1
├── axios@0.27.2
├── body-parser@1.20.1
├── bullmq@1.91.1
├── chalk@4.1.2
├── chartjs-plugin-colorschemes@0.4.0
├── child_process@1.0.2
├── cli-box@6.0.10
├── clinic@12.1.0
├── dateformat@5.0.3
├── discord.js@14.8.0
├── dotenv@16.0.1
├── eslint-config-google@0.14.0
├── eslint-config-prettier@8.8.0
├── eslint-plugin-prettier@4.2.1
├── eslint@8.37.0
├── express@4.18.2
├── fs@0.0.1-security
├── fuzzy-search@3.2.1
├── glob@7.2.3
├── mathjs@10.6.4
├── moment@2.29.4
├── mongoose@6.8.1
├── ms@2.1.3
├── node-fetch@2.6.7
├── pluralize@8.0.0
├── prettier-eslint@15.0.1
├── prisma@4.12.
├── quickchart-js@3.1.0
├── redis@4.5.1
├── simple-statistics@7.8.0
├── sourcebin@4.3.5
├── statcord.js@3.4.3
├── string-to-ms@1.1.2
├── tagscript@1.2.13
├── time-convert@0.0.2
├── url-clean@1.0.2
└── winston@3.8.2
├── @napi-rs/canvas@0.1.30
├── @prisma/client@4.12.0
├── agile@0.0.2
├── amaribot.js@1.6.1
├── axios@0.27.2
├── body-parser@1.20.1
├── bullmq@1.91.1
├── chalk@4.1.2
├── chartjs-plugin-colorschemes@0.4.0
├── child_process@1.0.2
├── cli-box@6.0.10
├── clinic@12.1.0
├── dateformat@5.0.3
├── discord.js@14.8.0
├── dotenv@16.0.1
├── eslint-config-google@0.14.0
├── eslint-config-prettier@8.8.0
├── eslint-plugin-prettier@4.2.1
├── eslint@8.37.0
├── express@4.18.2
├── fs@0.0.1-security
├── fuzzy-search@3.2.1
├── glob@7.2.3
├── mathjs@10.6.4
├── moment@2.29.4
├── mongoose@6.8.1
├── ms@2.1.3
├── node-fetch@2.6.7
├── pluralize@8.0.0
├── prettier-eslint@15.0.1
├── prisma@4.12.
├── quickchart-js@3.1.0
├── redis@4.5.1
├── simple-statistics@7.8.0
├── sourcebin@4.3.5
├── statcord.js@3.4.3
├── string-to-ms@1.1.2
├── tagscript@1.2.13
├── time-convert@0.0.2
├── url-clean@1.0.2
└── winston@3.8.2
none ah, alright. Thank you
Want results from more Discord servers?
Add your server