File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change 1+ import { Interaction } from "detritus-client" ;
2+ import { BaseCollection } from "detritus-client/lib/collections" ;
3+ import { Permissions } from "detritus-client/lib/constants" ;
4+ import { Message } from "detritus-client/lib/structures" ;
5+
6+ import { BaseContextMenuMessageCommand , ContextMenuMessageArgs } from ".." ;
7+
8+ class VCNotifyContextCommand extends BaseContextMenuMessageCommand {
9+ constructor ( ) {
10+ super ( {
11+ name : "Purge Below" ,
12+ permissions : [ Permissions . ADMINISTRATOR ] ,
13+ permissionsClient : [ Permissions . MANAGE_MESSAGES ] ,
14+ } ) ;
15+ }
16+
17+ async run ( ctx : Interaction . InteractionContext , args : ContextMenuMessageArgs ) {
18+ const messages : BaseCollection < string , Message > = await ctx . channel ! . fetchMessages ( {
19+ after : args . message . id ,
20+ limit : 100 ,
21+ } ) ;
22+
23+ if ( messages . length < 2 ) {
24+ return this . ephEoR ( ctx , "There were not enough messages to purge." , 2 ) ;
25+ }
26+
27+ return ctx . channel
28+ ?. bulkDelete (
29+ messages . map ( ( v , k ) => {
30+ return k ;
31+ } )
32+ )
33+ . then ( ( ) => {
34+ this . ephEoR ( ctx , `Deleted ${ messages . length } messages.` , 1 ) ;
35+ } ) ;
36+ }
37+ }
38+
39+ export default VCNotifyContextCommand ;
Original file line number Diff line number Diff line change @@ -235,7 +235,8 @@ amount: How much the hue should change.
235235 "Commands" ,
236236 `\`/help\` - You're looking at it right now!
237237\n\`/ping\` - Pong!
238- \n\`/purge (amount)\` - Deletes the specified amount of messages, between 2 and 100 messages at a time.`
238+ \n\`/purge (amount)\` - Deletes the specified amount of messages, between 2 and 100 messages at a time.
239+ \n\`Message Context Menu: Purge Below - Deletes up to 100 messages sent after the selected message (minimum 2).\``
239240 ) ;
240241
241242 this . embed . addField ( "User Left Messages" , `The bot can be set up to send a message in a specific channel when a user leaves the server.` ) ;
You can’t perform that action at this time.
0 commit comments