dc-securex 2.29.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dc_securex-2.29.7.dist-info/METADATA +1028 -0
- dc_securex-2.29.7.dist-info/RECORD +28 -0
- dc_securex-2.29.7.dist-info/WHEEL +5 -0
- dc_securex-2.29.7.dist-info/licenses/LICENSE +21 -0
- dc_securex-2.29.7.dist-info/top_level.txt +2 -0
- securex/__init__.py +18 -0
- securex/backup/__init__.py +5 -0
- securex/backup/manager.py +792 -0
- securex/client.py +329 -0
- securex/handlers/__init__.py +8 -0
- securex/handlers/channel.py +97 -0
- securex/handlers/member.py +110 -0
- securex/handlers/role.py +74 -0
- securex/models.py +156 -0
- securex/utils/__init__.py +5 -0
- securex/utils/punishment.py +124 -0
- securex/utils/whitelist.py +129 -0
- securex/workers/__init__.py +8 -0
- securex/workers/action_worker.py +115 -0
- securex/workers/cleanup_worker.py +94 -0
- securex/workers/guild_worker.py +186 -0
- securex/workers/log_worker.py +88 -0
- tests/__init__.py +9 -0
- tests/test_coverage_client.py +210 -0
- tests/test_coverage_handlers.py +341 -0
- tests/test_coverage_manager.py +504 -0
- tests/test_coverage_utils.py +177 -0
- tests/test_coverage_workers.py +297 -0
|
@@ -0,0 +1,1028 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dc-securex
|
|
3
|
+
Version: 2.29.7
|
|
4
|
+
Summary: Backend-only Discord anti-nuke protection SDK
|
|
5
|
+
Home-page: https://github.com/yourusername/securex-antinuke-sdk
|
|
6
|
+
Author: SecureX Team
|
|
7
|
+
Author-email: SecureX Team <contact@securex.dev>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/yourusername/securex-antinuke-sdk
|
|
10
|
+
Project-URL: Repository, https://github.com/yourusername/securex-antinuke-sdk
|
|
11
|
+
Project-URL: Issues, https://github.com/yourusername/securex-antinuke-sdk/issues
|
|
12
|
+
Keywords: discord,bot,antinuke,security,protection,sdk
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Requires-Python: >=3.8
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
License-File: LICENSE
|
|
22
|
+
Requires-Dist: discord.py>=2.0.0
|
|
23
|
+
Requires-Dist: aiofiles>=23.0.0
|
|
24
|
+
Dynamic: author
|
|
25
|
+
Dynamic: home-page
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
Dynamic: requires-python
|
|
28
|
+
|
|
29
|
+
# 🛡️ SecureX SDK - Discord Server Protection Made Easy
|
|
30
|
+
|
|
31
|
+
**Protect your Discord server from attacks in just 5 lines of code!**
|
|
32
|
+
|
|
33
|
+
[](https://pypi.org/project/dc-securex/)
|
|
34
|
+
[](https://www.python.org/downloads/)
|
|
35
|
+
|
|
36
|
+
## 🤔 What is this?
|
|
37
|
+
|
|
38
|
+
SecureX is a **Python library** that protects your Discord server from people who try to destroy it.
|
|
39
|
+
|
|
40
|
+
Imagine someone gets admin powers and starts:
|
|
41
|
+
- 🗑️ Deleting all channels
|
|
42
|
+
- 👥 Kicking everyone
|
|
43
|
+
- 🚫 Banning members
|
|
44
|
+
- 🤖 Adding spam bots
|
|
45
|
+
|
|
46
|
+
**SecureX stops them in milliseconds** (0.005 seconds!) and fixes everything automatically!
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## ✨ What can it do?
|
|
51
|
+
|
|
52
|
+
✅ **Instant Protection** - Stops attacks in 5-10 milliseconds
|
|
53
|
+
✅ **Auto Restore** - Brings back deleted channels and roles
|
|
54
|
+
✅ **Smart Punishment** - Bans/kicks bad users automatically
|
|
55
|
+
✅ **Easy Setup** - Just 5 lines of code!
|
|
56
|
+
✅ **Your Design** - You build the commands & UI, we handle security
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## 📋 Requirements
|
|
61
|
+
|
|
62
|
+
### Python & Dependencies
|
|
63
|
+
|
|
64
|
+
**Required:**
|
|
65
|
+
- ✅ Python 3.8 or higher
|
|
66
|
+
- ✅ discord.py 2.0.0 or higher (auto-installed)
|
|
67
|
+
- ✅ aiofiles 23.0.0 or higher (auto-installed)
|
|
68
|
+
|
|
69
|
+
**Installation:**
|
|
70
|
+
```bash
|
|
71
|
+
pip install dc-securex
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This automatically installs all required dependencies!
|
|
75
|
+
|
|
76
|
+
### Discord Bot Permissions
|
|
77
|
+
|
|
78
|
+
**REQUIRED Permissions** (Bot won't work without these):
|
|
79
|
+
|
|
80
|
+
| Permission | Why Needed | Priority |
|
|
81
|
+
|------------|-----------|----------|
|
|
82
|
+
| `View Audit Log` | See who did what (CRITICAL!) | 🔴 MUST HAVE |
|
|
83
|
+
| `Manage Channels` | Restore deleted channels | 🔴 MUST HAVE |
|
|
84
|
+
| `Manage Roles` | Restore deleted roles | 🔴 MUST HAVE |
|
|
85
|
+
| `Ban Members` | Ban attackers | 🟡 For bans |
|
|
86
|
+
| `Kick Members` | Kick attackers | 🟡 For kicks |
|
|
87
|
+
| `Moderate Members` | Timeout attackers | 🟡 For timeouts |
|
|
88
|
+
| `Manage Webhooks` | Delete spam webhooks | 🟢 Optional |
|
|
89
|
+
|
|
90
|
+
**Easy Invite Link:**
|
|
91
|
+
```
|
|
92
|
+
https://discord.com/api/oauth2/authorize?client_id=YOUR_BOT_ID&permissions=8&scope=bot
|
|
93
|
+
```
|
|
94
|
+
Using `permissions=8` gives Administrator (easiest for testing).
|
|
95
|
+
|
|
96
|
+
### Discord Bot Intents
|
|
97
|
+
|
|
98
|
+
**REQUIRED Intents** (Enable in Developer Portal AND code):
|
|
99
|
+
|
|
100
|
+
**In Discord Developer Portal:**
|
|
101
|
+
1. Go to your app → Bot → Privileged Gateway Intents
|
|
102
|
+
2. Enable:
|
|
103
|
+
- ✅ SERVER MEMBERS INTENT
|
|
104
|
+
- ✅ MESSAGE CONTENT INTENT (if using commands)
|
|
105
|
+
|
|
106
|
+
**In Your Code:**
|
|
107
|
+
```python
|
|
108
|
+
import discord
|
|
109
|
+
intents = discord.Intents.all()
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Or specific intents:
|
|
113
|
+
```python
|
|
114
|
+
intents = discord.Intents.default()
|
|
115
|
+
intents.guilds = True
|
|
116
|
+
intents.members = True
|
|
117
|
+
intents.bans = True
|
|
118
|
+
intents.webhooks = True
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Bot Role Position
|
|
122
|
+
|
|
123
|
+
⚠️ **IMPORTANT:** Your bot's role must be **higher** than roles it manages!
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
✅ CORRECT:
|
|
127
|
+
1. Owner
|
|
128
|
+
2. SecureBot ← Bot here
|
|
129
|
+
3. Admin
|
|
130
|
+
4. Moderator
|
|
131
|
+
|
|
132
|
+
❌ WRONG:
|
|
133
|
+
1. Owner
|
|
134
|
+
2. Admin
|
|
135
|
+
3. SecureBot ← Bot too low!
|
|
136
|
+
4. Moderator
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### System Requirements
|
|
140
|
+
|
|
141
|
+
- **OS:** Windows, Linux, macOS (any OS with Python 3.8+)
|
|
142
|
+
- **RAM:** 512MB minimum (1GB recommended)
|
|
143
|
+
- **Disk:** 100MB for SDK + backups
|
|
144
|
+
- **Network:** Stable internet connection
|
|
145
|
+
- **Discord:** Bot must have access to audit logs
|
|
146
|
+
|
|
147
|
+
### Optional (Recommended)
|
|
148
|
+
|
|
149
|
+
- **Git** - For version control
|
|
150
|
+
- **Virtual Environment** - Keep dependencies isolated
|
|
151
|
+
```bash
|
|
152
|
+
python -m venv venv
|
|
153
|
+
source venv/bin/activate
|
|
154
|
+
pip install dc-securex
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
## 📋 Before You Start
|
|
161
|
+
|
|
162
|
+
### Step 1: Create a Discord Bot
|
|
163
|
+
|
|
164
|
+
1. Go to [Discord Developer Portal](https://discord.com/developers/applications)
|
|
165
|
+
2. Click **"New Application"**
|
|
166
|
+
3. Give it a name (like "SecureBot")
|
|
167
|
+
4. Go to **"Bot"** tab → Click **"Add Bot"**
|
|
168
|
+
5. **Important**: Enable these switches:
|
|
169
|
+
- ✅ SERVER MEMBERS INTENT
|
|
170
|
+
- ✅ MESSAGE CONTENT INTENT
|
|
171
|
+
6. Click **"Reset Token"** → Copy your bot token (you'll need this!)
|
|
172
|
+
|
|
173
|
+
### Step 2: Invite Bot to Your Server
|
|
174
|
+
|
|
175
|
+
Use this link (replace `YOUR_BOT_ID` with your bot's ID from Developer Portal):
|
|
176
|
+
```
|
|
177
|
+
https://discord.com/api/oauth2/authorize?client_id=YOUR_BOT_ID&permissions=8&scope=bot
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
**Permission value `8` = Administrator** (easiest for beginners)
|
|
181
|
+
|
|
182
|
+
### Step 3: Install Python & Libraries
|
|
183
|
+
|
|
184
|
+
**Check if Python is installed:**
|
|
185
|
+
```bash
|
|
186
|
+
python --version
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Requirements:**
|
|
190
|
+
- ✅ Python 3.8 or newer (Python 3.10+ recommended)
|
|
191
|
+
- ✅ pip (comes with Python)
|
|
192
|
+
|
|
193
|
+
**If you don't have Python:**
|
|
194
|
+
- Download from [python.org](https://python.org)
|
|
195
|
+
- During installation, check "Add Python to PATH"
|
|
196
|
+
|
|
197
|
+
**Install SecureX SDK:**
|
|
198
|
+
```bash
|
|
199
|
+
pip install dc-securex
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**What gets installed automatically:**
|
|
203
|
+
- `discord.py >= 2.0.0` - Discord API wrapper
|
|
204
|
+
- `aiofiles >= 23.0.0` - Async file operations
|
|
205
|
+
|
|
206
|
+
**Optional: Use Virtual Environment (Recommended)**
|
|
207
|
+
```bash
|
|
208
|
+
python -m venv venv
|
|
209
|
+
source venv/bin/activate
|
|
210
|
+
pip install dc-securex
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
**Verify installation:**
|
|
214
|
+
```bash
|
|
215
|
+
pip show dc-securex
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
You should see version 2.15.3 or higher!
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
## 🚀 Quick Setup (5 Steps!)
|
|
223
|
+
|
|
224
|
+
### Step 1: Install SecureX
|
|
225
|
+
|
|
226
|
+
Open your terminal/command prompt and type:
|
|
227
|
+
```bash
|
|
228
|
+
pip install dc-securex
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Step 2: Create Your Bot File
|
|
232
|
+
|
|
233
|
+
Create a file called `bot.py` and copy this code:
|
|
234
|
+
|
|
235
|
+
```python
|
|
236
|
+
import discord
|
|
237
|
+
from discord.ext import commands
|
|
238
|
+
from securex import SecureX
|
|
239
|
+
|
|
240
|
+
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
|
241
|
+
sx = SecureX(bot)
|
|
242
|
+
|
|
243
|
+
@bot.event
|
|
244
|
+
async def on_ready():
|
|
245
|
+
await sx.enable(
|
|
246
|
+
punishments={
|
|
247
|
+
"channel_delete": "ban",
|
|
248
|
+
"role_delete": "ban",
|
|
249
|
+
"member_ban": "ban",
|
|
250
|
+
"member_kick": "ban"
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
print(f"✅ {bot.user.name} is online and protected!")
|
|
254
|
+
|
|
255
|
+
bot.run("YOUR_BOT_TOKEN_HERE")
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Step 3: Add Your Bot Token
|
|
259
|
+
|
|
260
|
+
Replace `"YOUR_BOT_TOKEN_HERE"` with the token you copied from Discord Developer Portal.
|
|
261
|
+
|
|
262
|
+
**⚠️ KEEP YOUR TOKEN SECRET!** Never share it or post it online!
|
|
263
|
+
|
|
264
|
+
### Step 4: Run Your Bot
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
python bot.py
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
You should see: `✅ YourBotName is online and protected!`
|
|
271
|
+
|
|
272
|
+
### Step 5: Test It!
|
|
273
|
+
|
|
274
|
+
Your server is now protected! If someone tries to delete a channel or kick members without permission, SecureX will:
|
|
275
|
+
1. **Ban them instantly** (in 0.005 seconds!)
|
|
276
|
+
2. **Restore what they deleted** (channels, roles, etc.)
|
|
277
|
+
3. **Log the attack** (so you know what happened)
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## 🎯 Understanding the Code
|
|
282
|
+
|
|
283
|
+
Let's break down what each part does:
|
|
284
|
+
|
|
285
|
+
```python
|
|
286
|
+
from securex import SecureX
|
|
287
|
+
```
|
|
288
|
+
This imports the SecureX library.
|
|
289
|
+
|
|
290
|
+
```python
|
|
291
|
+
sx = SecureX(bot)
|
|
292
|
+
```
|
|
293
|
+
This connects SecureX to your bot.
|
|
294
|
+
|
|
295
|
+
```python
|
|
296
|
+
await sx.enable(punishments={...})
|
|
297
|
+
```
|
|
298
|
+
This turns on protection and sets punishments:
|
|
299
|
+
- `"ban"` = Ban the attacker
|
|
300
|
+
- `"kick"` = Kick them out
|
|
301
|
+
- `"timeout"` = Mute them for 10 minutes
|
|
302
|
+
- `"none"` = Just restore, don't punish
|
|
303
|
+
|
|
304
|
+
---
|
|
305
|
+
|
|
306
|
+
## 🔧 What Can You Protect?
|
|
307
|
+
|
|
308
|
+
Here are ALL the things you can protect:
|
|
309
|
+
|
|
310
|
+
| Type | What it stops | Available Punishments |
|
|
311
|
+
|------|--------------|----------------------|
|
|
312
|
+
| `channel_delete` | Deleting channels | `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"` |
|
|
313
|
+
| `channel_create` | Creating too many channels (spam) | `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"` |
|
|
314
|
+
| `role_delete` | Deleting roles | `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"` |
|
|
315
|
+
| `role_create` | Creating too many roles (spam) | `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"` |
|
|
316
|
+
| `member_kick` | Kicking members | `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"` |
|
|
317
|
+
| `member_ban` | Banning members | `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"` |
|
|
318
|
+
| `member_unban` | Unbanning people | `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"` |
|
|
319
|
+
| `webhook_create` | Creating spam webhooks | `"none"`, `"warn"`, `"timeout"`, `"kick"`, `"ban"` |
|
|
320
|
+
| `bot_add` | Adding bad bots | Always `"ban"` (automatic) |
|
|
321
|
+
|
|
322
|
+
**Punishment Options Explained:**
|
|
323
|
+
- `"none"` - Only restore, don't punish
|
|
324
|
+
- `"warn"` - Send warning message
|
|
325
|
+
- `"timeout"` - Mute for 10 minutes (configurable)
|
|
326
|
+
- `"kick"` - Kick from server
|
|
327
|
+
- `"ban"` - Ban from server
|
|
328
|
+
|
|
329
|
+
---
|
|
330
|
+
|
|
331
|
+
## 🎨 Simple Examples
|
|
332
|
+
|
|
333
|
+
### Example 1: Strict Mode (Ban Everything)
|
|
334
|
+
|
|
335
|
+
```python
|
|
336
|
+
await sx.enable(
|
|
337
|
+
punishments={
|
|
338
|
+
"channel_delete": "ban",
|
|
339
|
+
"channel_create": "ban",
|
|
340
|
+
"role_delete": "ban",
|
|
341
|
+
"role_create": "ban",
|
|
342
|
+
"member_kick": "ban",
|
|
343
|
+
"member_ban": "ban"
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
### Example 2: Gentle Mode (Warn Only)
|
|
349
|
+
|
|
350
|
+
```python
|
|
351
|
+
await sx.enable(
|
|
352
|
+
punishments={
|
|
353
|
+
"channel_delete": "timeout",
|
|
354
|
+
"role_delete": "timeout",
|
|
355
|
+
"member_kick": "warn"
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Example 3: Protection Without Punishment
|
|
361
|
+
|
|
362
|
+
```python
|
|
363
|
+
await sx.enable()
|
|
364
|
+
```
|
|
365
|
+
This only restores deleted stuff but doesn't punish anyone.
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## 👥 Whitelist (Allow Trusted Users)
|
|
370
|
+
|
|
371
|
+
Want to allow some people to delete channels? Add them to the whitelist:
|
|
372
|
+
|
|
373
|
+
```python
|
|
374
|
+
await sx.whitelist.add(guild_id, user_id)
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
**Example:**
|
|
378
|
+
```python
|
|
379
|
+
@bot.command()
|
|
380
|
+
@commands.is_owner()
|
|
381
|
+
async def trust(ctx, member: discord.Member):
|
|
382
|
+
await sx.whitelist.add(ctx.guild.id, member.id)
|
|
383
|
+
await ctx.send(f"✅ {member.name} is now trusted!")
|
|
384
|
+
|
|
385
|
+
@bot.command()
|
|
386
|
+
@commands.is_owner()
|
|
387
|
+
async def untrust(ctx, member: discord.Member):
|
|
388
|
+
await sx.whitelist.remove(ctx.guild.id, member.id)
|
|
389
|
+
await ctx.send(f"❌ {member.name} is no longer trusted!")
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## 🔔 Get Notified When Attacks Happen
|
|
395
|
+
|
|
396
|
+
Add this to your code to get alerts:
|
|
397
|
+
|
|
398
|
+
```python
|
|
399
|
+
@sx.on_threat_detected
|
|
400
|
+
async def alert(threat):
|
|
401
|
+
print(f"🚨 ATTACK DETECTED!")
|
|
402
|
+
print(f" Type: {threat.type}")
|
|
403
|
+
print(f" Attacker: {threat.actor_id}")
|
|
404
|
+
print(f" Punishment: {threat.punishment_action}")
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**Fancier Alert (Discord Embed):**
|
|
408
|
+
|
|
409
|
+
```python
|
|
410
|
+
@sx.on_threat_detected
|
|
411
|
+
async def fancy_alert(threat):
|
|
412
|
+
channel = bot.get_channel(YOUR_LOG_CHANNEL_ID)
|
|
413
|
+
|
|
414
|
+
embed = discord.Embed(
|
|
415
|
+
title="🚨 Security Alert!",
|
|
416
|
+
description=f"Someone tried to {threat.type}!",
|
|
417
|
+
color=discord.Color.red()
|
|
418
|
+
)
|
|
419
|
+
embed.add_field(name="Attacker", value=f"<@{threat.actor_id}>")
|
|
420
|
+
embed.add_field(name="What Happened", value=threat.target_name)
|
|
421
|
+
embed.add_field(name="Punishment", value=threat.punishment_action.upper())
|
|
422
|
+
|
|
423
|
+
await channel.send(embed=embed)
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## 📝 Full Working Example
|
|
429
|
+
|
|
430
|
+
Here's a complete bot with commands:
|
|
431
|
+
|
|
432
|
+
```python
|
|
433
|
+
import discord
|
|
434
|
+
from discord.ext import commands
|
|
435
|
+
from securex import SecureX
|
|
436
|
+
|
|
437
|
+
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
|
438
|
+
sx = SecureX(bot)
|
|
439
|
+
|
|
440
|
+
@bot.event
|
|
441
|
+
async def on_ready():
|
|
442
|
+
await sx.enable(punishments={"channel_delete": "ban", "member_ban": "ban"})
|
|
443
|
+
print(f"✅ {bot.user.name} is protecting {len(bot.guilds)} servers!")
|
|
444
|
+
|
|
445
|
+
@sx.on_threat_detected
|
|
446
|
+
async def log_attack(threat):
|
|
447
|
+
print(f"🚨 Stopped {threat.type} by user {threat.actor_id}")
|
|
448
|
+
|
|
449
|
+
@bot.command()
|
|
450
|
+
@commands.is_owner()
|
|
451
|
+
async def trust(ctx, member: discord.Member):
|
|
452
|
+
await sx.whitelist.add(ctx.guild.id, member.id)
|
|
453
|
+
await ctx.send(f"✅ {member.mention} can now manage the server!")
|
|
454
|
+
|
|
455
|
+
@bot.command()
|
|
456
|
+
@commands.is_owner()
|
|
457
|
+
async def untrust(ctx, member: discord.Member):
|
|
458
|
+
await sx.whitelist.remove(ctx.guild.id, member.id)
|
|
459
|
+
await ctx.send(f"❌ {member.mention} is no longer trusted!")
|
|
460
|
+
|
|
461
|
+
@bot.command()
|
|
462
|
+
async def ping(ctx):
|
|
463
|
+
await ctx.send(f"🏓 Pong! Protection active!")
|
|
464
|
+
|
|
465
|
+
bot.run("YOUR_BOT_TOKEN")
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
---
|
|
469
|
+
|
|
470
|
+
## ❓ Common Questions
|
|
471
|
+
|
|
472
|
+
### Q: Will this slow down my bot?
|
|
473
|
+
**A:** No! SecureX is SUPER fast (5-10 milliseconds). Your bot will work normally.
|
|
474
|
+
|
|
475
|
+
### Q: What if I accidentally delete a channel?
|
|
476
|
+
**A:** If you're the server owner, SecureX won't stop you! Or add yourself to the whitelist.
|
|
477
|
+
|
|
478
|
+
### Q: Can I change punishments later?
|
|
479
|
+
**A:** Yes! Just call `await sx.enable(punishments={...})` again with new settings.
|
|
480
|
+
|
|
481
|
+
### Q: Does it work on multiple servers?
|
|
482
|
+
**A:** Yes! It automatically protects all servers your bot is in.
|
|
483
|
+
|
|
484
|
+
### Q: What if my bot goes offline?
|
|
485
|
+
**A:** When it comes back online, it automatically creates new backups. But it can't stop attacks while offline.
|
|
486
|
+
|
|
487
|
+
### Q: How do I make my own commands?
|
|
488
|
+
**A:** Check [discord.py documentation](https://discordpy.readthedocs.io/) to learn more about making bot commands!
|
|
489
|
+
|
|
490
|
+
---
|
|
491
|
+
|
|
492
|
+
## 🔧 Troubleshooting
|
|
493
|
+
|
|
494
|
+
### ❌ "Missing Permissions" Error
|
|
495
|
+
|
|
496
|
+
**Solution:** Make sure your bot has Administrator permission, or at least these:
|
|
497
|
+
- Manage Channels
|
|
498
|
+
- Manage Roles
|
|
499
|
+
- Ban Members
|
|
500
|
+
- Kick Members
|
|
501
|
+
- View Audit Log
|
|
502
|
+
|
|
503
|
+
### ❌ Bot doesn't detect attacks
|
|
504
|
+
|
|
505
|
+
**Solution:**
|
|
506
|
+
1. Check if you enabled **SERVER MEMBERS INTENT** in Discord Developer Portal
|
|
507
|
+
2. Make sure your bot is using `intents=discord.Intents.all()`
|
|
508
|
+
3. Check if bot role is above other roles in Server Settings → Roles
|
|
509
|
+
|
|
510
|
+
### ❌ Can't restore deleted channels
|
|
511
|
+
|
|
512
|
+
**Solution:** Bot role must be **higher** than the roles it needs to manage
|
|
513
|
+
|
|
514
|
+
---
|
|
515
|
+
|
|
516
|
+
## 🏗️ Architecture (How It Works Under the Hood)
|
|
517
|
+
|
|
518
|
+
SecureX uses a **Triple-Worker Architecture** for maximum speed and reliability. Here's how it works:
|
|
519
|
+
|
|
520
|
+
### ⚡ The Triple-Worker System
|
|
521
|
+
|
|
522
|
+
Think of SecureX like a security team with 3 specialized workers:
|
|
523
|
+
|
|
524
|
+
```
|
|
525
|
+
┌─────────────────────────────────────────────────────────┐
|
|
526
|
+
│ DISCORD SERVER │
|
|
527
|
+
│ (Someone deletes a channel, kicks a member, etc.) │
|
|
528
|
+
└────────────────┬────────────────────────────────────────┘
|
|
529
|
+
│
|
|
530
|
+
▼
|
|
531
|
+
┌────────────────────────────────────────────────────────┐
|
|
532
|
+
│ DISCORD AUDIT LOG EVENT (Instant!) │
|
|
533
|
+
│ Discord creates a log entry: "User X deleted #general"│
|
|
534
|
+
└────────────────┬───────────────────────────────────────┘
|
|
535
|
+
│
|
|
536
|
+
▼ (5-10 milliseconds)
|
|
537
|
+
┌────────────────────────────────────────────────────────┐
|
|
538
|
+
│ SECUREX EVENT LISTENER │
|
|
539
|
+
│ (Catches the audit log instantly) │
|
|
540
|
+
└─────┬──────────┬─────────────┬────────────────────────┘
|
|
541
|
+
│ │ │
|
|
542
|
+
▼ ▼ ▼
|
|
543
|
+
┌─────┐ ┌─────┐ ┌─────┐
|
|
544
|
+
│ Q1 │ │ Q2 │ │ Q3 │ (3 Queues)
|
|
545
|
+
└──┬──┘ └──┬──┘ └──┬──┘
|
|
546
|
+
│ │ │
|
|
547
|
+
▼ ▼ ▼
|
|
548
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
549
|
+
│Worker 1 │ │Worker 2 │ │Worker 3 │
|
|
550
|
+
│ Action │ │ Cleanup │ │ Log │
|
|
551
|
+
└─────────┘ └─────────┘ └─────────┘
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
### 🔨 Worker 1: Action Worker (PUNISHER)
|
|
555
|
+
**Job:** Ban/kick bad users INSTANTLY
|
|
556
|
+
|
|
557
|
+
**What it does:**
|
|
558
|
+
1. Checks if user is whitelisted
|
|
559
|
+
2. If NOT whitelisted → BAN them immediately
|
|
560
|
+
3. Takes only 5-10 milliseconds!
|
|
561
|
+
|
|
562
|
+
**Example:**
|
|
563
|
+
```
|
|
564
|
+
User "Hacker123" deletes #general
|
|
565
|
+
↓ (5ms later)
|
|
566
|
+
Action Worker: "Hacker123 is NOT whitelisted"
|
|
567
|
+
↓
|
|
568
|
+
*BANS Hacker123 instantly*
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### 🧹 Worker 2: Cleanup Worker (CLEANER)
|
|
572
|
+
**Job:** Delete spam creations (channels, roles, webhooks)
|
|
573
|
+
|
|
574
|
+
**What it does:**
|
|
575
|
+
1. If someone creates 50 spam channels
|
|
576
|
+
2. Deletes them all INSTANTLY
|
|
577
|
+
3. Prevents server from getting cluttered
|
|
578
|
+
|
|
579
|
+
**Example:**
|
|
580
|
+
```
|
|
581
|
+
User creates spam channel "#spam1"
|
|
582
|
+
↓ (10ms later)
|
|
583
|
+
Cleanup Worker: "Unauthorized channel!"
|
|
584
|
+
↓
|
|
585
|
+
*Deletes #spam1 immediately*
|
|
586
|
+
```
|
|
587
|
+
|
|
588
|
+
### � Worker 3: Log Worker (REPORTER)
|
|
589
|
+
**Job:** Alert you about attacks
|
|
590
|
+
|
|
591
|
+
**What it does:**
|
|
592
|
+
1. Fires your callbacks
|
|
593
|
+
2. Sends you alerts
|
|
594
|
+
3. Logs everything for review
|
|
595
|
+
|
|
596
|
+
**Example:**
|
|
597
|
+
```
|
|
598
|
+
Attack detected!
|
|
599
|
+
↓
|
|
600
|
+
Log Worker: Calls your @sx.on_threat_detected
|
|
601
|
+
↓
|
|
602
|
+
You get an alert embed in Discord!
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
---
|
|
606
|
+
|
|
607
|
+
### 🔄 Restoration System (Separate from Workers)
|
|
608
|
+
|
|
609
|
+
**Job:** Restore deleted stuff from backups
|
|
610
|
+
|
|
611
|
+
**How it works:**
|
|
612
|
+
```
|
|
613
|
+
Channel deleted
|
|
614
|
+
↓ (500ms wait for audit log)
|
|
615
|
+
↓
|
|
616
|
+
Restoration Handler checks: "Was this authorized?"
|
|
617
|
+
↓ NO
|
|
618
|
+
↓
|
|
619
|
+
Looks in backup: "Found #general backup!"
|
|
620
|
+
↓
|
|
621
|
+
*Recreates channel with same permissions*
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
**Automatic Backups:**
|
|
625
|
+
- Creates backup every 10 minutes
|
|
626
|
+
- Saves: Channels, roles, permissions, positions
|
|
627
|
+
- Stored in `./data/backups/` folder
|
|
628
|
+
|
|
629
|
+
---
|
|
630
|
+
|
|
631
|
+
### 🏰 Worker 4: Guild Worker (GUILD SETTINGS PROTECTOR)
|
|
632
|
+
|
|
633
|
+
**NEW in v2.15+!** The Guild Worker protects and restores critical guild settings.
|
|
634
|
+
|
|
635
|
+
**Job:** Restore guild name, icon, banner, vanity URL when changed unauthorized
|
|
636
|
+
|
|
637
|
+
**What it does:**
|
|
638
|
+
1. Monitors `guild_update` audit log events
|
|
639
|
+
2. Detects changes to server name, icon, banner, description, vanity URL
|
|
640
|
+
3. Restores from backup if unauthorized user made changes
|
|
641
|
+
4. Uses user tokens for vanity URL restoration (Discord API limitation)
|
|
642
|
+
|
|
643
|
+
**Protected Settings:**
|
|
644
|
+
- ✅ Server Name
|
|
645
|
+
- ✅ Server Icon
|
|
646
|
+
- ✅ Server Banner
|
|
647
|
+
- ✅ Server Description
|
|
648
|
+
- ✅ **Vanity URL** (requires user token)
|
|
649
|
+
|
|
650
|
+
**Example:**
|
|
651
|
+
```
|
|
652
|
+
Unauthorized user changes server name to "HACKED SERVER"
|
|
653
|
+
↓ (50ms wait for audit log)
|
|
654
|
+
↓
|
|
655
|
+
Guild Worker checks: "Was this authorized?"
|
|
656
|
+
↓ NO
|
|
657
|
+
↓
|
|
658
|
+
Looks in backup: "Found original name: Cool Community"
|
|
659
|
+
↓
|
|
660
|
+
*Restores server name to "Cool Community"*
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
---
|
|
664
|
+
|
|
665
|
+
### 🔑 Setting Up Guild Worker (With Vanity URL Support)
|
|
666
|
+
|
|
667
|
+
**Important:** Vanity URL restoration requires a **user token** due to Discord API limitations. Bot tokens cannot modify vanity URLs.
|
|
668
|
+
|
|
669
|
+
#### Step 1: Get Your User Token (One-Time Setup)
|
|
670
|
+
|
|
671
|
+
**⚠️ WARNING:** Your user token is VERY sensitive! Never share it publicly!
|
|
672
|
+
|
|
673
|
+
**How to get it:**
|
|
674
|
+
1. Open Discord in your browser (not the app!)
|
|
675
|
+
2. Press `F12` to open Developer Tools
|
|
676
|
+
3. Go to **Console** tab
|
|
677
|
+
4. Type: `window.webpackChunkdiscord_app.push([[''],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]);m.find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken()`
|
|
678
|
+
5. Copy the long string that appears (your token)
|
|
679
|
+
|
|
680
|
+
**Alternative Method (Network Tab):**
|
|
681
|
+
1. Open Discord in browser → `F12` → Network tab
|
|
682
|
+
2. Filter by "api"
|
|
683
|
+
3. Click any request to `discord.com/api/`
|
|
684
|
+
4. Look in Headers → Request Headers → `authorization`
|
|
685
|
+
5. Copy the token value
|
|
686
|
+
|
|
687
|
+
#### Step 2: Set The User Token in Your Bot
|
|
688
|
+
|
|
689
|
+
```python
|
|
690
|
+
@bot.event
|
|
691
|
+
async def on_ready():
|
|
692
|
+
await sx.enable(punishments={...})
|
|
693
|
+
|
|
694
|
+
# Set user token for vanity URL restoration
|
|
695
|
+
guild_id = 1234567890 # Your server ID
|
|
696
|
+
user_token = "YOUR_USER_TOKEN_HERE" # From step 1
|
|
697
|
+
|
|
698
|
+
await sx.guild_worker.set_user_token(guild_id, user_token)
|
|
699
|
+
print("✅ Guild settings protection enabled with vanity URL support!")
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
#### Step 3: Test It!
|
|
703
|
+
|
|
704
|
+
Try changing your server's vanity URL - SecureX will restore it automatically!
|
|
705
|
+
|
|
706
|
+
**Full Example:**
|
|
707
|
+
```python
|
|
708
|
+
import discord
|
|
709
|
+
from discord.ext import commands
|
|
710
|
+
from securex import SecureX
|
|
711
|
+
|
|
712
|
+
bot = commands.Bot(command_prefix="!", intents=discord.Intents.all())
|
|
713
|
+
sx = SecureX(bot)
|
|
714
|
+
|
|
715
|
+
@bot.event
|
|
716
|
+
async def on_ready():
|
|
717
|
+
# Enable punishments
|
|
718
|
+
await sx.enable(punishments={"channel_delete": "ban"})
|
|
719
|
+
|
|
720
|
+
# Set user token for each guild
|
|
721
|
+
for guild in bot.guilds:
|
|
722
|
+
token = get_user_token_for_guild(guild.id) # Your token storage
|
|
723
|
+
await sx.guild_worker.set_user_token(guild.id, token)
|
|
724
|
+
|
|
725
|
+
print(f"✅ {bot.user.name} protecting {len(bot.guilds)} servers!")
|
|
726
|
+
|
|
727
|
+
bot.run("YOUR_BOT_TOKEN")
|
|
728
|
+
```
|
|
729
|
+
|
|
730
|
+
---
|
|
731
|
+
|
|
732
|
+
### 🎯 Guild Worker API
|
|
733
|
+
|
|
734
|
+
**Set User Token:**
|
|
735
|
+
```python
|
|
736
|
+
await sx.guild_worker.set_user_token(guild_id, "user_token_here")
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
**Get User Token:**
|
|
740
|
+
```python
|
|
741
|
+
token = sx.guild_worker.get_user_token(guild_id)
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
**Remove User Token:**
|
|
745
|
+
```python
|
|
746
|
+
await sx.guild_worker.remove_user_token(guild_id)
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
**Check If Token Is Set:**
|
|
750
|
+
```python
|
|
751
|
+
if sx.guild_worker.get_user_token(guild_id):
|
|
752
|
+
print("Token is configured!")
|
|
753
|
+
else:
|
|
754
|
+
print("No token set - vanity restoration won't work!")
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
---
|
|
758
|
+
|
|
759
|
+
### 💾 User Token Storage
|
|
760
|
+
|
|
761
|
+
User tokens are **automatically saved** to `./data/backups/user_tokens.json` for persistence.
|
|
762
|
+
|
|
763
|
+
**Token Data Model:**
|
|
764
|
+
```python
|
|
765
|
+
from securex.models import UserToken
|
|
766
|
+
|
|
767
|
+
# Create token metadata
|
|
768
|
+
token_data = UserToken(
|
|
769
|
+
guild_id=123456789,
|
|
770
|
+
token="user_token_here",
|
|
771
|
+
set_by=999888777, # Admin who set it
|
|
772
|
+
description="Production server token"
|
|
773
|
+
)
|
|
774
|
+
|
|
775
|
+
# Track usage
|
|
776
|
+
token_data.mark_used() # Updates last_used timestamp
|
|
777
|
+
|
|
778
|
+
# Serialize
|
|
779
|
+
token_dict = token_data.to_dict()
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
**Storage Format (user_tokens.json):**
|
|
783
|
+
```json
|
|
784
|
+
{
|
|
785
|
+
"1234567890": "user_token_abc...",
|
|
786
|
+
"9876543210": "user_token_xyz..."
|
|
787
|
+
}
|
|
788
|
+
```
|
|
789
|
+
|
|
790
|
+
---
|
|
791
|
+
|
|
792
|
+
### ⚠️ Important Notes About User Tokens
|
|
793
|
+
|
|
794
|
+
**Security:**
|
|
795
|
+
- ✅ Tokens are stored locally in `./data/backups/`
|
|
796
|
+
- ✅ Never commit `user_tokens.json` to Git!
|
|
797
|
+
- ✅ Add to `.gitignore`: `data/backups/user_tokens.json`
|
|
798
|
+
- ⚠️ User tokens are more powerful than bot tokens - keep them secure!
|
|
799
|
+
|
|
800
|
+
**Limitations:**
|
|
801
|
+
- User tokens can **only** restore vanity URLs
|
|
802
|
+
- Other guild settings (name, icon, banner) use bot permissions
|
|
803
|
+
- User must be a server owner or have Manage Guild permission
|
|
804
|
+
- User token must be from someone with vanity URL access
|
|
805
|
+
|
|
806
|
+
**What Happens Without User Token:**
|
|
807
|
+
```
|
|
808
|
+
Unauthorized user changes vanity URL
|
|
809
|
+
↓
|
|
810
|
+
Guild Worker tries to restore
|
|
811
|
+
↓
|
|
812
|
+
⚠️ No user token set!
|
|
813
|
+
↓
|
|
814
|
+
Prints: "No user token set for guild 123! Cannot restore vanity."
|
|
815
|
+
↓
|
|
816
|
+
Other settings (name, icon) still restored via bot!
|
|
817
|
+
```
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
### 🔄 Complete Guild Protection Flow
|
|
822
|
+
|
|
823
|
+
**Timeline of Guild Name Change:**
|
|
824
|
+
```
|
|
825
|
+
0ms - Unauthorized user changes server name
|
|
826
|
+
50ms - Discord audit log updated
|
|
827
|
+
75ms - Guild Worker detects change
|
|
828
|
+
80ms - Checks whitelist (user not whitelisted)
|
|
829
|
+
85ms - Loads backup (finds original name)
|
|
830
|
+
100ms - Calls guild.edit(name="Original Name")
|
|
831
|
+
300ms - Server name restored!
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
**Multi-Setting Attack:**
|
|
835
|
+
```
|
|
836
|
+
User changes: name + icon + banner + vanity
|
|
837
|
+
↓
|
|
838
|
+
Guild Worker restores ALL in one go:
|
|
839
|
+
- Name: Restored via bot
|
|
840
|
+
- Icon: Restored via bot
|
|
841
|
+
- Banner: Restored via bot
|
|
842
|
+
- Vanity: Restored via user token (API)
|
|
843
|
+
↓
|
|
844
|
+
Total time: ~500ms for all 4 settings!
|
|
845
|
+
```
|
|
846
|
+
|
|
847
|
+
---
|
|
848
|
+
|
|
849
|
+
### 📊 Guild Worker vs Other Workers
|
|
850
|
+
|
|
851
|
+
| Worker | Speed | What It Protects | Token Needed
|
|
852
|
+
|--------|-------|------------------|-------------|
|
|
853
|
+
| Action Worker | 5-10ms | Punishes attackers | Bot token ✅ |
|
|
854
|
+
| Cleanup Worker | 10-20ms | Deletes spam | Bot token ✅ |
|
|
855
|
+
| Log Worker | 15ms | Sends alerts | Bot token ✅ |
|
|
856
|
+
| Guild Worker | 50-500ms | Server settings | Bot + User token ⚠️ |
|
|
857
|
+
|
|
858
|
+
**Why Guild Worker is slower:**
|
|
859
|
+
- Waits for audit log (50ms)
|
|
860
|
+
- Loads backup from disk
|
|
861
|
+
- Makes API calls to restore
|
|
862
|
+
- Vanity URL uses external API endpoint
|
|
863
|
+
|
|
864
|
+
**But still VERY fast compared to manual restoration!**
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
---
|
|
869
|
+
|
|
870
|
+
### 🎯 Why Triple Workers?
|
|
871
|
+
|
|
872
|
+
**Speed:**
|
|
873
|
+
- Workers don't wait for each other
|
|
874
|
+
- All process in parallel
|
|
875
|
+
- Punishment happens in 5-10ms!
|
|
876
|
+
|
|
877
|
+
**Reliability:**
|
|
878
|
+
- If one worker crashes, others keep working
|
|
879
|
+
- Each worker has its own queue
|
|
880
|
+
- No single point of failure
|
|
881
|
+
|
|
882
|
+
**Separation:**
|
|
883
|
+
- Punishment (fast) ≠ Restoration (slower but thorough)
|
|
884
|
+
- Action Worker = instant ban
|
|
885
|
+
- Restoration Handler = careful rebuild
|
|
886
|
+
|
|
887
|
+
---
|
|
888
|
+
|
|
889
|
+
### 📊 Data Flow Example
|
|
890
|
+
|
|
891
|
+
Let's say "BadUser" deletes 5 channels:
|
|
892
|
+
|
|
893
|
+
**Timeline:**
|
|
894
|
+
```
|
|
895
|
+
0ms - BadUser deletes #general
|
|
896
|
+
5ms - SecureX detects it (audit log)
|
|
897
|
+
7ms - Broadcasts to 3 workers
|
|
898
|
+
10ms - Action Worker BANS BadUser
|
|
899
|
+
12ms - Cleanup Worker ready (no cleanup needed)
|
|
900
|
+
15ms - Log Worker alerts you
|
|
901
|
+
500ms - Restoration Handler starts
|
|
902
|
+
750ms - #general recreated with permissions
|
|
903
|
+
```
|
|
904
|
+
|
|
905
|
+
**Result:**
|
|
906
|
+
- ✅ BadUser banned in 10ms
|
|
907
|
+
- ✅ You alerted in 15ms
|
|
908
|
+
- ✅ #general restored in 750ms
|
|
909
|
+
- ✅ Total response: Less than 1 second!
|
|
910
|
+
|
|
911
|
+
---
|
|
912
|
+
|
|
913
|
+
### 🧠 Smart Permission Detection
|
|
914
|
+
|
|
915
|
+
When someone updates a member's roles:
|
|
916
|
+
|
|
917
|
+
```
|
|
918
|
+
User "Sneaky" gives Admin role to "Friend"
|
|
919
|
+
↓
|
|
920
|
+
Member Update Handler triggered
|
|
921
|
+
↓
|
|
922
|
+
Checks: "Is Sneaky whitelisted?"
|
|
923
|
+
↓ NO
|
|
924
|
+
↓
|
|
925
|
+
Scans ALL roles of "Friend"
|
|
926
|
+
↓
|
|
927
|
+
Finds roles with dangerous permissions:
|
|
928
|
+
- Administrator ❌
|
|
929
|
+
- Manage Roles ❌
|
|
930
|
+
- Ban Members ❌
|
|
931
|
+
↓
|
|
932
|
+
*Removes ALL dangerous roles in ONE API call*
|
|
933
|
+
↓
|
|
934
|
+
Friend is now safe!
|
|
935
|
+
```
|
|
936
|
+
|
|
937
|
+
**Dangerous Permissions Detected:**
|
|
938
|
+
- Administrator
|
|
939
|
+
- Kick Members
|
|
940
|
+
- Ban Members
|
|
941
|
+
- Manage Guild
|
|
942
|
+
- Manage Roles
|
|
943
|
+
- Manage Channels
|
|
944
|
+
- Manage Webhooks
|
|
945
|
+
- Manage Emojis
|
|
946
|
+
- Mention Everyone
|
|
947
|
+
- Manage Expressions
|
|
948
|
+
|
|
949
|
+
---
|
|
950
|
+
|
|
951
|
+
### 💾 Caching System
|
|
952
|
+
|
|
953
|
+
SecureX uses caching for maximum speed:
|
|
954
|
+
|
|
955
|
+
**Cached Data:**
|
|
956
|
+
1. **Whitelist** - Frozenset for O(1) lookup
|
|
957
|
+
2. **Dangerous Permissions** - Class-level constant
|
|
958
|
+
3. **Guild Backups** - Updated every 10 minutes
|
|
959
|
+
|
|
960
|
+
**Why This Matters:**
|
|
961
|
+
```python
|
|
962
|
+
|
|
963
|
+
|
|
964
|
+
OLD (v1.x):
|
|
965
|
+
Check whitelist → Database query (50-100ms)
|
|
966
|
+
|
|
967
|
+
NEW (v2.x):
|
|
968
|
+
Check whitelist → Memory lookup (0.001ms)
|
|
969
|
+
```
|
|
970
|
+
|
|
971
|
+
**50,000x faster!**
|
|
972
|
+
|
|
973
|
+
---
|
|
974
|
+
|
|
975
|
+
## 📊 How It Works (Simple Summary)
|
|
976
|
+
|
|
977
|
+
1. **Someone does something bad** (delete channel, ban member, etc.)
|
|
978
|
+
2. **Discord logs it** (in audit log)
|
|
979
|
+
3. **SecureX sees it instantly** (5-10 milliseconds later!)
|
|
980
|
+
4. **Checks if they're allowed** (whitelist check)
|
|
981
|
+
5. **If NOT allowed:**
|
|
982
|
+
- Bans/kicks them (punishment)
|
|
983
|
+
- Restores what they deleted (from backup)
|
|
984
|
+
- Alerts you (via callback)
|
|
985
|
+
|
|
986
|
+
All of this happens **automatically** while you sleep! 😴
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
---
|
|
990
|
+
|
|
991
|
+
## 🎓 Next Steps
|
|
992
|
+
|
|
993
|
+
1. ✅ Get bot token from Discord Developer Portal
|
|
994
|
+
2. ✅ Install: `pip install dc-securex`
|
|
995
|
+
3. ✅ Copy the example code
|
|
996
|
+
4. ✅ Add your bot token
|
|
997
|
+
5. ✅ Run: `python bot.py`
|
|
998
|
+
6. 🎉 Your server is protected!
|
|
999
|
+
|
|
1000
|
+
---
|
|
1001
|
+
|
|
1002
|
+
## 📚 Want to Learn More?
|
|
1003
|
+
|
|
1004
|
+
- [Discord.py Docs](https://discordpy.readthedocs.io/) - Learn to make Discord bots
|
|
1005
|
+
- [Python Tutorial](https://docs.python.org/3/tutorial/) - Learn Python basics
|
|
1006
|
+
- [Discord Developer Portal](https://discord.com/developers/docs) - Official Discord docs
|
|
1007
|
+
|
|
1008
|
+
---
|
|
1009
|
+
|
|
1010
|
+
## 📄 License
|
|
1011
|
+
|
|
1012
|
+
MIT License - Free to use! ❤️
|
|
1013
|
+
|
|
1014
|
+
---
|
|
1015
|
+
|
|
1016
|
+
## 🌟 Support
|
|
1017
|
+
|
|
1018
|
+
Having issues? Questions? Found a bug?
|
|
1019
|
+
- Open an issue on GitHub
|
|
1020
|
+
- Read this README carefully
|
|
1021
|
+
- Check if your bot has all permissions
|
|
1022
|
+
|
|
1023
|
+
---
|
|
1024
|
+
|
|
1025
|
+
**Made with ❤️ for Discord bot developers**
|
|
1026
|
+
**Version 2.15.5** - Lightning-fast server protection!
|
|
1027
|
+
|
|
1028
|
+
🚀 **Start protecting your server today!**
|