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
- 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 OPthe only tutorial you should be following is the official guide
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 Intentsintents 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
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•2mo ago
Message Not Public
Sign In & Join Server To View
well the guide won't tell you everything, but you should use it as the starting point
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•2mo ago
Message Not Public
Sign In & Join Server To View
that sounds like a reasonable limitation, why can't I just tell the bot to abide by that?
Unknown User•2mo ago
Message Not Public
Sign In & Join Server To View
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.
that bot can't delete more than 100 messages
at a time? in total? with a cooldown?
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
I'm fine with not being able to support 100 messages.
you can use the bulkDelete method then
:method: TextChannel#bulkDelete()
@14.16.3
Bulk deletes given messages that are newer than two weeks.
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
this is perfect, thank you!