[英]Error when trying to instantiate a new Message Object in Discord.js
{ author: message.author, content: message.content },
client.on("message", async message => { if (message.author && message.author.bot) { return; } try { const myMessage = new Discord.Message( client, { author: { id: "myID" }, content: "My new Message" }, message.channel ); console.log(myMessage);
{ author: message.author, content: message.content },
but to no avail.但无济于事。 The error was the same.
错误是一样的。 So what am I doing wrong here?
那么我在这里做错了什么?
After hacking the source code of discord.js I discovered the culprit in the Message.js file.在破解discord.js的源代码后,我在Message.js文件中发现了罪魁祸首。 It is this line:
就是这一行:
this.createdTimestamp = SnowflakeUtil.deconstruct(this.id).timestamp;
The problem is that I never passed any id
to the constructor function in my data
object.问题是我从未在我的
data
object 中将任何id
传递给构造函数 function。 Just passing a fake id (a string of random numbers) did the trick.只需传递一个假 id(一串随机数)就可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.