You can use the fetchMessages
method to retrieve a promise that consists of a collection of the the last 10 messages, by setting the limit
to 10 using the ChannelLogsQueryOptions.
Using this collection of messages, as @Chris Satchell mentioned in the comments you loop through it and check if message.attatchments
is present for all of messages. Alternatively you can check if the <Collection>.size
of the attachments
for the entire collection of messages is equivalent to 10, and if it does you can go ahead with the next step.
Now that you have a collection of messages that you would like to delete, simply pass this collection into the messages
parameter of the method bulkDelete
.
So as a result, you fetch the last 10 messages in a TextChannel, and then check the attachments
property of the fetched collection of messages and then call the bulkDelete
method on this collection.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…