Responding to messages
// index.js
// add this to your index.js file, preferably above the ready event listener
client.on("messageCreated", async message => {
if(!message.content.startsWith("!")) return;
// type 0 is for bots
if(message.author.type === 0) return;
if(message.content === "!hi") return message.reply("hi there!");
});// index.ts
// add this to your index.ts file, preferably above the ready event listener
client.on("messageCreated", async message => {
if(!message.content.startsWith("!")) return;
// type 0 is for bots
if(message.author.type === 0) return;
if(message.content === "!hi") return message.reply("hi there!");
});Some practice concepts for you
Last updated
Was this helpful?