bot not answering

i created command !membercount and when I enter the command, the bot does not display the membercount Theres no error code:
const { Client, GatewayIntentBits, ActivityType } = require("discord.js");

const prefix = "!";

const client = new Client({
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true,
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
],
});


client.on("message", message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

//

const messageArray = message.content.split("");
const argument = messageArray.slice(1)
const cmd = messageArray[0];

//

if (cmd === `${prefix}membercount`){
message.channel.send(`**membercount:** ${message.guild.memberCount}`)
}


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

const prefix = "!";

const client = new Client({
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true,
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
],
});


client.on("message", message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

//

const messageArray = message.content.split("");
const argument = messageArray.slice(1)
const cmd = messageArray[0];

//

if (cmd === `${prefix}membercount`){
message.channel.send(`**membercount:** ${message.guild.memberCount}`)
}


})
12 Replies
chewie
chewie•11mo ago
you are missing the MessageContent intent
Ggahramaq
Ggahramaq•11mo ago
still not working
chewie
chewie•11mo ago
the event is called messageCreate, not message
Ggahramaq
Ggahramaq•11mo ago
You mean like this?
client.on("messageCreate", message => {
})
client.on("messageCreate", message => {
})
chewie
chewie•11mo ago
yes
Ggahramaq
Ggahramaq•11mo ago
nope bot is still not working
chewie
chewie•11mo ago
are you even logging in
Ggahramaq
Ggahramaq•11mo ago
yes, i wrote token
chewie
chewie•11mo ago
show the full code without the token obviously
Ggahramaq
Ggahramaq•11mo ago
const { Client, GatewayIntentBits, ActivityType } = require("discord.js");
const welcome = require("./welcome.js")
const prefix = "!";

const client = new Client({
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true,
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
],
});

client.on("ready", () => {
console.log("Bot is online!");
console.log(`Nickname: ${client.user.username}`);
console.log(`ID: ${client.user.id}`);


client.user.setActivity({
name: "Prefix - !",
type: ActivityType.Streaming
});


welcome(client)
})

client.on("messageCreate", message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

//

const messageArray = message.content.split("");
const argument = messageArray.slice(1)
const cmd = messageArray[0];

//

if (cmd === `${prefix}membercount`){
message.channel.send(`**membercount:** ${message.guild.memberCount}`)
}


})



client.login("???");
const { Client, GatewayIntentBits, ActivityType } = require("discord.js");
const welcome = require("./welcome.js")
const prefix = "!";

const client = new Client({
allowedMentions: {
parse: ["users", "roles"],
repliedUser: true,
},
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessageReactions,
],
});

client.on("ready", () => {
console.log("Bot is online!");
console.log(`Nickname: ${client.user.username}`);
console.log(`ID: ${client.user.id}`);


client.user.setActivity({
name: "Prefix - !",
type: ActivityType.Streaming
});


welcome(client)
})

client.on("messageCreate", message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

//

const messageArray = message.content.split("");
const argument = messageArray.slice(1)
const cmd = messageArray[0];

//

if (cmd === `${prefix}membercount`){
message.channel.send(`**membercount:** ${message.guild.memberCount}`)
}


})



client.login("???");
chewie
chewie•11mo ago
why are you checking for !membercount at the end of messageCreate you have to check for membercount, since you already remove the prefix from cmd
Ggahramaq
Ggahramaq•11mo ago
client.on("messageCreate", message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

if (command === "membercount") {
message.channel.send(`**membercount:** ${message.guild.memberCount}`);
}
});
client.on("messageCreate", message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

if (command === "membercount") {
message.channel.send(`**membercount:** ${message.guild.memberCount}`);
}
});
like this? i did it finally!
Want results from more Discord servers?
Add your server