Skip to content

feat: create command to purge a given channel#1484

Open
surajkumar wants to merge 7 commits into
developfrom
purge-command
Open

feat: create command to purge a given channel#1484
surajkumar wants to merge 7 commits into
developfrom
purge-command

Conversation

@surajkumar
Copy link
Copy Markdown
Contributor

@surajkumar surajkumar commented May 22, 2026

Pull-request

Changes

  • Existing code
  • New feature

Closes Issue: #912

Description

This PR introduces a new slash command for moderators called /purge.
The command takes 2 required params:

  1. channel: so the bot knows which channel to purge
  2. message-id: The message to start the purge from

A third optional amount to limit how many messages are deleted. When absent all messages after the given message-id are deleted.

Why?

There have been cases were we've needed to purge a channel but haven't had the tools to automatically do this. Instead, mods and admins manually delete messages which is painful.

Example of when this would have been useful: "the @everyone ping".


See comments for more context.

@surajkumar surajkumar marked this pull request as ready for review May 22, 2026 18:41
@surajkumar surajkumar requested a review from a team as a code owner May 22, 2026 18:41
Copy link
Copy Markdown
Member

@Zabuzard Zabuzard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo needs some sort of confirmation dialog including the amount of messages that will get deleted.
otherwise all it takes is someone making a mistake and the entire channel history is gone.

a better and safer ux might be something like "purge all messages from the last x hours/minutes" or alternatively a safety check that the message to purge from isnt older than two days.

the real command we need, i think, is purging messages from a single user in all channels (like what /ban does). but difficult to do discord api wise.

@ankitsmt211
Copy link
Copy Markdown
Member

#912 not around channels but perhaps relevant for the PR or discussion, seems like there's a graveyard of PRs and issues around this

a better and safer ux might be something like "purge all messages from the last x hours/minutes" or alternatively a safety check that the message to purge from isnt older than two days.

agreed around UX feels better

* confirmation
* in progress
* completion
* audit log
@surajkumar
Copy link
Copy Markdown
Contributor Author

No worries, I'm currently tackling this and I'll do it piece by piece.

First is the confirmation:
image

Then the completion:
image

and the audit log (#mod-audit-log):
image

@surajkumar
Copy link
Copy Markdown
Contributor Author

next is time based:

image image

@surajkumar
Copy link
Copy Markdown
Contributor Author

Usage now:

  • /purge channel:#foo minutes:30 purge last 30 minutes
  • /purge channel:#foo message-id:123… purge after a specific message
  • /purge channel:#foo minutes:30 amount:50 purge last 30 minutes, capped at 50

@surajkumar
Copy link
Copy Markdown
Contributor Author

Added another command: /purge-messages-by-user

Takes 2 params:

  • user: the user
  • minutes: time range capped to 6 hours
  • amount: optional global amount of messages to delete

Confirmation:
image

image

Audit log:
image

@sonarqubecloud
Copy link
Copy Markdown

@surajkumar surajkumar enabled auto-merge (squash) May 22, 2026 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants