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
you are missing the MessageContent intent
still not working
the event is called messageCreate, not message
You mean like this?
client.on("messageCreate", message => {
})
client.on("messageCreate", message => {
})
yes
nope
bot is still not working
are you even logging in
yes, i wrote token
show the full code
without the token obviously
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("???");
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
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}`);
}
});