I cant use my anycommand
Even if I fix my internet connection problem I got this error
103 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.then you either did not fix it or your code takes too long to execute
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Ill try now
No it didnt fix
then i dont know, might be your home network, might be your server network, but its not djs related it looks like
First of all, messy code. Second, is the bot even registering the ping command? Log it when you run the command and check
it is being ran, can be seen in the stacktrace
I started coding again all project
I try change my interaction create part
lines 15
do it like this !(code)
not like this !interaction.type ==
Or just !== ?
yeah
Is it ok?
no?
or yes
try it and see if the results satisfy u
Can I use editReply() after reply()
?
Yes
thats my interactionCreate event
But still I got this error
can you try loggin client.ws.ping? Might maybe give you some clue
Ok I will try
1219 ms WTF?
and there is your issue
are u using windows 7?
Thats Virtual Device
What is this btw?
Client.ws.ping?
your websocket latency
What could be causing the problem?
and how can I fix it
Switching hosts looks to be the only way
Or do you happen to use a vpn or proxy
No I dont use
Switch to a better host would be your best guess
Must be another way
do you use anything else that's network intensive?
No I just use Visual Studio
Welp, time to get a better host probably
Just for further understanding. Websocket Latency is determined by the trip it takes for your bot to communicate with the discord gateway.
Bad network = more trip time = more latency
If the host is giving costant high latency performance... I don't see the reason to stick with it tbh
and the distance between the host and the discord servers
And that yeah. But even if the host is pretty far away, If the netwrork route is good. You can work with the ping.
300ms to SG is not bad. With some proper coding and handling it's barely noticeable.
I sometimes get 144ms but sometimes 1000+ ms
Why ping is change...
do you use a shared host
Probably yes
There is your answer
I use host only
Yeah... if shared, when the surrounding gets heated up with traffic, your area suffers
To put it simply
Anyhow, whether its shared or not, get a better host
Or a host that has reasonable performance even when shared.
It's the root cause that's why we're consistent about it
aahh I live in Turkey and we got a little economic problem and soo this host problem is very expensive is another country
And I cant get a risk
If after I get a host from USA and then if still I get this error
Thats can be so bad
for me
i pay like 5€ a month for my hetzner server
Probably I paid same cost
I pay nothing for my VPS, but with a risk I'm taking to use what I get to it's full potential
OK so you changed the hosting service ?
And the network is good without any latencies ?
But the problem still persists ?
Then the problem is your code mate.
- yes
- yes
- yes
-
That last line is wrong.
You can only use
editReply
after an interaction is deferred.
Use followUp
instead.
Or use the variable and do sent.edit()
Okey I will did it
Luna said yes
i guess something is increbily wrong in how you're handling the interactions.
If the command is right then the next place is where you handle the
interactionCreate
event.
If that's also correct then your event handler is the culpritif you switched to a different host, try logging the ping again and see
Websocket hb is now 144 and 150 it doesnt have Problem now
Here is my interactionCreate event
And my event-handler
Bro can u look?
The handler is fine I guess.
As for the interaction handler.
I'm curious as to why you're checking the interaction type
When type guards exist
And also curious why you're using a process error handler inside the interaction handler
While you can handle that in the main index file for global code coverage
Before I use inside of index.js
Oh ok I will change it again
Also uncaughtException doesn't catch unhandledRejection
The latter mostly happens when discord API errors happen
Oh wait I add also
Yeah please remove that if statement and use normal type guards.
For example
interaction.isButton()
exists to handle button interactionsOkeyy
This is fine.
Is it ok for get error?
Oh oke
Yep that's enough to cover most of the errors.
But sometimes you still need a try catch block /
.catch()
to catch some errors that escape
https://old.discordjs.dev/#/docs/discord.js/main/class/BaseInteraction if you're lost
Slash commands are isChatInputCommand()
I try but I got same error
My ping command
The interactionCreate code I mean
Did you update it
I did it that
I said to remove the previous if statement and wrap it inside a new if statement that looks something like
if (interaction.isChatInputCommand()) {...}
So your code will ignore other interactions
And only execute your slash commands when a slash command is used
<:teri_point2:947453665164283935>I removed?
Where is it?
Sorry I dont see
@devkavi Bro sorry for tag but I need help
try using console.time to see what part of your code takes so long to execute
Okey
Is it true
Also my bot dead now
He dont get any command and dont send any error
no need to time between console;logs, time betweeon your db calls
also idk how thats formatted but if that is a . and not a , then you have your answer
Currently, no commands are working, including the ping command. Isn't that the main problem?
also show your event handler
isnt require synchrounous
So is it ok?
??
why did you do that
U said that
no? like? I didnt even say something close to that
i said that require() might not be async
Sorry ur right mb
Im understand now
She's right.
Require is not an async operation.
Sorry but I was asleep while you tagged me. And wow I forgot console.time exists.
That can also help you to figure out what's taking long to execute that takes more than 3 seconds.
I try it
.
Probably sending Part is takes more time
Then time it
Something happened like that
line 13.7 is await
If I remove await?
Its work?
Please dont tell me those wait functions were there the whole time
No
I just add
I try something
that isnt gonna help at all
Just place console.time before and after each operation to see what's taking so long
I write part3 two times but
Its taking 800ms to reply, so something is wrong with your network or machine
Ahh.. I got ws error before time
Thats can be about websocket connection?
I was use .destroy before
Can be thats about
I dont use now