Skip to content

Feature - Optimise purge functionality#47

Merged
SyniRon merged 2 commits into7Cav:developfrom
JensGryspeert:feature/implement-warden-commands-foxhole
Jan 19, 2026
Merged

Feature - Optimise purge functionality#47
SyniRon merged 2 commits into7Cav:developfrom
JensGryspeert:feature/implement-warden-commands-foxhole

Conversation

@JensGryspeert
Copy link

No description provided.

Copy link
Contributor

@SyniRon SyniRon left a comment

Choose a reason for hiding this comment

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

Review looks good generally, but let's make a few safety modifications:

  • Create First, Delete Last: Let's move the new role creation to happen before we delete the old role. Currently, if creation fails, we've already deleted the old role and lost its configuration permanently. We should only delete the old role once the new one is successfully established.

  • Migrate Permissions Safely: Along with the "create first" change, let's copy all channel overwrites to the new role before deleting the old one. This ensures data integrity if the copy process errors out halfway through.

  • Remove Role Reordering: Please remove the restoreRolePositionBestEffort logic. It requires submitting the entire server role list to the API, which risks scrambling the hierarchy if the cache is stale. It is safer to let the new role spawn at the bottom.

  • Rate Limiting: In the reapplyRoleOverwrites loop, please add a small sleep (e.g., time.Sleep(200 * time.Millisecond)) between iterations. Without this, we risk hitting rate limits by dumping 50+ permission write requests to the Discord API instantly.

Because of this sleep, it would be a good idea to wrap the purge logic in a goroutine so we don't block the main bot thread/heartbeat. We can defer the ephemeral response and have the goroutine reply to it when completed. Not strictly necessary, though.

@JensGryspeert JensGryspeert requested a review from SyniRon January 19, 2026 09:35
Copy link
Contributor

@SyniRon SyniRon left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@SyniRon SyniRon merged commit 887646a into 7Cav:develop Jan 19, 2026
2 checks passed
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.

2 participants