[英]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:
如果是这样,那是您的答案,但如果没有:
new VultrexDB
, message.mentions.members.first
, message.mentions.members.cache.get
, messageData.get
, new MessageEmbed
, setColor
, setAuthor
, addField
new VultrexDB
、 message.mentions.members.first
、 message.mentions.members.cache.get
、 messageData.get
、 new MessageEmbed
、 setColor
、 setAuthor
、 addField
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 VultrexDB
、 message.mentions.members.cache.get
和messageData.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 VultrexDB
和messageData.get
,它们是基于 VultrexDB 的并且是 idk 的,所以只要查看指南或文档(如果有的话)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.