Issues with sending embeds

Hi, I have a discord bot which sends DMs directly to users (for notifications) including an embed, recently, ive done an update which removed the embeds directly from the code files, and added them to a specific embeds.js, and made each embed a function which returns the embed, because some data in the embed is personalized for the specific message or user. Recently though, when i try to send a DM with an embed after this change that I did, the messages don't get sent. The error stack: https://pastebin.com/GPdgFNZz
Pastebin
C:\Users\OneDrive\Desktop\Code\node_modules@sapphire\shapes - Pa...
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.
30 Replies
d.js toolkit
d.js toolkit17mo 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!
Eddippla
EddipplaOP17mo ago
Node version v18.17.0 [email protected]
grass
grass17mo ago
one of your fields has an invalid value, please show embeds.js line 93 please
Eddippla
EddipplaOP17mo ago
Sure
.addFields(
{ name: "Support Server", value: config.supportinvite },
{ name: "Warning ID", value: id},
{ name: "Your User ID", value: userid },
{ name: "Reason", value: reason }
);
.addFields(
{ name: "Support Server", value: config.supportinvite },
{ name: "Warning ID", value: id},
{ name: "Your User ID", value: userid },
{ name: "Reason", value: reason }
);
config.supportinvite is a string, the servers invite warning id is a mongodb id with .toString() user id is a discord user id (input validated, string) reason is input validated to be a string too
grass
grass17mo ago
can you add this to your code and show the full log?
console.log([
config.supportinvite,
id,
userid,
reason
]);
console.log([
config.supportinvite,
id,
userid,
reason
]);
Eddippla
EddipplaOP17mo ago
sure 1 sec will run it now
Eddippla
EddipplaOP17mo ago
[ 'https://discord.gg/GWE(UGH#WEYBY@B#^Y&*', 'xxxxxxxxxxxx', undefined, 'test' ]
Discord
Discord | Your Place to Talk and Hang Out
Discord is the easiest way to talk over voice, video, and text. Talk, chat, hang out, and stay close with your friends and communities.
Eddippla
EddipplaOP17mo ago
The undefined shouldnt be there
grass
grass17mo ago
so then userid is undefined
Eddippla
EddipplaOP17mo ago
I will need to check that rn lol
grass
grass17mo ago
also, maybe change that invite / dont show it
Eddippla
EddipplaOP17mo ago
No i changed it to xxxxxx
grass
grass17mo ago
its still a valid invite
Eddippla
EddipplaOP17mo ago
Not to my server lol
grass
grass17mo ago
doesnt matter
Eddippla
EddipplaOP17mo ago
Ok now its random
grass
grass17mo ago
👍
Eddippla
EddipplaOP17mo ago
Ok ill now need to check why the userid is undefined Really strange lol damn i found it I did input validation but forgot to put in the input validated strings Ok the embed issue is fixed but now theres something else let me see if i can fix that before I ask for help ont hat onet oo
grass
grass17mo ago
did you get it fixed?
Eddippla
EddipplaOP17mo ago
no lol it was way more advanced than i thought so whats happening is it saves a warning for a user, and then dms the warned user, all successfully but then the api i have for warning users returns a error 500
{
"status": false,
"err": "Failed to warn user: TypeError: Cannot read properties of undefined (reading 'send')"
}
{
"status": false,
"err": "Failed to warn user: TypeError: Cannot read properties of undefined (reading 'send')"
}
and this ill try to send more info now honestly the only way that it can error out is when the promise rejects but the only way i programmed the promise to reject is when it doesnt save the warning successfully to the database how is that even possible
await warnNow(client, userid, reason)
.then((res) => {
res.send({ status: true, content: "Successfully warned user." });
return;
})
.catch((err) => {
res
.status(500)
.send({ status: false, err: "Failed to warn user: " + err });
return;
});
await warnNow(client, userid, reason)
.then((res) => {
res.send({ status: true, content: "Successfully warned user." });
return;
})
.catch((err) => {
res
.status(500)
.send({ status: false, err: "Failed to warn user: " + err });
return;
});
do you think u can help @grass ?
grass
grass17mo ago
what does warnNow return
Eddippla
EddipplaOP17mo ago
it returns a promise
grass
grass17mo ago
what does it resolve to
Eddippla
EddipplaOP17mo ago
what do you mean like the value it resolves? cause when i just do resolve()
grass
grass17mo ago
when you resolve the promise it returns, what value do you have
Eddippla
EddipplaOP17mo ago
i just do resolve(); without any value
grass
grass17mo ago
so then res is undefined
Eddippla
EddipplaOP17mo ago
yes
grass
grass17mo ago
therefore you cannot call send() on it
Eddippla
EddipplaOP17mo ago
.then((res) => { res.send({ status: true, content: "Successfully warned user." }); return; }) i just realized res is the response of the promise but also the response for express js damn thats the issu bro you helped me so much frfr ty bro it actually works now everything

Did you find this page helpful?