// js code
import Discord from 'discord.js';
const { Client, GatewayIntentBits } = Discord;
import fs from 'fs'
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
]
});
client.once('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
const token = JSON.parse(fs.readFileSync('./????/token.json'));
client.login(token.token);
client.on('message',(message)=>{
console.log(message.content);
})
terminal
PS C:\Users\?????\mybot> node main.js
Logged in as mybot#????
I want to create a bot that outputs a message to the console when a message is entered on the server to which the bot belongs.
My bot is logged in and its state is online. However when i send message in the server, it is not worked. What is the problem?