bulkDelete doesn't delete messages 2 weeks old?

Is this true? Does bulkDelete not delete messages two weeks old? If this is the case, and I want to delete a batch of specific messages that are older than 2 weeks old, is the best way to fetch each message and execute a delete on them individually?
20 Replies
d.js docs
d.js docs3y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Dagan
Dagan3y ago
Yes it is true
Helix
HelixOP3y ago
so running singular deletes is probably the better solution, especially if I'm deleting specific messages with specific ids
Dagan
Dagan3y ago
And i think thats the best way of doing it if you really want to delete it Dont know if it would work tho Youll have to try it out
Matte
Matte3y ago
You shouldnt delete too many messages at once that way for just a few its fine but more than that not so much
Helix
HelixOP3y ago
what's the best way, for say I have 50 messages that need to be deleted (they're specified by ids)
Matte
Matte3y ago
if all of those are older than 2 weeks i would find some other way than to delete them
Helix
HelixOP3y ago
I'm doing something like this atm:
try {
const toBeDeleted = await BotApplicantForm.query()
.whereIn("applicant_id", ids)
.select(["channel_id", "message_id"]);

console.log("toBeDeleted", toBeDeleted);

const messages = await Promise.all(
toBeDeleted.map(async (d) => {
return client.channels.cache
.get(d.channel_id)
.messages.fetch(d.message_id);
})
);

console.log(`messages`, messages);

await Promise.all(messages.map((message) => message.delete()));
try {
const toBeDeleted = await BotApplicantForm.query()
.whereIn("applicant_id", ids)
.select(["channel_id", "message_id"]);

console.log("toBeDeleted", toBeDeleted);

const messages = await Promise.all(
toBeDeleted.map(async (d) => {
return client.channels.cache
.get(d.channel_id)
.messages.fetch(d.message_id);
})
);

console.log(`messages`, messages);

await Promise.all(messages.map((message) => message.delete()));
minus the console logs obviously lol
Matte
Matte3y ago
thats going to get ratelimited quite easily generally not a good idea iirc the ratelimits for deleting messages is 5/1s per channel
Dagan
Dagan3y ago
So you could use setInterval
Helix
HelixOP3y ago
I was thinking of that implementing some type of exponential backoff
Matte
Matte3y ago
i wouldnt recommend that. Like i said youd be better off finding an alternative to deleting too many messages older than 2 weeks
Helix
HelixOP3y ago
does updating and creating messages also have the same rate limitations?
Matte
Matte3y ago
the ratelimits for those is less
Helix
HelixOP3y ago
I only ask because there might be situations where I'm batch creating messages and/or updating
Matte
Matte3y ago
yeah you should avoid that too generally you shouldnt be doing anything in large clusters
Helix
HelixOP3y ago
basically I have it set up where an application is filled and sent to my web site, I create an entry in the db and I also create a copy to be posted onto discord ahh, okay
Matte
Matte3y ago
its fine if it happens by user input and doesnt occur too often sending up to 5 messages at once is still fine there are different ratelimits for this stuff so my approach to it is just to avoid doing anything in clusters like i said
Helix
HelixOP3y ago
I looked for the documentation on the different rate limits, but maybe I'm blind, can't seem to find it other than the global rate limit is 50 per second
Matte
Matte3y ago
its a bit of a mystery
Want results from more Discord servers?
Add your server