Cannot read properties of null (reading 'id')

Hey, so I have a code that worked everytime, but now not longer... Version: 14.11.0
/home/container/src/commands/guesspic.js:42
if (activeRounds[channel.id]) {
^
TypeError: Cannot read properties of null (reading 'id')
at Object.execute (/home/container/src/commands/guesspic.js:42:30)
at module.exports (/home/container/src/events/interactionCreate.js:6:13)
at BoilerplateClient.emit (node:events:512:28)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:238:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.<anonymous> (/home/container/node_modules/@discordjs/ws/dist/index.js:1103:51)
at WebSocketShard.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
/home/container/src/commands/guesspic.js:42
if (activeRounds[channel.id]) {
^
TypeError: Cannot read properties of null (reading 'id')
at Object.execute (/home/container/src/commands/guesspic.js:42:30)
at module.exports (/home/container/src/events/interactionCreate.js:6:13)
at BoilerplateClient.emit (node:events:512:28)
at InteractionCreateAction.handle (/home/container/node_modules/discord.js/src/client/actions/InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (/home/container/node_modules/discord.js/src/client/websocket/handlers/INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:354:31)
at WebSocketManager.<anonymous> (/home/container/node_modules/discord.js/src/client/websocket/WebSocketManager.js:238:12)
at WebSocketManager.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
at WebSocketShard.<anonymous> (/home/container/node_modules/@discordjs/ws/dist/index.js:1103:51)
at WebSocketShard.emit (/home/container/node_modules/@vladfrangu/async_event_emitter/dist/index.js:282:31)
9 Replies
d.js toolkit
d.js toolkit17mo 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. - Issue solved? Press the button!
Cgx
CgxOP17mo ago
Code:
const category = interaction.options.getString('category');
const channel = interaction.channel;

const pro = new EmbedBuilder()
.setColor('#35393e')
.setTitle('<:kenon_time:1112837885696155759> 〢 Slow down!')
.setDescription(`There's still a Round in progress.`);

// Check if a round is already in progress in the channel
if (activeRounds[channel.id]) {
// Send an invisible message to inform that a round is still running
await interaction.reply({ embeds: [pro], ephemeral: true });
return;
}

// Mark the channel as having an active round
activeRounds[channel.id] = true;
const category = interaction.options.getString('category');
const channel = interaction.channel;

const pro = new EmbedBuilder()
.setColor('#35393e')
.setTitle('<:kenon_time:1112837885696155759> 〢 Slow down!')
.setDescription(`There's still a Round in progress.`);

// Check if a round is already in progress in the channel
if (activeRounds[channel.id]) {
// Send an invisible message to inform that a round is still running
await interaction.reply({ embeds: [pro], ephemeral: true });
return;
}

// Mark the channel as having an active round
activeRounds[channel.id] = true;
If more is needed to help, please ping me
Syjalo
Syjalo17mo ago
Could you confirm your version with npm i discord.js?
Cgx
CgxOP17mo ago
yes still the same
duck
duck17mo ago
is the command being executed in a dm?
treble/luna
treble/luna17mo ago
do you have the guilds intent or ^
Cgx
CgxOP17mo ago
Nope, in the server Oh, seems to be this the error... I guess I have to beg discord to give me the guilds intent since I only got the message content intent
treble/luna
treble/luna17mo ago
you just have to enable it in your client? Its not a privileged intent
Cgx
CgxOP17mo ago
Uhm... cgx.exe stopped working Well, that resolved it, thanks
Want results from more Discord servers?
Add your server