Search
Get Started
d-I❄
discord.js - Imagine ❄
•
2y ago
electric
Bot will crash after first successful run of command (will auto be fine after like 2 mins)
Kinda confused what to fix or how to fix the problem
, pleas help
discord.js - Imagine ❄
Join
Support server for discord.js, a Node.js module to interact with Discord's apps API.
58,353
Members
View on Discord
Was this page helpful?
Yes
No
D
d.js toolkit
•
6/28/24, 9:37 AM
What
's your exact discord
.js
npm list discord.js
npm list discord.js
and node
node -v
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
!
E
electric
Kinda confused what to fix or how to fix the problem, pleas help
I
Inky
•
6/28/24, 9:39 AM
You can
’t delete a message that has already been deleted
I
Inky
You can’t delete a message that has already been deleted
E
electric
OP
•
6/28/24, 9:39 AM
so the message
.delete is extra
?
I
Inky
•
6/28/24, 9:39 AM
This likely happens due to race conditions
I
Inky
•
6/28/24, 9:39 AM
Could be someone that deletes their message quicker than you can receive it
E
electric
OP
•
6/28/24, 9:39 AM
no but like
E
electric
OP
•
6/28/24, 9:39 AM
id like the bot to delete the initiative command
E
electric
OP
•
6/28/24, 9:40 AM
how can I manage to do that
?
I
Inky
•
6/28/24, 9:40 AM
Ur not checking if it
’s a command tho
I
Inky
•
6/28/24, 9:40 AM
Ur just deleting all messages sent by users who have that role
E
electric
OP
•
6/28/24, 9:40 AM
Fr
? I thought Im deleting the initiative message
?
?
E
electric
OP
•
6/28/24, 9:40 AM
Ex
.
-
(prefix
)app in this case
I
Inky
•
6/28/24, 9:41 AM
It
’s outside of the if statements of the commands
E
electric
OP
•
6/28/24, 9:41 AM
so I should place it within the if statement
?
I
Inky
•
6/28/24, 9:41 AM
That
’s one way
E
electric
OP
•
6/28/24, 9:41 AM
like somewhere between ln 182 and 183
I
Inky
•
6/28/24, 9:41 AM
You could also put the else clause in to return
I
Inky
•
6/28/24, 9:41 AM
I
Inky
•
6/28/24, 9:42 AM
That
’ll stop the code from continuing if no command matched
I
Inky
•
6/28/24, 9:42 AM
To be safe
, you can just attach a catch handler to the delete and silently ignore it
I
Inky
•
6/28/24, 9:43 AM
Well
, to be really safe would be to ensure that the error message is Unknown Message
, rethrow if it
’s not
I
Inky
•
6/28/24, 9:43 AM
Up to you if you want to go that far
.
.catch
(
…
) handler is bare minimum
I
Inky
Up to you if you want to go that far. .catch(…) handler is bare minimum
E
electric
OP
•
6/28/24, 9:46 AM
here
's the issue even if I deleted the delete statement it will still delete the initiative command
E
electric
OP
•
6/28/24, 9:46 AM
why
's that
?
I
Inky
•
6/28/24, 9:46 AM
Error occurred elsewhere
E
electric
OP
•
6/28/24, 9:46 AM
im pretty sure it
's here tho since if i deleted this
, my bot will work perfectly fine
I
Inky
•
6/28/24, 9:47 AM
I thought you said it still errors after removing it
?
I
Inky
•
6/28/24, 9:47 AM
Oh
, I misread
I
Inky
•
6/28/24, 9:48 AM
Delete is happening elsewhere
E
electric
OP
•
6/28/24, 9:48 AM
see if i do this my bot will not crash
I
Inky
•
6/28/24, 9:48 AM
Can you stop
/kill the bot and see if it still deletes the message
?
I
Inky
•
6/28/24, 9:48 AM
Could be running another instance of the bot
E
electric
OP
•
6/28/24, 9:49 AM
nope it won
't delete
E
electric
OP
•
6/28/24, 9:49 AM
it
's the bot
E
electric
OP
•
6/28/24, 9:49 AM
if I send the full file will that help
?
I
Inky
•
6/28/24, 9:50 AM
Just look for another message
.delete in ur code
E
electric
OP
•
6/28/24, 9:50 AM
therre is another one but
E
electric
OP
•
6/28/24, 9:50 AM
it
's in another
E
electric
OP
•
6/28/24, 9:50 AM
section
E
electric
OP
•
6/28/24, 9:50 AM
will that affect this section
>
>
?
E
electric
OP
•
6/28/24, 9:51 AM
like it
's not in the same if nested statement
I
Inky
•
6/28/24, 9:51 AM
It could have the same issue as the code you originally showed has
E
electric
OP
•
6/28/24, 9:51 AM
it doesn
't tho
E
electric
OP
•
6/28/24, 9:51 AM
it works perfectly fine for that section
E
electric
OP
•
6/28/24, 9:51 AM
that
's when the confusion hits
I
Inky
•
6/28/24, 9:51 AM
Try commenting out the message
.delete
E
electric
OP
•
6/28/24, 9:52 AM
for the section I ssed or the another one
E
electric
OP
•
6/28/24, 9:53 AM
hm
E
electric
OP
•
6/28/24, 9:53 AM
It still crashed if I commented out both message delete
@New Year
's Predicate
E
electric
OP
•
6/28/24, 9:53 AM
can I conclude that isn
't about deleting
?
Next page
else { return }
else { return }