mirror of
https://github.com/mollersuite/monofile.git
synced 2024-11-21 21:36:26 -08:00
fix bulk deletions in deleteMessages
This commit is contained in:
parent
cad72fafd2
commit
3bedc21d05
|
@ -58,7 +58,7 @@ export class Client {
|
||||||
|
|
||||||
// Remove bulk deletable messages
|
// Remove bulk deletable messages
|
||||||
|
|
||||||
let bulkDeletable = ids.filter(e => convertSnowflakeToDate(e).valueOf() < 2 * 7 * 24 * 60 * 60 * 1000)
|
let bulkDeletable = ids.filter(e => Date.now()-convertSnowflakeToDate(e).valueOf() < 2 * 7 * 24 * 60 * 60 * 1000)
|
||||||
await this.rest.fetch(`/channels/${this.targetChannel}/messages/bulk-delete`, {
|
await this.rest.fetch(`/channels/${this.targetChannel}/messages/bulk-delete`, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({messages: bulkDeletable})
|
body: JSON.stringify({messages: bulkDeletable})
|
||||||
|
@ -69,7 +69,7 @@ export class Client {
|
||||||
// there's probably a better way to do this @Jack5079
|
// there's probably a better way to do this @Jack5079
|
||||||
// fix for me if possible
|
// fix for me if possible
|
||||||
await Promise.all(ids.map(async e => {
|
await Promise.all(ids.map(async e => {
|
||||||
if (convertSnowflakeToDate(e).valueOf() >= 2 * 7 * 24 * 60 * 60 * 1000) {
|
if (Date.now()-convertSnowflakeToDate(e).valueOf() >= 2 * 7 * 24 * 60 * 60 * 1000) {
|
||||||
return await this.deleteMessage(e)
|
return await this.deleteMessage(e)
|
||||||
}
|
}
|
||||||
}).filter(Boolean)) // filter based on whether or not it's undefined
|
}).filter(Boolean)) // filter based on whether or not it's undefined
|
||||||
|
|
Loading…
Reference in a new issue