Error: ENOENT: no such file or directory, open 'NSFW.txt'
at Object.openSync (node:fs:601:3)
at Object.readFileSync (node:fs:469:35)
at Object.execute (C:\Users\SkyOPG\Desktop\StarBot\interactions\ai\imagine.js:26:26)
at Object.execute (C:\Users\SkyOPG\Desktop\StarBot\events\interactionCreate.js:16:18)
at BotClient.<anonymous> (C:\Users\SkyOPG\Desktop\StarBot\events.js:15:44)
at BotClient.emit (node:events:513:28)
at InteractionCreateAction.handle (C:\Users\SkyOPG\Desktop\StarBot\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\SkyOPG\Desktop\StarBot\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\SkyOPG\Desktop\StarBot\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (C:\Users\SkyOPG\Desktop\StarBot\node_modules\discord.js\src\client\websocket\WebSocketShard.js:494:22) {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: 'NSFW.txt'
}
#somewhy the file is there but itt can't read it?
43 messages · Page 1 of 1 (latest)
NSFW.txt wouldn’t be a path
but that's how it works in this line
const nsfwWords = fs.readFileSync('NSFW.txt', 'utf8').split('\n').map((word) => word.trim().toLowerCase());
ill try though
The first part is a path
It’s from your working directory ig
my working directory, i changed it to ./NSFW.txt and still gives the error
Can you show me your file structure
as a screenshot?
Yes
In vs code
Or so
Try
./interactions/ai/NSFW.txt
okay
tysm it worked!
Iirc your working directory is where you start your bot
I am probably wrong
But that means you start from index.js, so you need to go from there
Hence ./interactions/ai/…
cause everything is getting read from it
Kinda, not too sure
But you’re welcome :)
:)
i said it cause
index.js
interactions.js
interactions.js actually processes the commands
and it is required by the index.js
thanks again for the help
it is though
Is it?
yes
I thought like ./NSFW.txt would be a park
Path *
it just refers to the file relative to the cwd
file.js wouldn't be a valid import via require or import because of node's module resolution but for file access it's perfectly fine
So if it was in the same folder as index.js in this case, that would be completely valid
well, the cwd
but yes
Yh, missed that ig lol