I started a new project to make a bot for discord, but I always use the same setup every time I create a new discord bot project and update the setup if there is an update in discord.js. In here, I was trying to send a message when the user('s) sends a message.
import { Client, IntentsBitField } from "discord.js"
const client = new Client({
intents: [
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.Guilds
]
});
import dotenv from "dotenv"
dotenv.config();
client.on("ready", () => {
console.log("astoon bot is READY!");
});
// Detecting if there is a message created.
client.on("messageCreate", (message) => {
if (message.content === "ping") {
message.reply("Pong!");
};
});
client.login(process.env.TOKEN);