#TypeError: Cannot destructure property 'id' of 'data' as it is undefined.
54 messages · Page 1 of 1 (latest)
• 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.
import { EmbedBuilder, WebhookClient } from "discord.js";
const wh = new WebhookClient(process.env.WEBHOOK_URL);
export async function logger(req, res, nextz) {
var incomingIP = req.ip.split(':').pop();
const logEmbed = new EmbedBuilder()
.setColor(0xfa9a50)
.setTitle(`Request Recieved.`)
.addFields(
{ name: "Request type:", value: `\`\`\`${req.method}\`\`\``, inline: true },
{ name: "Request endpoint", value: `\`\`\`${req.baseUrl}\`\`\``, inline: true },
{ name: "Request IP Adress", value: `\`\`\`${incomingIP}\`\`\``, inline: true }
)
wh.send(logEmbed)
next()
}
❯ node -v
v18.12.1
+-- @prisma/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]
the thread name @gusty matrix
let { id, token } = data;
^
TypeError: Cannot destructure property 'id' of 'data' as it is undefined.
at new WebhookClient (C:\Users\corrupted\Desktop\Projects\Landify\node_modules\discord.js\src\cli
ent\WebhookClient.js:46:11)
at file:///C:/Users/corrupted/Desktop/Projects/Landify/utils/logging.js:3:12
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
at async loadESM (node:internal/process/esm_loader:91:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)
try using id and token
why would i use that im trying to use wbhooks
how do i get those
oh t hank
works?
let me
i think webhooks take an object, not sure tho
uh oh
uh oh what
look
{ name: "Request endpoint", value: `\`\`\`${req.baseUrl}\`\`\``, inline: true },
yeah?
have you worked with expressjs
not really
whats [object Object] bro
why is it not just showing the object like
{}
log it
it logs object Object
.setDescription(`\`\`\`${req.body}\`\`\``)
ok so what
i cant really think of an answer
console.log(req.body) as it‘s clearly an object and you can’t just put it in a template literal like that and expect it to work