“库未定义” -node.js 不和谐机器人

发布于 2025-01-11 07:33:03 字数 793 浏览 0 评论 0原文

我正在尝试为我的 node.js 自动编码不和谐机器人制作验证码,这是我的代码:

let verifiedRole = `${process.env.Verified}`;

//Assigns role to member after using /verify
await lib.discord.guilds['@0.1.0'].members.roles.update({
  role_id: `${verifiedRole}`,
  user_id: context.params.event.member.user.id,
  guild_id: `${context.params.event.guild_id}`,
});

我收到此错误:

RuntimeError: lib is not defined

ReferenceError: lib is not defined
    at (/functions/events/discord/message/button/interaction.js:5:1)

The JSON output of the error is below.
{
  "error": {
    "type": "RuntimeError",
    "message": "lib is not defined",
    "stack": "ReferenceError: lib is not defined\n    at (/functions/events/discord/message/button/interaction.js:5:1)"
  }

有人可以帮助我吗???

i am trying to make a verification code for my node.js autocode discord bot, here is my code:

let verifiedRole = `${process.env.Verified}`;

//Assigns role to member after using /verify
await lib.discord.guilds['@0.1.0'].members.roles.update({
  role_id: `${verifiedRole}`,
  user_id: context.params.event.member.user.id,
  guild_id: `${context.params.event.guild_id}`,
});

i am getting this error:

RuntimeError: lib is not defined

ReferenceError: lib is not defined
    at (/functions/events/discord/message/button/interaction.js:5:1)

The JSON output of the error is below.
{
  "error": {
    "type": "RuntimeError",
    "message": "lib is not defined",
    "stack": "ReferenceError: lib is not defined\n    at (/functions/events/discord/message/button/interaction.js:5:1)"
  }

can someone please help me???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖兔^ω^ 2025-01-18 07:33:03

问题正是错误所说的,您没有在任何地方定义变量 lib 。您需要在文件顶部定义它。根据 Autocode 的 示例 之一,它看起来像:

const lib = require("lib")({token: '{{ YOUR IDENTITY TOKEN }}'})`

此行未在提供的代码中的任何位置显示你的问题,所以我认为这就是你遇到的问题。请注意,必须在使用它的每个文件中定义 lib ,以便能够在这些文件中使用它。仅在一个文件中包含 lib 并不能使其在所有文件中作为变量进行访问。

The issue is exactly what the error says, you are not defining the variable lib anywhere. You need to define it at the top of the file. According to one of Autocode's examples, it looks something like:

const lib = require("lib")({token: '{{ YOUR IDENTITY TOKEN }}'})`

This line is not shown anywhere within the code provided in your question, so I assume this is the issue you are having. Note that lib must be defined in every file you are using it in, in order to be able to use it in those files. Just having lib in one file doesn't make it accessible as a variable in all of your files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文