null value from slash command option

index.js
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'embed') {
const embed = new EmbedBuilder().setTitle("This is title").setDescription("This is description");

interaction.reply({ embeds: [embed] });
}
})
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'embed') {
const embed = new EmbedBuilder().setTitle("This is title").setDescription("This is description");

interaction.reply({ embeds: [embed] });
}
})
resgister-commands.js
{
name: 'embed',
description: 'sends an embed',
},
{
name: 'embed',
description: 'sends an embed',
},
error
node:events:496
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of null (reading 'value')
at Client.<anonymous> (C:\Users\SWEET HOME\Desktop\BTEP\src\index.js:91:57)
at Client.emit (node:events:530:35)
at InteractionCreateAction.handle (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\@discordjs\ws\dist\index.js:1173:51)
at WebSocketShard.emit (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.onMessage (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\@discordjs\ws\dist\index.js:988:14)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:401:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v20.11.1
node:events:496
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of null (reading 'value')
at Client.<anonymous> (C:\Users\SWEET HOME\Desktop\BTEP\src\index.js:91:57)
at Client.emit (node:events:530:35)
at InteractionCreateAction.handle (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\client\websocket\WebSocketManager.js:355:31)
at WebSocketManager.<anonymous> (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\client\websocket\WebSocketManager.js:239:12)
at WebSocketManager.emit (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.<anonymous> (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\@discordjs\ws\dist\index.js:1173:51)
at WebSocketShard.emit (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\@vladfrangu\async_event_emitter\dist\index.cjs:282:31)
at WebSocketShard.onMessage (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\@discordjs\ws\dist\index.js:988:14)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:401:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v20.11.1
32 Replies
d.js toolkit
d.js toolkit3mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
f(x) = 1/x
f(x) = 1/x3mo ago
[nodemon] app crashed - waiting for file changes before starting...
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
a { no
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
that was reg commands const num1 = interaction.options.get('first-number').value; i should change .value
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
but i ran a entirelly different command tho no
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
wait
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
require('dotenv').config(); const { Client, IntentsBitField } = require ('discord.js'); const client = new Client({ intents: [ IntentsBitField.Flags.Guilds, IntentsBitField.Flags.GuildMembers, IntentsBitField.Flags.GuildMessages, IntentsBitField.Flags.MessageContent, ], }); client.on('ready', (c) => { console.log('scrodringer is expeimenting.'); //you can use ${user.tag.id(or .tag or smth)} to mention the bot like console.log(${user.tag.id} is expeimenting.); }); client.on('messageCreate', (message) => { if (message.author.bot) { // ignores bots message return; } if (message.content === 'hello') { message.reply('hi') } })
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
the code is too big lemme do pastebin
d.js docs
d.js docs3mo ago
To share long code snippets, use a service like gist, sourcebin, starbin, or similar instead of posting them as large code blocks or files.
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
Pastebin
require('dotenv').config();const { Client, IntentsBitField } = requ...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
f(x) = 1/x
f(x) = 1/x3mo ago
lemme see but
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
the command is about embed
Unknown User
Unknown User3mo ago
Message Not Public
Sign In & Join Server To View
f(x) = 1/x
f(x) = 1/x3mo ago
i think i got a diff error after changing .values to .getNumber [nodemon] 3.1.0 [nodemon] to restart at any time, enter rs [nodemon] watching path(s): . [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting node src/index.js scrodringer is expeimenting. C:\Users\SWEET HOME\Desktop\BTEP\node_modules@discordjs\rest\dist\index.js:722 throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData); ^ DiscordAPIError[10062]: Unknown interaction at handleErrors (C:\Users\SWEET HOME\Desktop\BTEP\node_modules@discordjs\rest\dist\index.js:722:13) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async BurstHandler.runRequest (C:\Users\SWEET HOME\Desktop\BTEP\node_modules@discordjs\rest\dist\index.js:826:23) at async _REST.request (C:\Users\SWEET HOME\Desktop\BTEP\node_modules@discordjs\rest\dist\index.js:1266:22) at async ChatInputCommandInteraction.reply (C:\Users\SWEET HOME\Desktop\BTEP\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:111:5) { requestBody: { files: [], json: { type: 4, data: { content: 'The sum is 3', tts: false, nonce: undefined, embeds: undefined, components: undefined, username: undefined, avatar_url: undefined, allowed_mentions: undefined, flags: undefined, message_reference: undefined, attachments: undefined, sticker_ids: undefined, thread_name: undefined } } }, rawError: { message: 'Unknown interaction', code: 10062 }, code: 10062, status: 404, method: 'POST', url: 'liiink' } Node.js v20.11.1 [nodemon] app crashed - waiting for file changes before starting...
duck
duck3mo ago
just to elaborate, every interactionCreate listener will execute for every interaction emitted you may continue to encounter further errors without fully understanding how each of your event listeners affect each other it's recommended to only have 1 event listener per event
f(x) = 1/x
f(x) = 1/x3mo ago
wait, gimme a minute i see a problem so basically i didnt close the previous event listener which was of a mathematical operation
duck
duck3mo ago
well the more problematic listener is probably the one on line 88 of your pastebin that responds indiscriminately to every slash command interaction
f(x) = 1/x
f(x) = 1/x3mo ago
by event listener you meant
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;
.
.
.
client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;
.
.
.
right?
duck
duck3mo ago
yes
f(x) = 1/x
f(x) = 1/x3mo ago
i havent faced any prob running 5 yet? what could be possible problems
duck
duck3mo ago
except you have? the errors you've posted so far are caused by this both of them
f(x) = 1/x
f(x) = 1/x3mo ago
human error right? Human error is due to carelessness or to the limitations of human ability. a physics term ig
duck
duck3mo ago
I mean depending on how you interpret it, I suppose so
f(x) = 1/x
f(x) = 1/x3mo ago
got it thanks btw