首页 > 解决方案 > 如何修复错误“Uncaught TypeError: Cannot read property 'id' of undefined”?

问题描述

所以我正在制作一个自我机器人(为什么不),我完成了第一个命令。它应该工作,但它没有这是代码:

const Discord = require("discord.js");
const fs = require("fs");
const ConsoleTitle = require("node-bash-title");
const bot = new Discord.Client({disableEveryone: true});
ConsoleTitle("Slefx")
bot.on("ready", async () => {
    console.log("Ready!");
    setTimeout( () => {
        console.log("Ready to go!");
    }, 2000)
})

bot.on("message", async () => {
    if(message.content === "!embed sus" ) return message.channel.send("https://embed.rauf.workers.dev/?author=Sussy&title=Bakka%2520B%29&description=Fuck%2520you%2520B%29&image=https%253A%252F%252Fmedia.sketchfab.com%252Fmodels%252F230ec756288e444c8e07f486ef9e8786%252Fthumbnails%252Feb28075b3cbe419bab000bd898b6f6ef%252F9d87472aded94922929162557fcec2d6.jpeg&redirect=https%253A%252F%252Ftherickroll.com");
})

bot.login("hahaucanloginwithmyaccountbecauseireplacedmycookiewiththis")

这是错误: Uncaught TypeError: Cannot read property 'id' of undefined

好吧,如果你看到这个,祝你有美好的一天:D。

标签: javascriptnode.jsdiscord

解决方案


您可能需要检查错误的来源,因为您的代码没有任何“id”。如果你能检查日志会更好。


推荐阅读