Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Purge configuration data of removed guilds #39

Merged
merged 3 commits into from
Jan 31, 2022
Merged

✨ Purge configuration data of removed guilds #39

merged 3 commits into from
Jan 31, 2022

Conversation

n1ckoates
Copy link
Contributor

When Needle is removed from a guild (kicked, guild deleted, etc.), it will now delete the configuration data of that guild.

On startup, Needle will compare the configs directory to its current guilds, deleting ones it's no longer in. This is done in case Needle is offline when the guildDelete event fires. As a precautionary measure, Needle will not delete configs if no guilds are present; this protects against the wrong token being used by mistake, or a theoretical Discord API error.

Both of these things are achieved through the resetConfigToDefault function, which just deletes the respective file.

@n1ckoates
Copy link
Contributor Author

If this pull request is merged & I become a contributor, I'm fine with the proposed AGPL license change.

@c43721
Copy link
Contributor

c43721 commented Jan 26, 2022

If #34 gets merged before this, you're going to have merge conflicts FYI.

Copy link
Owner

@MarcusOtter MarcusOtter left a comment

Choose a reason for hiding this comment

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

Thank you so much, it works flawlessly ✨

I moved the function to configHelpers.ts where we already have access to the CONFIGS_PATH and fs. It keeps index.ts more tidy as well. Other than that I just did some tiny nitpicks like making variable names slightly more descriptive (e.g. files => configFiles) and moved the logging of Deleted config for guild ${id} to the actual reset command.

Thank you for this! 🎉

@MarcusOtter MarcusOtter merged commit 32b90b7 into MarcusOtter:main Jan 31, 2022
@MarcusOtter MarcusOtter mentioned this pull request Feb 1, 2022
Merged
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

💡 Purge configuration data of removed guilds
3 participants