Discord bot just answers in DMs

Joined
Nov 1, 2022
Messages
2
Reaction score
0
Hi
I develop a discord bot with Javascript and the bot doesn't answer in the server.

He has the permission and is online. What am I doing wrong?

require('dotenv').config();
const Discord = require('discord.js');
const client = new Discord.Client({intents: ['GUILDS', 'GUILD_MESSAGES']});
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`) })


// messages
client.on('message', (message) => {

if (message.content === 'test') {
message.channel.send('I work correctly!');
}

if (message.content === 'server') {
message.channel.send(`Server name: ${message.guild.name}\nTotal members: ${message.guild.memberCount}`);
}
});
client.login('MYSECRETCODE001248422...');

Thank you for your help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,529
Members
45,001
Latest member
Kendra00E1

Latest Threads

Top