Skip to content

Commit

Permalink
v0.1.2: Hotfix
Browse files Browse the repository at this point in the history
Fixed an error when the bot couldn't find webhook entry
  • Loading branch information
cymon4380 committed May 18, 2024
1 parent 81af520 commit 9f2fe94
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<p align="center">
<a href="https://discord.gg/EmpnUU5EE7"><img src="https://img.shields.io/discord/1136258983565480067?style=flat-square&color=5865f2&logo=discord&logoColor=ffffff&label=discord" alt="Discord server invite" /></a>
<img src="https://img.shields.io/badge/version-0.1.1-252525?style=flat-square" alt="Version" />
<img src="https://img.shields.io/badge/version-0.1.2-252525?style=flat-square" alt="Version" />
<a href="https://t.me/ErisProtect">
<img src="https://img.shields.io/badge/Telegram (RU)-2CA5E0?style=flat-square&logo=telegram" alt="Telegram channel invite" />
</a>
Expand All @@ -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

Expand All @@ -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.**
13 changes: 9 additions & 4 deletions src/plugins/antinuke/cogs/listeners/antinuke.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/utils/plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -87,4 +87,4 @@ def get_plugins(bot: commands.AutoShardedInteractionBot) -> list[Plugin]:
except KeyError:
pass

return plugins
return plugins

0 comments on commit 9f2fe94

Please sign in to comment.