API not returning data
https://gist.github.com/KiraKenjiro/de1460359c1b33dc5f2d55763eae95a2
Inside the Gist, there's a bot that retrieves user information based on their ID. The bot command is functional, so if you use "!info {userid}" in a chat, it will provide you with all the relevant information. However, when I attempt to request the API, it doesn't return any data.
Data returned by command:
Data returned by API:
Can anyone help or run your eyes over this to see if i'm doing anything wrong, I can't unpick it xD
Gist
This is a Discord bot designed to easily retrieve your account deta...
This is a Discord bot designed to easily retrieve your account details using your ID. - index.js
8 Replies
- 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 OPwhere do you define guildId in your app.get(…)?
line 182
another probability is that the member isn’t cached in said guild
the member is cached in the messagecreate event because discord sends it, but on line 182 theres a probability the member isn’t cached
actually, there’d still be some info
i’ll look a bit more
Turns out it wasnt even entering the try part.
But it brings us on to the part that now you get this error
Error fetching user: TypeError: Cannot read properties of undefined (reading 'members')
at getUserInfo (/Users/kirakenjiro/Desktop/Coding/Plaque/index.js:26:4)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /Users/kirakenjiro/Desktop/Coding/Plaque/index.js:180:22
Userinfo:null
xD
So something can't respond correctly
Thats responding to this line here
either the client isn’t ready or isn’t in that guild
make sure you’re passing a string as the id
Current i think its being passed as an int
then it’s getting truncated
Got it, I'll give that a change
yep, that was it, Its returning an object now so we're good <3
Thanks so much for the help pistol :D
no problem