Following a tutorial from 2020 and unsure of how I'm supposed to define Intents.

I'm following this tutorial by Sethey17 to make a simple Discord bot for my server that would be able to bulk delete messages in response to a command. https://www.youtube.com/watch?v=fx6oJ4PQDOs I'm on step two and I keep getting the following error when I try to run the code in the terminal. I've checked the code for typos and used JSHint. From what I can understand and find online (mind you, this is the first time I've ever made a bot or used Javascript) this is because Discord needs me to set the permissions for the bot via Intents. I can't seem to get a confirmation on exactly how to do this anywhere online, other than that the way used in Sethey17's tutorial may no longer be correct. How do I fix this so I can move on to the next step? Node.js v22.11.0 PS C:\Users\dogkn\Documents\Tomatogen> node index.js C:\Users\dogkn\Documents\Tomatogen\node_modules\discord.js\src\client\Client.js:529 throw new DiscordjsTypeError(ErrorCodes.ClientMissingIntents); ^ TypeError [ClientMissingIntents]: Valid intents must be provided for the Client. at Client._validateOptions (C:\Users\dogkn\Documents\Tomatogen\node_modules\discord.js\src\client\Client.js:529:13) at new Client (C:\Users\dogkn\Documents\Tomatogen\node_modules\discord.js\src\client\Client.js:80:10) at Object.<anonymous> (C:\Users\dogkn\Documents\Tomatogen\index.js:2:13) at Module._compile (node:internal/modules/cjs/loader:1546:14) at Object..js (node:internal/modules/cjs/loader:1689:10) at Module.load (node:internal/modules/cjs/loader:1318:32) at Function._load (node:internal/modules/cjs/loader:1128:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:218:24) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5) { code: 'ClientMissingIntents' }
Sethey17
YouTube
How to make a Discord Bot - Our First Code!
We are no longer helping with bot coding. I am currently in college and no longer have time to help or make videos, and my helpers have lives too so they arent available much either. If you are really interested in making discord bots I suggest you go watch some JavaScript tutorials and read the discord.js documentation. Thank you for all the su...
20 Replies
d.js toolkit
d.js toolkit2w 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! - Marked as resolved by OP
Amgelo
Amgelo2w ago
the only tutorial you should be following is the official guide
d.js docs
d.js docs2w ago
:guide: Home: Introduction read more
Amgelo
Amgelo2w ago
that tutorial seems to be using djs v11 that's 3 major versions behind (we're on v14)
From what I can understand and find online (mind you, this is the first time I've ever made a bot or used Javascript) this is because Discord needs me to set the permissions for the bot via Intents
intents aren't really permissions, but like a way to tell discord what data the bot needs, so you don't get computationally burdened with events you don't care about the only intents that work kind of like "permissions" are the priviliged ones, like MESSAGE_CONTENT, they're related to user privacy and need to be approved manually by discord when you verify
Hachiko ✨ Rook
Hachiko ✨ RookOP2w ago
I'm fine with that but unless I missed something the official guide does not seem to tell me how to do what I want to do (I want to make a bot that will mass-delete messages, preferably from before a certain time, when a moderator tells it to do so, and I want it to only do that)
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View
Amgelo
Amgelo2w ago
well the guide won't tell you everything, but you should use it as the starting point
Hachiko ✨ Rook
Hachiko ✨ RookOP2w ago
I will explain my problem and perhaps you can explain to me a way to do this correctly, because I'm confused as to how this is spam. I have a Discord server with a channel for people to post when they go live. The channel is locked and streamers can only post there, once, when they go live. I would like to be able to clear this channel from time to time, because once the streamer is no longer live these messages are useless. I want to make a bot where when a moderator types a specific command in the channel, it clears the channel of all of these messages (once again, it would be nice if it was before a certain period of time, so the moderator can choose not to delete messages that are still relevant) instead of the moderator having to go in and manually delete them one by one.
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View
Hachiko ✨ Rook
Hachiko ✨ RookOP2w ago
that sounds like a reasonable limitation, why can't I just tell the bot to abide by that?
Unknown User
Unknown User2w ago
Message Not Public
Sign In & Join Server To View
Hachiko ✨ Rook
Hachiko ✨ RookOP2w ago
ClearChat offers the option to clear messages from a channel and is approved by Discord, so I assume there is a legitimate way to give your bot orders to delete messages. I wanted something functionally similar. I assume I would have to add some limitations to prevent people from spamming the bot. For the purposes of the bot I'm making, 100 messages would be a week or two, minimum, more like a month.
Amgelo
Amgelo2w ago
that bot can't delete more than 100 messages
Hachiko ✨ Rook
Hachiko ✨ RookOP2w ago
at a time? in total? with a cooldown?
Amgelo
Amgelo2w ago
its clearall command clones the channel, its clear command uses the GuildMessageManager#fetch() method, which uses the channelMessages endpoint, which doesn't support more than 100 messages it doesn't seem to perform any kind of iteration unless its public version is different than the one in their github
Hachiko ✨ Rook
Hachiko ✨ RookOP2w ago
I'm fine with not being able to support 100 messages.
Amgelo
Amgelo2w ago
you can use the bulkDelete method then
d.js docs
d.js docs2w ago
:method: TextChannel#bulkDelete() @14.16.3 Bulk deletes given messages that are newer than two weeks.
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
// Bulk delete messages
channel.bulkDelete(5)
.then(messages => console.log(`Bulk deleted ${messages.size} messages`))
.catch(console.error);
Amgelo
Amgelo2w ago
that bot only seems to fetch first to support filtering though bulkDelete will fetch first if you only specify a number anyways use whichever fits your needs
Hachiko ✨ Rook
Hachiko ✨ RookOP2w ago
this is perfect, thank you!
Want results from more Discord servers?
Add your server