首页 > 解决方案 > 如何修复“TypeError:无法读取未定义的属性‘包含’”

问题描述

我已经在我的机器人上发出命令,但是这个问题在几个小时内都可以正常工作,但突然它抛出了一个错误。

exports.run = (client, message, args) => {

    if (!args[0].includes("https://www.roblox.com/games/")) return message.reply("Invalid Format!"); 

    // ^ Where it throws an error - TypeError: Cannot read property 'includes' of undefined

    const { pathname } = new URL(args[0]);
    if (!pathname) return message.channel.send("Invalid URL Provided");
    let id = pathname.slice(pathname.indexOf("s/") + 2, pathname.lastIndexOf("/"));

}

标签: javascriptnode.js

解决方案


推荐阅读