ClientUser banner is undefined when force fetching on ready
I decided to open a post because I asked in d.js help and go no reply and i then bumped the message 2+hrs later and still no reply so i asumed no one active had an idea
When I ran my command the bannerURL is undefined when it should not as I am force fetching and caching the client user once ready
I moved the fetch into my command and it worked however I prefer to keep it in my ready event so I only have to do it one time. I don't understand how the banner could still be undefined
I'm using latest discord.js v14.15.2
19 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!the fact that it successfully fetches when executing as part of a command suggests that the issue has more to do with your
ready
listener or some other logic preventing this from executing properly
client.user.fetch()
and what you have currently should both be fineIm not sure how the ready event could be an issue though as everything else works on it. i also fetch my account on ready so i can display developer info without manual putting it in
well it'll definitely be hard to give you any further information with just the code shown
theres not really much to show
ready.js
command:
i have collapsed all of the private methods
originally i loaded commands in
start
method however when i parse refresh: false
, it fetches the commands and client.application
is undefined or null i cant remember which one
i will try only load the test command
Console:
ran /test
and banner: null
i fetch commands in loadCommands so then if refresh is false it fetches otherwise if its true it gets the id's from the result of rest.put so i might just use rest to fetch the commands
but then it would fetch everytime, i only need to fetch if i dont register (ik i can just comment the line out but thats just inconvenient imo)
ill try logging banner with loading commands in start anyways to see if it makes a difference as this test command doesnt use the ids
in test command:
whilst only loading test.js too
i will try console.log client user in ready
it returns the banner, just command
i will try logging it throughout interaction
yes, i change to true when i register my commands on startup or use /register however its 1 extra thing, possible but inconvenient however it didnt work when i tried moving registering to start
i also tried seeing if i can forcefully overwrite it using object define property but banner is still null in the command
was only testing purposes
maybe when i run the command the cache gets updated internally and as it doesn't have the banner from the discord api it updates banner to null?
idk when djs internally updates clientuser cache
right now it only logs banner, but it will be to get the bots info
would djs receive data for the client user on the interaction cmd?
i dont do anything to the client in interaction create but i have the console log at the very top anyways so wouldnt matter what happens in it
i only listen to it once too
yes i will do that now, however i did try to fetch the client after i ran the ready functio
is it a discord api bug that banner isn't sent initially or is it intended
i will try disable guild presences, i think i deleted the feature which used it
banner is still null without guild presences
i will try that however something i just noticed something strange
the second i saw "✅ test" i ran the command, banner wasnt null. waited a few seconds, ran the command again and banner was null
above message delete
19:09:12
out of those events, i only listen to ready, message delete, message create and interaction create
yes
i can add them back
ill add the log to start and end of message delete and create
im not sure, only thing which bulk deletes messages are my leaderboards but i removed the code
and my message delete event returns if the channel name doesnt start with a specific word
the message events took a while to come through this time
"a while", few seconds longer than before
i commented out my entire message delete and create events and banner is still null so must be internally
i will try now
still null
@Qjuh
im not sure why message create and delete are even emitting
seems to be once message delete is emitted
@Qjuh this is my leaderboard code which i run on a timeout in my main file
correct
i originally had this timeout in my ready event but i removed it and dumped it in my client so i didnt forget it (i could've just commented in my ready but it was 'clogging' it up when looking at it and i forgot to comment it in my main file)
when i comment it out, banner remains as it should be however i look to reimplement this feature as i was only temporarily removing it
none
i tried bulk deleting in ready and using eval to bulk delete whilst keeping the leaderboard commented out and i cant seem to replicate this... im not sure whats happening but its to do with my leaderboard class i think
but if i dont fetch a message?
it only goes null when i bulkDelete in my leaderboard class
i tried bulk deleting with eval and in my ready function
but didnt go null
however, when i comment out the bulkDelete method in the leaderboard class, it doesn't go null :Thonk:
changing to
channel.lastMessage?.delete()
works, however in some cases, there might
- A. not be a last message at all
- B. there may be more than just the last message (i want to clear the entire channel)
update.. it isn't a solution because lastMessage is null (not cached) and i can not fetch it because of this issue 🤦♂️
ah, i thought it would fetch them but i wasn't sure
would this be considered a 'bug'?
sounds good, atleast we (you) have been able to find the issue because this has been driving me crazy all day
for now, i think i should fetch the client after initially purging the leaderboard channels, then using lastMessage to delete the posts
btw, is there anyway i can keep updated or is it a case of keeping my eye out in #discord.js (discord.js)?