Skip to content

Enhance 'purge' command with additional options#77

Open
dotpmm wants to merge 9 commits intodevfrom
beta-pmm
Open

Enhance 'purge' command with additional options#77
dotpmm wants to merge 9 commits intodevfrom
beta-pmm

Conversation

@dotpmm
Copy link
Contributor

@dotpmm dotpmm commented Nov 22, 2025

Updated the 'purge' command to allow deletion by amount, date, or message link.

📌 Description

Updated the purge command to support additional deletion methods based on moderator needs.
This PR implements three mutually exclusive purge options:

  • Amount – delete the last N messages
  • Message Link – delete all messages newer than a specific message
  • Date – delete all messages from a given date (DD-MM-YYYY) forward

This enhancement resolves: #65

🧱 Type of Change

  • 🐛 Bug fix – Non-breaking fix for a functional/logic error
  • ✨ New feature – Adds functionality without breaking existing commands or APIs
  • ⚠️ Breaking change – Backward-incompatible change (commands, bot behavior, etc.)
  • 📝 Documentation update – README, comments, help text, etc.
  • 🧪 Test suite change – Adds/updates unit, integration, or manual tests
  • ⚙️ CI/CD pipeline update – GitHub Actions, Docker, Git hooks, etc.
  • 🧹 Refactor – Code cleanup, improvements, or style changes
  • 🐢 Performance improvement – Faster command responses or reduced resource use
  • 🕵️ Logging/debugging – Improved diagnostics, logs, or debug output
  • 🔧 Tooling – Scripts, benchmarks, or local dev improvements
  • 🔒 Security fix – Permissions, validation, or Discord API-related vulnerabilities
  • 🧰 Dependency update – Library or package updates

🧪 How Has This Been Tested?

  • Unit Tests (tests/unit/)
  • Integration Tests (tests/integration/)
  • Manual testing in Discord
  • CI

Test Environment:

  • OS: (e.g., Linux)
  • Python: (e.g., 3.12)
  • Discord.py version: (e.g., 2.6.3)
  • Docker build tested

✅ Checklist

  • My code follows repo CONTRIBUTING.md guidelines
  • Self-review completed
  • Added/updated comments and docstrings
  • Updated relevant docs (README, help text, etc.)
  • No new warnings or errors introduced
  • Added/updated tests
  • All tests pass locally
  • Ran linting and formatting
  • Docker image builds and runs
  • Changes are backwards compatible (if applicable)
  • Feature flags or .env vars updated (if applicable)
  • Tested in multiple environments (if applicable)

🛠️ Affected Bot Areas

  • Commands (e.g., /ping, /help)
  • Event handling (on_message, on_ready, etc.)
  • Permissions/roles
  • Database/Storage
  • Discord API/Integrations
  • Bot startup/shutdown
  • CI / Git hooks
  • Dockerfile / build
  • Dependencies (pyproject.toml)
  • Tooling/scripts
  • Other (specify in Additional Notes)

📸 Screenshots / Demos (if applicable)


🧠 Additional Notes

Updated the 'purge' command to allow deletion by amount, date, or message link.
@dotpmm dotpmm requested a review from a team as a code owner November 22, 2025 03:42
@sach-12
Copy link
Member

sach-12 commented Nov 22, 2025

@dotpmm install githooks. Check step 3 here

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances the purge command to support three mutually exclusive deletion methods: by amount (1-100 messages), by message link (all messages after a specific message), or by date (all messages after DD-MM-YYYY format). This provides moderators with more flexible message management options.

Key Changes:

  • Modified the purge command to accept optional parameters for amount, message_link, and date
  • Added validation to ensure exactly one parameter is provided
  • Implemented separate logic branches for each deletion method with appropriate error handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dotpmm
Copy link
Contributor Author

dotpmm commented Nov 22, 2025

@sach-12 Done?

@sach-12
Copy link
Member

sach-12 commented Nov 23, 2025

Why are there modifications in the .githooks files?


if amount < 1 or amount > 100:
await interaction.followup.send(content="Please specify a number between 1 and 100", ephemeral=True)
if sum(x is not None for x in [amount, message_link, date]) != 1:
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to use any here instead of sum?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used sum because we need to make sure exactly one of the three parameters is provided. any would only tell us if at least one is provided, which still allows two or three arguments at the same time(it just allows, we can find a workaround to select only one out of it, but then it defeats the purpose) . Using sum(x is not None …) lets us count how many were given and enforce the requirement cleanly.

@dotpmm
Copy link
Contributor Author

dotpmm commented Nov 29, 2025

Why are there modifications in the .githooks files?

I really don't understand how that happened. I never modified them manually...nevertheless, I have reverted the changes!

Implemented the /ban slash command with proper permission checks,
DM notifications, logging to mod channel, and error handling.
This reverts commit df897e1.
This was not meant to be in this PR
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.

Better purge

2 participants