sg-antinuke Reusable SassGuard's Anti‑Nuke cog you can plug into any discord.py bot to detect and mitigate server nukes (malicious mass actions) with optional Redis-backed caching.
Install
- Local dev:
pip install -e . - From PyPI (after publish):
pip install sg-antinuke - Optional Redis support:
pip install sg-antinuke[redis]and setREDIS_URL. - Requires Python 3.10+
Quick Start
- Load as extension:
bot.load_extension('sg_antinuke')
- Or add programmatically:
from sg_antinuke import AntiNuke async def setup_hook(): await bot.add_cog(AntiNuke(bot)) bot.setup_hook = setup_hook
Minimal Bot Example
import os
import discord
from discord.ext import commands
intents = discord.Intents.default()
intents.guilds = True
intents.members = True
intents.bans = True
intents.message_content = False
bot = commands.Bot(command_prefix='!', intents=intents)
@bot.event
async def on_ready():
print(f"Logged in as {bot.user}")
async def setup_hook():
bot.load_extension('sg_antinuke') # or await bot.add_cog(AntiNuke(bot))
bot.setup_hook = setup_hook
bot.run(os.environ['DISCORD_TOKEN'])
Configuration & Storage
- By default, the cog stores data under
./sg_antinuke_data/with subfolders:config/per‑guild config files like<guild_id>_config.jsonbackups/periodic guild structure backupscache/transient caches
- Override base directory via env var:
SG_ANTINUKE_DIR=/absolute/or/relative/path
Optional Redis Caching
- Install extra:
pip install sg-antinuke[redis] - Set environment variable:
REDIS_URL=redis://localhost:6379/0 - If available, Redis is used for:
- Guild config caching
- Recent messages cache per channel
- Tracking flagged/malicious users
- If
REDIS_URLis not set or redis is not installed, features gracefully degrade to in‑process storage.
Environment Variables
SG_ANTINUKE_DIR: Base folder for configs/backups/cache (default:./sg_antinuke_data)REDIS_URL: Optional Redis connection (e.g.,redis://localhost:6379/0)
Bot Permissions & Intents
- Intents: enable
guilds,members,bans(and any others your bot requires). - Permissions: to mitigate attacks, the bot typically needs Manage Channels/Roles, Kick/Ban Members, and Manage Webhooks where appropriate.
Commands (high‑level)
- The cog exposes an
antinukecommand group with subcommands to enable/disable, configure thresholds, and manage whitelists. Typical flows:antinuke enable/antinuke disableantinuke whitelist add @user/antinuke whitelist remove @user/antinuke whitelist listantinuke settings(view current config)antinuke thresholds(view/edit detection thresholds)- Log channel and quarantine role setters (if supported by your command prefix and permissions)
Logging
- Uses logger name
sg_antinukewith aNullHandlerby default (won’t create files automatically). - To capture logs, configure logging in your bot:
import logging logger = logging.getLogger('sg_antinuke') logger.setLevel(logging.INFO) handler = logging.StreamHandler() formatter = logging.Formatter('%(asctime)s %(levelname)s %(name)s: %(message)s') handler.setFormatter(formatter) logger.addHandler(handler)
Notes
- No hardcoded App ID; the cog uses the running bot’s user ID when present.
- Data paths and Redis are fully optional and configurable via env vars.
Metadata
Release files for sg-antinuke 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
Total release size: 92.0 MB
Release files / sg_antinuke-0.1.0-cp313-cp313-win_amd64.whl
| Download URL | sg_antinuke-0.1.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8dd53e1b7f8daeff544178dd5efd361b8b5832ac215f0c12494272e75532e01b
|
|
BLAKE2b-256 checksum How to use checksums |
ac3464af3334e8761b51ba44ab98f5f0621b85c7de2d9aa93ad81792543b002d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 8.7 MB |
| Tags | CPython 3.13 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
b5a2a4d787f05e42eddc3ef4d6237ace574d41fc2cdfb695f9f80ae791b223e3
|
|
BLAKE2b-256 checksum How to use checksums |
83a15b599807cc1080cde05d42336f2956516ec3789e4341728b1020aa5dadb7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 8.8 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
3d90185b29324813acc5086ff56acf67cd9713cc2aa6835c17758b634f45e5ea
|
|
BLAKE2b-256 checksum How to use checksums |
b5bf7dcdd5a56c7fa7401d810cab7a39af1d070fbc1da77b32b67a53b452779c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | sg_antinuke-0.1.0-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
502a3a87f09d18e0318b2c9fe40d79a9f4dd433163f8f3bfe7e1eb92dc3444dc
|
|
BLAKE2b-256 checksum How to use checksums |
be9140ee59308f8dc9bf429f3cc33447b2978eeeb1f3d0c58b1afe2d988da798
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.13 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
7824b11bc6e3129e80857329a2f47724eedcb80eab277612397c7584b7212a99
|
|
BLAKE2b-256 checksum How to use checksums |
d0f1a09c39e3803f12aa6e08ca34db3676d58dff6577350b578236a81b271683
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp312-cp312-win_amd64.whl
| Download URL | sg_antinuke-0.1.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b64c75dce6777ada7a7b4cc8061dc2ac91e020cae6bf59b1510b12117615b28d
|
|
BLAKE2b-256 checksum How to use checksums |
1c6a62608aa4d3508e1d56d118fd2c147b35a04b4a76ca85d5b1b58d0e5dbc01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 8.8 MB |
| Tags | CPython 3.12 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
b87f80f7f3193516a2b2f9e1c7617ec8347e51478677a77a2d61586917301c2c
|
|
BLAKE2b-256 checksum How to use checksums |
1161a04d7672f9b5f5af53d2a958e6dca3c37a151f91610013ff9e1a31f1bd57
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 8.9 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
b84580e51b18b48eb64fd301cd895ff75b7a579d5efa431bb2c15174614c73cb
|
|
BLAKE2b-256 checksum How to use checksums |
34bfa0703a3000010735132e6884c8723dc56d9547ec2f14533fda80ad613a92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | sg_antinuke-0.1.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
4f149735f50835b88d24553cfc1891103f4b5e9961742323972216912d27f4b7
|
|
BLAKE2b-256 checksum How to use checksums |
28fc9c6cc8c134bb5463e20dcf098635d575c1ddbc354f97e3d02d882b6d73a8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 macOS 10.13+ x86-64 |
|
SHA-256 checksum How to use checksums |
d70b525e0dce75b705fe480305a9ebea01a7641fb635279e838381ee2290f720
|
|
BLAKE2b-256 checksum How to use checksums |
367450e921a892bcd8d1977546c98d23d86d2acc362fc281a7c2422653eff598
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp311-cp311-win_amd64.whl
| Download URL | sg_antinuke-0.1.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
25a768f0d61263dae4bdbc1993c78b4e0b461ebbb197afd18cb014a2de707c61
|
|
BLAKE2b-256 checksum How to use checksums |
413d14794634e829f567a7e8513abde9f7bb4e9a09af2174a91aaf26f70592ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 8.3 MB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
1e8a09f26420593d9cf1703e95c247605083247ea5dbfab86cf252a95f35fecf
|
|
BLAKE2b-256 checksum How to use checksums |
049680511cd00ccff78413993bc7f0924117b4851090ad7db9099790f71066ae
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 8.3 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
72d4361a4c3c147b098812cae015578b517aefad896b130906cb0c3720f280b9
|
|
BLAKE2b-256 checksum How to use checksums |
6da45ebde46092cc440641557a4d528c3eda858d7efa5ace7285cdbe8d3e8961
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | sg_antinuke-0.1.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
50e567263be1ce54a66e26e8f51bb199e4f4376f54a792961e66cbf9babcbb6b
|
|
BLAKE2b-256 checksum How to use checksums |
d5c5d2cdda3ced29809dba20589b53f1f0b001b06964f677e5b9bc34c395a68e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.11 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
1dd1a445db3e2cd682ae6381c64054059530a0cadd81a08e9d68639b9b9fbc31
|
|
BLAKE2b-256 checksum How to use checksums |
89352fae511a5e2273f2bacec99a4cd1d2124976a528bf441191d6609b4ebd47
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp310-cp310-win_amd64.whl
| Download URL | sg_antinuke-0.1.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
a27f7dfe6bac41ba0b280ed4312a569ecfe3e76d6b51ae00a60559f5ccdb5728
|
|
BLAKE2b-256 checksum How to use checksums |
0426fe558ed565626e1de79d5b320ed42e780f576a11b3a1e6d37aa64fea2c34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 7.9 MB |
| Tags | CPython 3.10 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
371eeab3a1c9923fa1fe7616f512382a5ad362da44e368ceedfb420b95975ae8
|
|
BLAKE2b-256 checksum How to use checksums |
ea3d7d47c2ff2bc145e76756d85f7daad4b5e5965139577e7dcaa75b79634514
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 7.8 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
ca739d4cbf66da3c7b8ae8f183d2f448bf297afc92271863ef6d6e7c5e764449
|
|
BLAKE2b-256 checksum How to use checksums |
5587c2a58f29d65eef34b81286fdc5e5544212afbbb3386199fa942cdb446bf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | sg_antinuke-0.1.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d837b33a42deb71026fe889e7fa1ed3a4cbfaf1789cde853c834fff5e2725d20
|
|
BLAKE2b-256 checksum How to use checksums |
c93da1c64fc2619c5920bc2124fc94543893e44e31e6ab71d906f7502130e454
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / sg_antinuke-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
| Download URL | sg_antinuke-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl |
|---|---|
| Size | 2.2 MB |
| Tags | CPython 3.10 macOS 10.9+ x86-64 |
|
SHA-256 checksum How to use checksums |
8e7df8c2ba66cb661cca26a624c850e663333052e34933d329a835638ae06156
|
|
BLAKE2b-256 checksum How to use checksums |
c532db7b49a66c9bee76c5ed14e1939699e8b437b3d40db52b8599cffe03f7d5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for sg-antinuke 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.