From 9f2fe944bdb23e043af7d8c0580e8c1c975eeaa5 Mon Sep 17 00:00:00 2001 From: cymon4380 Date: Sat, 18 May 2024 18:54:42 +0700 Subject: [PATCH] v0.1.2: Hotfix Fixed an error when the bot couldn't find webhook entry --- README.md | 7 ++++--- src/plugins/antinuke/cogs/listeners/antinuke.py | 13 +++++++++---- src/utils/plugin_manager.py | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b776e9d..bcf8fc4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

Discord server invite - Version + Version Telegram channel invite @@ -12,14 +12,13 @@ **ErisProtect** is an open source Discord bot designed to help with protection servers from damage. You can contribute and help us improve it. ## What can ErisProtect do? -**Here are the features that will be added to the bot before version 1.0.** +**Here are the features that will likely be added to the bot before version 1.0.** - `0.1` Anti-nuke - `0.2` Anti-webhook-spam - `0.5` User verification (CAPTCHA, Anti-VPN) - `0.5` Anti-alternative-accounts - `0.3` Server backups -- `0.6` Auto moderation of voice messages - `0.4` Quarantine - `0.2` Improved punishment system @@ -29,6 +28,8 @@ ErisProtect requires **Python 3.10** and **MongoDB 6.0** to run. Install all libraries from `requirements.txt` and specify `DISCORD_TOKEN` and `MONGO_AUTH_STRING` in environment variables. Then edit the `config.json` file and run the bot using `main.py`. Your bot must have the **Server Members** and **Message Content** privileged gateway intents. +**Please run the bot from the `src` directory. Otherwise, you will get an error!** + --- **Keep in mind that no one bot can fully protect your server. They can only help you with protection. You shouldn't add unknown bots to your server and grant dangerous permissions to unknown members.** \ No newline at end of file diff --git a/src/plugins/antinuke/cogs/listeners/antinuke.py b/src/plugins/antinuke/cogs/listeners/antinuke.py index 839389b..5ad59d5 100644 --- a/src/plugins/antinuke/cogs/listeners/antinuke.py +++ b/src/plugins/antinuke/cogs/listeners/antinuke.py @@ -148,21 +148,26 @@ async def on_guild_role_update(self, before: disnake.Role, after: disnake.Role): async def on_webhooks_update(self, channel: disnake.abc.GuildChannel): guild = channel.guild entry = None - async for audit_entry in guild.audit_logs(limit=1): - entry = audit_entry + async for audit_entry in guild.audit_logs(limit=10): + if audit_entry.action in [ + disnake.AuditLogAction.webhook_create, + disnake.AuditLogAction.webhook_update, + disnake.AuditLogAction.webhook_delete + ]: + entry = audit_entry + break if entry is None: return user = entry.user - permission = None match entry.action: case disnake.AuditLogAction.webhook_create: permission = AntiNukePermission.CreateWebhooks case disnake.AuditLogAction.webhook_update: permission = AntiNukePermission.EditWebhooks - case disnake.AuditLogAction.webhook_delete: + case _: permission = AntiNukePermission.DeleteWebhooks if AntiNukePermissions.from_database(user.id, guild).has_permissions(permission): diff --git a/src/utils/plugin_manager.py b/src/utils/plugin_manager.py index ad387ec..e76a819 100644 --- a/src/utils/plugin_manager.py +++ b/src/utils/plugin_manager.py @@ -77,7 +77,7 @@ def load_plugins(bot: commands.AutoShardedInteractionBot): def get_plugins(bot: commands.AutoShardedInteractionBot) -> list[Plugin]: plugins = [] - for address, dirs, files in walk(path.join(getcwd(), 'plugins')): + for _, dirs, _ in walk(path.join(getcwd(), 'plugins')): for directory in dirs: try: plugin = Plugin(bot, directory) @@ -87,4 +87,4 @@ def get_plugins(bot: commands.AutoShardedInteractionBot) -> list[Plugin]: except KeyError: pass - return plugins + return plugins