#Error, v14 messageCreate

9 messages · Page 1 of 1 (latest)

obtuse pine
#

const { Client, GatewayIntentBits } = require('discord.js');
const Discord = require("discord.js");

const TOKEN="REDACTED"

const client = new Discord.Client({
intents: [GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMembers,]
})

require('dotenv').config();

client.on('ready', () => {
// channel.send("My Message")
console.log(Logged in as ${client.user.tag}!);
});

client.on("messageCreate", msg => {
if (msg.content === "ping") {
msg.reply("pong");
}
})

client.on('guildMemberAdd', (member) => {
console.log(member)
});

client.on('interactionCreate', async (interaction) => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'ping') {
    await interaction.reply('Pong!');
}

});

client.login(TOKEN);

^^^^^^
please help, this code doesn't work
when someone types "ping" inside a server it doesn't reply with "pong"

peak lodgeBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

fathom fractal
#

You dont have MessageContrnt intent

#

And I recommend using slash commands way easier and better supported by discord

obtuse pine
#

in the discord website I enabled all privileged gateway intents...if that's what you're talking about

obtuse pine
fathom fractal
obtuse pine