小编gok*_*max的帖子

类型错误:Object.hasOwn 不是函数

我尝试使用新的 Discord.js 版本编写机器人,但当我尝试登录时,它提示我此错误

/home/max/Schreibtisch/Discord Bots/Perplex/node_modules/discord.js/src/util/Util.js:279
    if (!Object.hasOwn(given, key) || given[key] === undefined) {
                ^

TypeError: Object.hasOwn is not a function
    at mergeDefault (/home/max/Schreibtisch/Discord Bots/Perplex/node_modules/discord.js/src/util/Util.js:279:17)
    at new BaseClient (/home/max/Schreibtisch/Discord Bots/Perplex/node_modules/discord.js/src/client/BaseClient.js:25:20)
    at new Client (/home/max/Schreibtisch/Discord Bots/Perplex/node_modules/discord.js/src/client/Client.js:43:5)
    at Object.<anonymous> (/home/max/Schreibtisch/Discord Bots/Perplex/src/bot.js:26:16)
    at Module._compile (node:internal/modules/cjs/loader:1108:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1137:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Function.Module._load (node:internal/modules/cjs/loader:828:14)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47
Run Code Online (Sandbox Code Playgroud)

这是我的机器人代码

/home/max/Schreibtisch/Discord Bots/Perplex/node_modules/discord.js/src/util/Util.js:279
    if (!Object.hasOwn(given, key) || given[key] === undefined) {
                ^

TypeError: Object.hasOwn is not a function
    at mergeDefault (/home/max/Schreibtisch/Discord Bots/Perplex/node_modules/discord.js/src/util/Util.js:279:17)
    at …
Run Code Online (Sandbox Code Playgroud)

javascript node.js discord discord.js

13
推荐指数
1
解决办法
2万
查看次数

标签 统计

discord ×1

discord.js ×1

javascript ×1

node.js ×1