Delete Message from User in DM
Is it possible, to delete all Messages from the Bot and User in DMs
32 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!The bot can only delete the bots messages.
How would you approach it, to remove all messages sent from the bot in someone's direct messages? I've got no use for it right now, however, it is worth knowing for future reference!
by doing it the spammy way: fetch, iterate, delete
How do you fetch someone's dms again? Also, are we to expect the message after 14 days saying we can't delete it?
<DMChannel>#messages#fetch - as usual
<User>#createDM for the channel
And no, thats just for bulkdelete
Well. I guess I have learned two things. Didn't know that the day limit applies only to the
BulkDelete
. Thanks for explainingHi, can you please explain how we can do it?
I am new to discord.js. I have enabled all Intents to see if that's the problem. But
.dmChannel
always null for me.you need to call createDM first.
But I am sending user dms through
user.send()
and have a lot of messages from bot in dm. It means sending dms through user.send()
is wrong approac? Detailed code to send dm:
that has nothing to do with this though
the dmchannel isnt cached by default
so you have to call createDM
OK, so
createDM()
worked for. What I have learnt is that if we use user.send(_message)
directly without calling createDM()
, it will not cache/save the messages sent to user but user will receive the dms from bot. By calling createDM()
first on user then using send()
on the returned reference will cache the messages to be used in future.
Don't know why, but it looks to me that we have to call createDM()
separately.Are you referring to solution something like this: https://stackoverflow.com/a/61029038/8823023
client.users.cache.get('id').send('Blabla')
Thanks for it. Man, I am working for about 8+ years in TypeScript dealt, many libraries. But complexity of discort.js
is on another level. Many thanks for the direction though.
Yes, of course
By the way, if some small examples added to the documentation, it will be way much easier, like: https://angular.dev/api/common/DecimalPipeyou might be referring to the guide? https://discordjs.guide
discord.js Guide
Imagine a guide... that explores the many possibilities for your discord.js bot.
Nope, to the documentation it self.
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
Of course, not everything. But somethings should.
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
Like you can see, I have referred a small example from angular docs (https://angular.dev/api/common/DecimalPipe). They have added very few examples in the docs. If you go to the link and scroll to the references to the left of that page, you will find out almost many references don't have examples. But some important references have examples and helps a lot.
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
Yes, very much like that. Maybe I haven't got any from doc by luck.
I am very new to
discord.js
to point out anything. Surely, will if needed in future.
To be specific, if I see myself new to discord api and what I struggled a lot, is the intents. Intents were very confusing to be understand why they are here. Well that's not about the discord.js
but about the developer portal itself. If new person go to "Installation", "OAuth2" and "Bot" pages on the discord application page for a specific application, he can't distinguish between these 3 and will question why these 3 pages are there, not one.
For the discord.js
docs somehow I visited the only pages the examples were not there, I think those are good.
But I want to point out that the guide started good. Like we even pointed out how to add linter and how to secure tokens using .env
. But then suddenly in "creating your bot" in "command handling" we used different files for different commands and exported using module.exports. After that used node's file system to fetch files and access code within, this adds difficulty in learning the basics of slash commands (when I read those pages I thought it's something complex but after googling realized it's easier than expected).
What I think, using file system and module.exports adds complexity/difficulty in learning at that point. Though, it's important to point out that the code will become pain if not managed through multiple files correctly, this could be told to the user in later parts of the guide.The user is required to have a solid understanding of the basics of javascript before starting, this is also reflected in #rules 3. This includes working with the file system
Well, I am at ok to good level in file system and I know how they work, I pointed out to the are in guide about slash commands.
tbf even the basics of file handling are taught in the guide
but yeah it is expected that users should use the library having that knowledge already
That's totally depend on the user.
If they are programmers (as I expect mostly they are) we don't need to tell them how to manage code complexity.
If they are new people and normal users with little to no programming experience then we should tell them about how to manage the code complexity/refactoring but then module.exports, node's file system will torture these kind of new comers
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
thats what we're trying to tell you, djs isnt meant for newcomers, they should have a solid understanding of javascript
the guide is meant to guide people
its not meant to learn the basics of javascript, that is not our job
Sure, I pointed out the difficulties I found some of them as asked. We can close the topic.
Nahh... rather that simplifies my workflow massively... It lets you even customise how you want each command to be executed, for example cool downs, but still making sure everything converges to one loop. Very efficient. It's confusing for a start but once you start using it, you'd see how much better your refactoring would look like.
The honest truth is: Discord.js feels difficult at first. The official guides are organized, but they don't really teach — they mostly turn you into a code copier. But once you do a bit more digging and understand how things work, you realize it’s actually very straightforward. In fact, the circular nature of the API is soooo solid — it keeps everything interconnected in a way that makes the library powerful once you understand the flow. But for the new guides, there's alot of improvements, they now use gifs and images to illustrate what is actually happening.
Well that's true too.