message not being read

The bot is not reading the message and replying
63 Replies
d.js toolkit
d.js toolkit•2y ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Elvin
ElvinOP•2y ago
"discord.js": "^14.13.0"
treble/luna
treble/luna•2y ago
you do not have the GuildMessages and/or MessageContent intent
Elvin
ElvinOP•2y ago
when I put GuildMessages or MessageContent it shows error on my terminal
treble/luna
treble/luna•2y ago
then you have to enable the intent in the developer portal
Elvin
ElvinOP•2y ago
do you mean this one
No description
treble/luna
treble/luna•2y ago
the message content one yes
Elvin
ElvinOP•2y ago
still doesnt work restarted the bot and turned the message content to on
treble/luna
treble/luna•2y ago
define does not work did you add the intents to your client constructor
Elvin
ElvinOP•2y ago
okay now it works
import { Client, GatewayIntentBits, IntentsBitField } from "discord.js";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
import { Client, GatewayIntentBits, IntentsBitField } from "discord.js";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
treble/luna
treble/luna•2y ago
and how are you listening for messages
Elvin
ElvinOP•2y ago
when I use the IntentsBitField.GuildMessages it throws error throw new DiscordjsRangeError(ErrorCodes.BitFieldInvalid, bit); ^ RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.
treble/luna
treble/luna•2y ago
npm ls discord.js
Elvin
ElvinOP•2y ago
Didnt send that code jajajaaja already installed?
treble/luna
treble/luna•2y ago
thats not what i'm asking just run the command
Elvin
ElvinOP•2y ago
what does it do
treble/luna
treble/luna•2y ago
it lists the version of djs you are using
Elvin
ElvinOP•2y ago
treble/luna
treble/luna•2y ago
did you save your code
Elvin
ElvinOP•2y ago
yes mam
treble/luna
treble/luna•2y ago
can you show the full error stack also wait why are you using GatewayIntentBits but telling me you use IntentsBitField
Elvin
ElvinOP•2y ago
No description
treble/luna
treble/luna•2y ago
well yeah, IntentsBitField.GuildMessages is indeed undefined
Elvin
ElvinOP•2y ago
when I used IntentsBitField it gave the above eror
treble/luna
treble/luna•2y ago
i dont see why you are using both GatewayIntentBits and IntentBitsField
Elvin
ElvinOP•2y ago
are both the same
treble/luna
treble/luna•2y ago
if you use it correclty, yes either use GatewayIntentBits.GuildMessages, like you did before
Elvin
ElvinOP•2y ago
okay
treble/luna
treble/luna•2y ago
or intentsbitfields but you have to put Flags first which then returns GatewayIntentBits regardless
Elvin
ElvinOP•2y ago
Idk whats a Flag is it a boolean
treble/luna
treble/luna•2y ago
its a property just use GatewayIntentBits
Elvin
ElvinOP•2y ago
okay thanks one more error cannot use import out a module
treble/luna
treble/luna•2y ago
thats not really djs realted, either change to require()
Elvin
ElvinOP•2y ago
I have "type":"module" in my package.json
treble/luna
treble/luna•2y ago
yeah not djs related anymore at this point
Elvin
ElvinOP•2y ago
client is the bot and guild is the server right
treble/luna
treble/luna•2y ago
yes
Elvin
ElvinOP•2y ago
Im trying to run the commands file do i run it npm run start commands.js
treble/luna
treble/luna•2y ago
those are 3 scripts either run node <yourfile> or create a script and run that script
Elvin
ElvinOP•2y ago
how do I do that I did this
treble/luna
treble/luna•2y ago
and what did it output you also ran it before so just run the same command you ran before
Elvin
ElvinOP•2y ago
node commands.js Started refreshing application (/) commands. Successfully reloaded application (/) commands.
treble/luna
treble/luna•2y ago
thats to deploy your commands
Elvin
ElvinOP•2y ago
im confused now I have 2 files index.js and commands.js
treble/luna
treble/luna•2y ago
that is indeed correct your command.js file is just to deploy your commands your index is your main file
Elvin
ElvinOP•2y ago
yes
Elvin
ElvinOP•2y ago
No description
treble/luna
treble/luna•2y ago
do you have an event handler
Elvin
ElvinOP•2y ago
nope gotta make one
treble/luna
treble/luna•2y ago
also why does your account reply with the interaction failed message lol
Elvin
ElvinOP•2y ago
you shld say Idk lol im getting again module error @wolvinny 🌈
treble/luna
treble/luna•2y ago
and it again is not djs related
Elvin
ElvinOP•2y ago
again now its not working
treble/luna
treble/luna•2y ago
define not working
Elvin
ElvinOP•2y ago
this is my code its not reading inpt
import { Client, GatewayIntentBits } from "discord.js";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
],
});

client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
});

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

console.log(interaction.commandName);
});

client.login(
TOKEN
);
import { Client, GatewayIntentBits } from "discord.js";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
],
});

client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
});

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

console.log(interaction.commandName);
});

client.login(
TOKEN
);
Elvin
ElvinOP•2y ago
have this turned on too
No description
treble/luna
treble/luna•2y ago
and has your bot logged in
Elvin
ElvinOP•2y ago
yes its online
treble/luna
treble/luna•2y ago
intents dont matter here do you run a slash command
Elvin
ElvinOP•2y ago
yes okay wait how can I make the bot respond to a chat when someone send helo
treble/luna
treble/luna•2y ago
<Interaction>.reply()
Elvin
ElvinOP•2y ago
I added a new command and it was succesfully uploaded but its not showing
treble/luna
treble/luna•2y ago
refresh your discord

Did you find this page helpful?