Cannot read properties of undefined error when modularizing commands - discord.js

There is a problem that commands such as "await client.channels.cache.get('1020656369021489182').send('dd')" cannot be used when used in a command modular manner. It works well when it is not modular, but it enters the module and does not operate commands in individual files. I ask for your help on how to solve this problem!
The following error occurs when you execute the command
TypeError: Cannot read properties of undefined (reading 'send')
at Object.execute (C:\discordbot\music\commands\ping.js:10:57)
at Client.<anonymous> (C:\discordbot\music\reindex.js:32:17)
at Client.emit (node:events:527:28)
at InteractionCreateAction.handle (C:\discordbot\music\node_modules\discord.js\src\client\actions\InteractionCreate.js:81:12)
at Object.module.exports [as INTERACTION_CREATE] (C:\discordbot\music\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\discordbot\music\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (C:\discordbot\music\node_modules\discord.js\src\client\websocket\WebSocketShard.js:481:22)
at WebSocketShard.onMessage (C:\discordbot\music\node_modules\discord.js\src\client\websocket\WebSocketShard.js:321:10)
at WebSocket.onMessage (C:\discordbot\music\node_modules\ws\lib\event-target.js:199:18)
at WebSocket.emit (node:events:527:28)

Seems like 1020656369021489182 is not a valid channel id or that channel doesn't exist.

Related

How do I solve this reference error when opening a file?

I'm trying to make a discord bot that can read dates from a txt file on my device.
I've read the documentation and looked over similar posts, but I keep running into the same error. Just starting to learn python so please excuse any obvious mistakes/ strange formatting.
list = open("dates.txt","r")
list.seek(0)
var firstLine = file1.readline()
file1.close()
bot.sendMessage({
to: channelID,
message: firstLine
})
The error:
C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\bot.js:241
list = open("dates.txt","r")
^
ReferenceError: open is not defined
at DiscordClient.<anonymous> (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\bot.js:241:13)
at DiscordClient.emit (node:events:527:28)
at DiscordClient.handleWSMessage (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\discord.io\lib\index.js:1854:11)
at WebSocket.emit (node:events:527:28)
at Receiver.ontext (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\WebSocket.js:841:10)
at C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:536:18
at Receiver.applyExtensions (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:371:5)
at C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:508:14
at Receiver.flush (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:347:3)
at Receiver.finish (C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp\node_modules\ws\lib\Receiver.js:541:12)
PS C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp>
Might be useful to know
This bot is able to do other things like respond to commands
dates.txt exists in the same folder at C:\Users\My Laptop\Desktop\Discord Bots\HeadzUp
So it seems like I completely mashed up python and nodejs on accident.
Not quite sure what I was thinking but that was the issue.
Simple answer — don't mix nodejs and Python.
First of all you should avoid to redefine "list" as this is python keyword.
Second, the command is correct and the "open" keyword is built in in native python. So it should work.
This exact line works in my python environment (even when overwriting "list").
When you look at the end of the lines of the error message you can see the ".js" endings. This is hinting, that you somehow try to interpret python code with a javascript interpreter.
Maybe you should post some more information about your system and setup.
If you use a proper python3 interpreter your code should work.

Failing to open audio device (/dev/dsp)

I am using pocketsphinx to adapt my acoustic model which i have trained.
So to use the model in pocketsphinx, i ran the following command:
pocketsphinx_continuous -inmic yes -lm "/home/ridwan/sphinx/other/output/other.lm.DMP" -dict "/home/ridwan/sphinx/other/output/other.dic" -hmm "/home/ridwan/sphinx/other/output/other.ci_cont"
But however, I am getting this error:
ad_oss.c(115): Failed to open audio device(/dev/dsp): Input/output error
FATAL: "continuous.c", line 245: Failed to open audio device
I tried this solution. (installing pulseaudio, libpulse-dev, osspd)
I also tried export LD_PRELOAD=libpulsedsp.so
But I keep getting the same error message.

Tutorial nextjs multiple apps

I tried :
https://github.com/zeit/next.js/tree/canary/examples/with-zones
I follow the instructions and I got this :
#MacBook-Pro  ~/Documents/nextjs  cd with-zones
#MacBook-Pro  ~/Documents/nextjs/with-zones  now dev
> Now CLI 16.7.3 dev (beta) — https://zeit.co/feedback
┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ WARN! You defined 1 build that did not match any source files (please ensure they are NOT defined in .nowignore): │
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
- {"src":"home/next.config.js","use":"#now/next"}
> Creating initial build
Exiting builder due to build error:
Error: Cannot find module 'next'
Require stack:
- /Users/d_/Documents/nextjs/with-zones/blog/noop.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at resolveFileName (/Users/d_/Library/Caches/co.zeit.now/dev/builders/node_modules/#now/next/dist/dev-server.js:142:39)
at resolveFrom (/Users/d_/Library/Caches/co.zeit.now/dev/builders/node_modules/#now/next/dist/dev-server.js:156:9)
at Object.module.exports.101.module.exports [as default] (/Users/d_/Library/Caches/co.zeit.now/dev/builders/node_modules/#now/next/dist/dev-server.js:159:47)
at process.<anonymous> (/Users/d_/Library/Caches/co.zeit.now/dev/builders/node_modules/#now/next/dist/dev-server.js:4472:48)
at Object.onceWrapper (events.js:313:26)
at process.emit (events.js:223:5)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/d_/Documents/nextjs/with-zones/blog/noop.js' ]
What is the problem ? I don't understand... thanks

Cant start react-native at android via react-native run-android

BUILD FAILED in 3s
Cant run react-native run-android
i connect fierbase in this project
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* Where:
Script 'E:\react\fb (2)\fb\node_modules\#react-native-community\cli-platform-android\native_modules.gradle' line: 191
* What went wrong:
A problem occurred evaluating settings 'fb'.
> Unable to determine the current character, it is not a string, number, array, or object
The current character read is 'E' with an int value of 69
Unable to determine the current character, it is not a string, number, array, or object
line number 1
index number 0
Error: Unexpected close tagLine: 31Column: 11Char: > at error (E:\react\fb (2)\fb\node_modules\sax\lib\sax.js:651:10) at strictFail (E:\react\fb (2)\fb\node_modules\sax\lib\sax.js:677:7) at closeTag (E:\react\fb (2)\fb\node_modules\sax\lib\sax.js:871:9) at SAXParser.write (E:\react\fb (2)\fb\node_modules\sax\lib\sax.js:1436:13) at new XmlDocument (E:\react\fb (2)\fb\node_modules\xmldoc\lib\xmldoc.js:261:15) at readManifest (E:\react\fb (2)\fb\node_modules\#react-native-community\cli-platform-android\build\config\readManifest.js:38:10) at Object.projectConfig (E:\react\fb (2)\fb\node_modules\#react-native-community\cli-platform-android\build\config\index.js:59:46) at Object.get project [as project] (E:\react\fb (2)\fb\node_modules\react-native\node_modules\#react-native-community\cli\build\tools\config\index.js:134:65) at E:\react\fb (2)\fb\node_modules\react-native\node_modules\#react-native-community\cli\build\commands\config\config.js:8:452 at Array.forEach (<anonymous>)
^
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

Babel/browserify throws "Error while parsing JSON - Unexpected token o"

Weird error when attempting to use browserify and babel:
./node_modules/.bin/browserify app/index.js -o bundle.js -t [ babelify --presets [ es2015 react ] ]
gives:
SyntaxError: /.../package.json: Error while parsing JSON - Unexpected token o in JSON at position 1 while parsing file: /.../index.js
at Object.parse (native)
at ConfigChainBuilder.addConfig (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:155:65)
at ConfigChainBuilder.findConfigs (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:107:30)
at buildConfigChain (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/options/build-config-chain.js:66:13)
at OptionManager.init (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/options/option-manager.js:369:58)
at File.initOptions (/.../dash/node_modules/babelify/node_modules/babel-core/lib/transformation/file/index.js:223:65)
at new File
I have the proper presets installed for es2015 and react, but I have no idea why it's throwing up this error. The weird thing is, this command is working on my production server...
Any ideas?
This is the package.json parsing error, Check whether there is an package.json file at my user directory, if exist, delete it.

Resources