#[suggestion] changing the return type for events

1 messages · Page 1 of 1 (latest)

primal copper

I've only noticed the MessageCreate event but the return type for it is Promise<void>. I suggest changing it to Promise<any> because Promise<void> makes validating stuff and replying impossible. For example:

client.on("messageCreate", async Message => {
 let answer = Message.content;
 if (answer !== "cow") return await Message.channel.send("wrong answer"); // oops an error
})

Since I am returning a Promise<Message> i'll get a error saying that void and Message do not match. And that is why I suggest this, I do not want to use a more complicated to re-read validate statement

For example I can do this to go about the error:

client.on("messageCreate", async Message => {
 let answer = Message.content;
 if (answer !== "cow") {
  await Message.channel.send("wrong answer"); // oops an error
  return;
 }
})

but that is just unnecessary effort and unnecessary complication