pxldevv
HOBBYOP
2 years ago
const { Client, GatewayIntentBits, Message } = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.DirectMessages, GatewayIntentBits.MessageContent] });
client.on("ready", function(){
console.log(`the client becomes ready to start`);
console.log(`I am ready! Logged in as ${client.user.tag}!`);
});
client.on("messageCreate", function(message){
console.log(`a message was created`);
console.log({message});
});
client.login(token);I am able to get any other event but anything that has to do with messages just won't work.
23 Replies
// Require the necessary discord.js classes
const { Client, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');
// Create a new client instance
const client = new Client({ intents: [GatewayIntentBits.Guilds] });
// When the client is ready, run this code (only once).
// The distinction between `client: Client` and `readyClient: Client` is important for TypeScript developers.
// It makes some properties non-nullable.
client.once(Events.ClientReady, readyClient => {
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});
// Log in to Discord with your client's token
client.login(token);And then I added the Events.MessageCreate which is refrenced somewhere else.
lasse
PRO
2 years ago
@PixelZero You need GatewayIntentBits.GuildMessages
lasse
PRO
2 years ago
MessageContent
GuildMessages
… are required
lasse
PRO
2 years ago
Does it work? :D
lasse
PRO
2 years ago
Hmm wierd
lasse
PRO
2 years ago
Try ask in the discord.js server.
lasse
PRO
2 years ago
No .gg/djs
