0
// 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#????

intent

discord

discord2

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?

Zsolt Meszaros
  • 21,961
  • 19
  • 54
  • 57
nayounsang
  • 83
  • 1
  • 6
  • As I mention in my linked answer, _"The `message` and `interaction` events are now removed. You can use the `messageCreate` and `interactionCreate` events instead."_ – Zsolt Meszaros Jun 04 '23 at 15:48

0 Answers0