Using intents in V14

I just updated a repo to v14 but cannot figure out how to wrangle intents at all. Can someone show me code that works correctly with the intents? The latest code that worked was something like
require('dotenv').config();
const fs = require('fs');
const Discord = require('discord.js');

const { Client, Collection} = require('discord.js');
const bot = new Client();
require('dotenv').config();
const fs = require('fs');
const Discord = require('discord.js');

const { Client, Collection} = require('discord.js');
const bot = new Client();
and now it gives TypeError [ClientMissingIntents]: Valid intents must be provided for the Client. at Client._validateOptions (/home/thetis/coding/SI_Card_Bot/node_modules/discord.js/src/client/Client.js:512:13) at new Client (/home/thetis/coding/SI_Card_Bot/node_modules/discord.js/src/client/Client.js:80:10)
13 Replies
d.js toolkit
d.js toolkit8mo 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!
d.js docs
d.js docs8mo ago
- Websocket intents limit events and decrease memory usage: learn more - See what intents you need here
Tim
TimOP8mo ago
thetis@thetis:~/coding/SI_Card_Bot$ npm list discord.js
[email protected] /home/thetis/coding/SI_Card_Bot

thetis@thetis:~/coding/SI_Card_Bot$ node -v
v20.12.0
thetis@thetis:~/coding/SI_Card_Bot$
thetis@thetis:~/coding/SI_Card_Bot$ npm list discord.js
[email protected] /home/thetis/coding/SI_Card_Bot

thetis@thetis:~/coding/SI_Card_Bot$ node -v
v20.12.0
thetis@thetis:~/coding/SI_Card_Bot$
d.js docs
d.js docs8mo ago
:guide: Additional Information: Updating from v12 to v13 read more :guide: Additional Information: Updating from v13 to v14 read more
Tim
TimOP8mo ago
I've tried reading both and still don't get it unfortunately. Something about the bot just stops working even if I give it some intents Let me try one of the codes and show For example
const { Client, Collection, GatewayIntentBits, Intents} = require('discord.js');
const bot = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});/**/
const PREFIX = "-";
const { Client, Collection, GatewayIntentBits, Intents} = require('discord.js');
const bot = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMembers,
],
});/**/
const PREFIX = "-";
I use this code, and the bot starts without any errors. And then does not change its own status or reply to -help anymore I cant tell why, do I need to specify a separate intent for every little thing? Send Messages, MessageContent, change Status etc?
NyR
NyR8mo ago
You don't need intents for sending messages/changing your own status, how are you doing all that? Show the relevant code
d.js docs
d.js docs8mo ago
:method: ClientUser#setPresence() Sets the full presence of the client user.
Tim
TimOP8mo ago
GitHub
SI_Card_Bot/index.js at main · TheOriginalSoni/SI_Card_Bot
Discord App for Spirit island. Contribute to TheOriginalSoni/SI_Card_Bot development by creating an account on GitHub.
Tim
TimOP8mo ago
I am basically updating to v14 so it can use forum posts and threads again Sorry I'm not well versed in JS, I usually use python for things, so just learning as I go
NyR
NyR8mo ago
You clearly didn't, because that is not v14, also you do not specify any intents when initiating your client The events you are listening to are outdated, activity type, use ActivityType enum, just read the updating guide
Tim
TimOP8mo ago
I just committed the code I was running locally latest. That's just the code I already shared above
NyR
NyR8mo ago
Also, its activities in v14 which takes an array, follow this doc Okay, that just added the intents, rest of the stuff is still the same the event message -> messageCreate , for settinf the presence, check the doc i linked
Tim
TimOP8mo ago
Yeah reading. I didnt write the repo so still picking up all NodeJs and Discord.js stuff at once I think I managed to get it work. Had to replace message with messagecreate and I think that was all? Thank you, it took me a while to understand what all changes needed to be followed. The full list of V13 V14 events is a bit hard to parse
Want results from more Discord servers?
Add your server