-
Notifications
You must be signed in to change notification settings - Fork 64
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
Re-work message clean up, re-work of the admin system and cleaning up left guilds #53
Conversation
This event (https://discordpy.readthedocs.io/en/latest/api.html#discord.on_guild_remove) is needed to detect when the bot leaves a server
Thanks a lot for this PR! I will test it later this evening but it looks good. My bad for forgetting to attach guild IDs to admin IDs. I have only a single question: would this work if the bot and/or discord api was down when the guild gets deleted? |
No it would not work as it is done right now, it could be done by fetching every guild that the bot has database entries in every now and then but that will be a lot of API calls and it would probably be wise to in that case store the guilds "to be removed" for 24 hrs then re-check to deal with any potential invalid responses from Discords API. Hope that makes any sense, I'd be able to help do that if it sounds good 👍 |
That was what I tried to achieve in the current master on lines 266-297, but it is not working as intended. The similar code for deleted messages (lines 222-256) seems to be working correctly when the message is deleted but the guild is not. My current guess is that if the guild is deleted the except and/or if functions are not triggered properly. I haven't had the time to debug it sadly. |
It would be great if we could go the 24h route so that the change is retroactive and does not assume 100% uptime. |
👍 I took a quick look at 266-297 and I think the reason it is currently not working is because: |
Thanks for spotting it so quickly. I agree with re-working the admin system as well. I hope I can get a good look at it this weekend. Thanks for taking interest in this project 😃 |
…e & interaction Please note: Other function calls will be needed when calling get_admins, remove_admin and add_admin
Glad I can help! :) |
Also added another task loop to check "unreachable" guilds every 6 hrs instead of every 24 hrs
Thanks for the quick changes! This weekend I will add the necessary updates for database migration. I think the most painless way to do this is to outright delete the old admins table, recreate it with the new column and let users re-run the command to add admins. Once I did that and tested everything I will merge and release 2.1.0 |
The reason I don’t check for the actual Administrator permission (only done for adding and removing admins) is to have other users manage the bot by giving them a certain role without giving them full control over the server. (Unless this isn’t what you meant with checking for actual admins) The code could be (or most likely it is) inefficient as I am not a developer and this is just a hobby of mine. |
Oh my bad! I ment the isadmin() function which checks if the user has the admin role, my bad for being unclear! |
Hey! I just noticed that anyone with an admin role can kill, restart or update the bot, that can be abused if its added to multiple servers and in one of them decides to mess with it they can without any problem, I suggest to add this decor to the management commands https://discordpy.readthedocs.io/en/latest/ext/commands/api.html?highlight=is_owner#discord.ext.commands.is_owner to only make those commands usable by the bot owner |
…mmands one Also removed the ability to see other guilds admin roles
I changed the way it handles discord.Forbidden as we cant mention a channel we dont fetch. (See comment on line 254)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit for
b9bc29d * Clean up admin roles that cant be migrated not guilds
I agree with the I see that you already made the code to |
I added it to more than just the 3 I mentioned before, please review and check if this is something you agree with.
I don't think there is anything more to do than to write a little changelog. No worries! 🙂 |
Thanks again for taking the time to make such a big PR! |
Fixes #52 by deleting a guilds database entries after leaving the guild / if the guild gets deleted.
In order to do this I added another database function (remove_guild) which just removes everything directly connected to the guild (message, reactionroles, systemchannels). Please note: This will NOT remove the admin role id from the database as admins table does not refer to which guild the admin role belongs to.