简体   繁体   English

等待 dTypeError [ERR_INVALID_ARG_TYPE]:“id”参数必须是字符串类型。 收到未定义

[英]Waiting for the dTypeError [ERR_INVALID_ARG_TYPE]: The “id” argument must be of type string. Received undefined

I'm writing a discord bot using the discord.js v12.2.0 library and I get this error:我正在使用discord.js v12.2.0 库编写 discord 机器人,但出现此错误:

Waiting for the dTypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string.等待 dTypeError [ERR_INVALID_ARG_TYPE]:“id”参数必须是字符串类型。 Received undefined收到未定义

This is my code:这是我的代码:

const { MessageEmbed } = require("discord.js");
const { VultrexDB } = require("vultrex.db");
const messageData = new VultrexDB({
    name: "messages"
})

module.exports.run = (client, message, args) => {
    const member = message.mentions.members.first() || message.guild.members.cache.get(args[0]) || message.member;
    const messages = messageData.get(`${message.guild.id}-${member.id}`, 0);

    message.chanel.send(new MessageEmbed()
        .setColor("E67E22")
        .setAuthor(`Data | ${member.user.username}`, member.user.displayAvatarURL())
        .addField("Messages Sent:", messages, true)
    );
}

module.exports.help = {
    name: "messages",
    description: "view the amount of messages sent by a member"
}

module.exports.requirements = {
    clientPerms: ["EMBED_LINKS"],
    userPerms: [],
    ownerOnly: false
}

You should learn to debug especially since this error practically tells you the answer.你应该学习调试,尤其是因为这个错误实际上告诉你答案。 Did it tell you which line?有没有告诉你是哪条线? If so there;s your answer but incase it didnt:如果是这样,那是您的答案,但如果没有:

  1. Tells you invalid arg, this means you called a function (including a new class), and the arguments you passed in were invalid告诉您无效的 arg,这意味着您调用了 function(包括一个新类),而您传入的 arguments 无效
  2. Argument was undefined参数未定义

new VultrexDB , message.mentions.members.first , message.mentions.members.cache.get , messageData.get , new MessageEmbed , setColor , setAuthor , addField new VultrexDBmessage.mentions.members.firstmessage.mentions.members.cache.getmessageData.getnew MessageEmbedsetColorsetAuthoraddField

you can rule out MessageEmbed and message.mentions.members.first since they don't require any arguments, setColor , setAuthor , and addField` all are giving arguments您可以排除MessageEmbed and message.mentions.members.first since they don't require any arguments, setColor , setAuthor , and addField` 都提供 arguments

that leaves new VultrexDB , message.mentions.members.cache.get and messageData.get留下new VultrexDBmessage.mentions.members.cache.getmessageData.get

for message.mentions.members.cache.get , it only requires one argument, the id, and you pass it by args[0] , so to check if this is the problem just check if you have args对于message.mentions.members.cache.get ,它只需要一个参数,即 id,并且您通过args[0]传递它,因此要检查这是否是问题,只需检查您是否有 args

for new VultrexDB and messageData.get , those are VultrexDB based and idk it, so just look at a guide or the documentation if they have one.对于new VultrexDBmessageData.get ,它们是基于 VultrexDB 的并且是 idk 的,所以只要查看指南或文档(如果有的话)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 收到未定义和代码:'ERR_INVALID_ARG_TYPE' - TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined and code: 'ERR_INVALID_ARG_TYPE' [ERR_INVALID_ARG_TYPE]:“id”参数必须是字符串类型。 接收类型对象 - [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type object 图片上传错误:TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 接收类型未定义 - Image Upload Error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined 'TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 接收类型未定义' - 'TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined' 类型错误 [ERR_INVALID_ARG_TYPE]:“文件”参数必须是字符串类型。 接收类型对象 - TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object ERR_INVALID_ARG_TYPE - “from” 参数必须是字符串类型。 接收到一个 Array 实例 - ERR_INVALID_ARG_TYPE - The “from” argument must be of type string. Received an instance of Array TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 收到 Object 的实例 - TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received an instance of Object Webpack 类型错误'TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 接收类型布尔值(真)' - Webpack type error 'TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (true)' Node.js 应用程序类型错误 [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 接收类型对象 - Node.js app TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object 错误:TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 尝试 node utils/nftport/uploadFiles.js 时收到 undefined - error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined when trying node utils/nftport/uploadFiles.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM