Reputation: 8962
Cannot read property 'slice' of undefined
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?
Upvotes: 1
Views: 213
Reputation: 8962
After hacking the source code of discord.js I discovered the culprit in the Message.js file. 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. Just passing a fake id (a string of random numbers) did the trick.
Upvotes: 1