javascript - 如何修复错误“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。
解决方案
您可能需要检查错误的来源,因为您的代码没有任何“id”。如果你能检查日志会更好。
推荐阅读
- ios - Swift iOS MetalKit draw a curve , why the end of the curve is always in the center, how can i fix it?
- nunjucks - What could cause a HPE_INVALID_METHOD error using fastify and nunjucks?
- python - How do i retrieve the variable name for each dict in a list of dicts?
- sql - 在 SQL Select 查询中指定列“百分比”的问题
- docker - 如何在容器启动后使用 docker-compose 中的表达式值设置 env 变量
- java - Keycloak 抱怨令牌端点上的 redirect_uri 无效
- powerbi - 计算累积值
- python - Power BI 中的 Python Plotly
- html - 无法取消 Ionic 是否提供折扣的实际价格
- android - 在带有前缀的 ABI 的 NDK 工具链文件夹中找不到工具链