“库未定义” -node.js 不和谐机器人
我正在尝试为我的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题正是错误所说的,您没有在任何地方定义变量
lib
。您需要在文件顶部定义它。根据 Autocode 的 示例 之一,它看起来像:此行未在提供的代码中的任何位置显示你的问题,所以我认为这就是你遇到的问题。请注意,必须在使用它的每个文件中定义
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: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 havinglib
in one file doesn't make it accessible as a variable in all of your files.