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
No description
No description
140 Replies
d.js toolkit
d.js toolkit6mo ago
- 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!
Kinect3000
Kinect30006mo ago
You can’t delete a message that has already been deleted
electric
electricOP6mo ago
so the message.delete is extra?
Kinect3000
Kinect30006mo ago
This likely happens due to race conditions Could be someone that deletes their message quicker than you can receive it
electric
electricOP6mo ago
no but like id like the bot to delete the initiative command how can I manage to do that?
Kinect3000
Kinect30006mo ago
Ur not checking if it’s a command tho Ur just deleting all messages sent by users who have that role
electric
electricOP6mo ago
Fr? I thought Im deleting the initiative message?? Ex. -(prefix)app in this case
Kinect3000
Kinect30006mo ago
It’s outside of the if statements of the commands
electric
electricOP6mo ago
so I should place it within the if statement?
Kinect3000
Kinect30006mo ago
That’s one way
electric
electricOP6mo ago
like somewhere between ln 182 and 183
Kinect3000
Kinect30006mo ago
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 minimum
electric
electricOP6mo ago
here's the issue even if I deleted the delete statement it will still delete the initiative command why's that?
Kinect3000
Kinect30006mo ago
Error occurred elsewhere
electric
electricOP6mo ago
im pretty sure it's here tho since if i deleted this, my bot will work perfectly fine
Kinect3000
Kinect30006mo ago
I thought you said it still errors after removing it? Oh, I misread Delete is happening elsewhere
electric
electricOP6mo ago
see if i do this my bot will not crash
No description
Kinect3000
Kinect30006mo ago
Can you stop/kill the bot and see if it still deletes the message? Could be running another instance of the bot
electric
electricOP6mo ago
nope it won't delete it's the bot if I send the full file will that help?
Kinect3000
Kinect30006mo ago
Just look for another message.delete in ur code
electric
electricOP6mo ago
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
Kinect3000
Kinect30006mo ago
It could have the same issue as the code you originally showed has
electric
electricOP6mo ago
it doesn't tho it works perfectly fine for that section that's when the confusion hits
Kinect3000
Kinect30006mo ago
Try commenting out the message.delete
electric
electricOP6mo ago
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?
Kinect3000
Kinect30006mo ago
Show the error
electric
electricOP6mo ago
No description
Kinect3000
Kinect30006mo ago
That’s a different error
electric
electricOP6mo ago
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
Kinect3000
Kinect30006mo ago
You got Unknown Message too?
electric
electricOP6mo ago
yes
Kinect3000
Kinect30006mo ago
Right above or below that one?
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
hm what should I replace with
Kinect3000
Kinect30006mo ago
It wouldn’t work if none of the if statements executed
electric
electricOP6mo ago
well it didn't come at the same time but i believe it exists together
Kinect3000
Kinect30006mo ago
What?
electric
electricOP6mo ago
both problem exists the error panel just show the higher priority ones
Kinect3000
Kinect30006mo ago
No Ur bot’s not crashing Surprisingly considering unhandled rejections are deprecated
electric
electricOP6mo ago
hope this can spot the issue
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
You can’t send an empty message
electric
electricOP6mo ago
i didn't embed is not considered an empty message i think
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
Ur code always sends the "message", regardless of whether any of the if statement executed or not
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
but if i place it above it's still error somehow
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
It seems to be general problem in ur code
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
hm how should I replace
Kinect3000
Kinect30006mo ago
I would just send in the commands
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
There’s no interaction here
electric
electricOP6mo ago
yea it's an initiative command like if I send a message like -app
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
the embed will be sent and the initiative message will be deleted
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
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
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
to replace this?
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
i thought im using message.channel
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
message.channel returns a channel
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
ah is my delete command alr or not
Kinect3000
Kinect30006mo ago
It has the same issue as the send message
electric
electricOP6mo ago
Hmmmm
No description
Kinect3000
Kinect30006mo ago
They both run when none of the if statements matched There’s the empty embed one
electric
electricOP6mo ago
but if i place it above within the validation, it still somehow error
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
but it's not
Kinect3000
Kinect30006mo ago
You need add a field or set a description in the embed
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
No description
electric
electricOP6mo ago
it works sometimes and crrashes afterward
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
Just keep ur sends and deletes in the command blocks
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
it's not rn?
Kinect3000
Kinect30006mo ago
No Unless you changed it. I’m not downloading a file onto my phone
electric
electricOP6mo ago
oh ur not on PC what is considered within the command blocks
Kinect3000
Kinect30006mo ago
if (command === "…") {…}
electric
electricOP6mo ago
No description
Kinect3000
Kinect30006mo ago
That block
electric
electricOP6mo ago
ln 183?
Kinect3000
Kinect30006mo ago
Yea, it’s clearly outside the command blocks Is that even a real number?
electric
electricOP6mo ago
yea...
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
No description
electric
electricOP6mo ago
what...
Kinect3000
Kinect30006mo ago
ln 283 = 5.209…
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
ln = line
Kinect3000
Kinect30006mo ago
Oh
electric
electricOP6mo ago
what do u think it is
Kinect3000
Kinect30006mo ago
Natural log
electric
electricOP6mo ago
.
Kinect3000
Kinect30006mo ago
Never seen anyone abbreviate line Actually, L283
electric
electricOP6mo ago
but that's vs code default abbv
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
okaie yea what's wrong with it?
Kinect3000
Kinect30006mo ago
I don’t see a 283
electric
electricOP6mo ago
183
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
Yea
electric
electricOP6mo ago
yea wdym
Kinect3000
Kinect30006mo ago
Technically yes
electric
electricOP6mo ago
it works
Kinect3000
Kinect30006mo ago
All embed methods (besides toX methods) return itself
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
Whether it’s necessary to do all of that is debatable At most, I’d just reassign the messageOptions
electric
electricOP6mo ago
uh sure
Kinect3000
Kinect30006mo ago
At least that way, you can check for null/undefined
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
one of my irl friends keep telling me to do that but im not sure how
d.js docs
d.js docs6mo ago
:guide: Creating Your Bot: Event handling - Individual event files read more
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs6mo ago
:guide: Creating Your Bot: Event handling read more
electric
electricOP6mo ago
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.
electric
electricOP6mo ago
@Jordy feel free to scan the link if ur concerned
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
idk i cba to register for online pastebin or smth like that
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
idk how to create so me dumb so how's the code and what should I fix
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
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
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
sometimes idk what im doing, is it extra
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
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
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
electric
electricOP6mo ago
No description
electric
electricOP6mo ago
eh.
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
sendOption isn’t an embed
Unknown User
Unknown User6mo ago
Message Not Public
Sign In & Join Server To View
Kinect3000
Kinect30006mo ago
Just .send(sendOption) I usually just hardcode this part .send({ embeds: [ embed ] });
Want results from more Discord servers?
Add your server