pxldevv
HOBBY
a year 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.
0 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);
a year ago
@PixelZero You need GatewayIntentBits.GuildMessages
a year ago
MessageContent
GuildMessages
… are required
a year ago
Does it work? :D
a year ago
Hmm wierd
a year ago
Try ask in the discord.js server.
a year ago
No .gg/djs