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
140 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!You can’t delete a message that has already been deleted
so the message.delete is extra?
This likely happens due to race conditions
Could be someone that deletes their message quicker than you can receive it
no but like
id like the bot to delete the initiative command
how can I manage to do that?
Ur not checking if it’s a command tho
Ur just deleting all messages sent by users who have that role
Fr? I thought Im deleting the initiative message??
Ex. -(prefix)app in this case
It’s outside of the if statements of the commands
so I should place it within the if statement?
That’s one way
like somewhere between ln 182 and 183
You could also put the else clause in to return
else { return }
That’ll stop the code from continuing if no command matched
To be safe, you can just attach a catch handler to the delete and silently ignore it
Well, to be really safe would be to ensure that the error message is Unknown Message, rethrow if it’s not
Up to you if you want to go that far. .catch(…) handler is bare minimumhere's the issue even if I deleted the delete statement it will still delete the initiative command
why's that?
Error occurred elsewhere
im pretty sure it's here tho since if i deleted this, my bot will work perfectly fine
I thought you said it still errors after removing it?
Oh, I misread
Delete is happening elsewhere
see if i do this my bot will not crash
Can you stop/kill the bot and see if it still deletes the message?
Could be running another instance of the bot
nope it won't delete
it's the bot
if I send the full file will that help?
Just look for another message.delete in ur code
therre is another one but
it's in another
section
will that affect this section>>?
like it's not in the same if nested statement
It could have the same issue as the code you originally showed has
it doesn't tho
it works perfectly fine for that section
that's when the confusion hits
Try commenting out the message.delete
for the section I ssed or the another one
hm
It still crashed if I commented out both message delete @New Year's Predicate
can I conclude that isn't about deleting?
Show the error
That’s a different error
so both error at the same time
i have to fix 2 errors
so it's gonna crash if i don't fix both either way
You got Unknown Message too?
yes
Right above or below that one?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
hm
what should I replace with
It wouldn’t work if none of the if statements executed
well it didn't come at the same time
but
i believe it exists together
What?
both problem exists
the error panel just show the higher priority ones
No
Ur bot’s not crashing
Surprisingly considering unhandled rejections are deprecated
hope this can spot the issue
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
You can’t send an empty message
i didn't
embed is not considered an empty message i think
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Ur code always sends the "message", regardless of whether any of the if statement executed or not
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
but if i place it above it's still error somehow
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
It seems to be general problem in ur code
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
hm
how should I replace
I would just send in the commands
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
There’s no interaction here
yea
it's an initiative command
like if I send a message like
-app
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
the embed will be sent
and the initiative message will be deleted
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
i dislike the slashcommand feature
and i don't want the
memberrs to know who ran the command
that's why
that's why deleting the initiative command is compulsary in this case
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
to replace this?
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
i thought im using message.channel
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
message.channel returns a channel
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
ah
is my delete command alr or not
It has the same issue as the send message
Hmmmm
They both run when none of the if statements matched
There’s the empty embed one
but if i place it above within the validation, it still somehow error
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
but it's not
You need add a field or set a description in the embed
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
it works sometimes
and crrashes afterward
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Just keep ur sends and deletes in the command blocks
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
it's not rn?
No
Unless you changed it. I’m not downloading a file onto my phone
oh ur not on PC
what is considered within the command blocks
if (command === "…") {…}
That block
ln 183?
Yea, it’s clearly outside the command blocks
Is that even a real number?
yea...
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
what...
ln 283 = 5.209…
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
ln = line
Oh
what do u think it is
Natural log
.
Never seen anyone abbreviate line
Actually, L283
but that's vs code default abbv
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
okaie
yea what's wrong with it?
I don’t see a 283
183
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Yea
yea wdym
Technically yes
it works
All embed methods (besides toX methods) return itself
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Whether it’s necessary to do all of that is debatable
At most, I’d just reassign the messageOptions
uh sure
At least that way, you can check for null/undefined
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
one of my irl friends keep telling me to do that but im not sure how
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Pastebin Online - AppDevTools
Pastes text or code for online public viewing via a share link with syntax highlighting and an optional expiration period. Supports over 170 programming languages.
@Jordy
feel free to scan the link if ur concerned
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
idk i cba to register for online pastebin or smth like that
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
idk how to create
so
me dumb
so how's the code
and what should I fix
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Pastebin
require("dotenv").config();const { Client, IntentsBitField, EmbedBu...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
sometimes idk what im doing, is it extra
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
but the thing is if i do that
the commands that's expected for everyone would only work for discord mod somehow
idk why
allowedroleID is discord mod
allowedroleIDMemebr is obviously Member
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
eh.
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
sendOption isn’t an embed
Unknown User•6mo ago
Message Not Public
Sign In & Join Server To View
Just
.send(sendOption)
I usually just hardcode this part
.send({ embeds: [ embed ] });