Skip to main content

Reusable Anti-Nuke Discord cog from SassGuard

Project description

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 set REDIS_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.json
    • backups/ periodic guild structure backups
    • cache/ 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_URL is 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 antinuke command group with subcommands to enable/disable, configure thresholds, and manage whitelists. Typical flows:
    • antinuke enable / antinuke disable
    • antinuke whitelist add @user / antinuke whitelist remove @user / antinuke whitelist list
    • antinuke 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_antinuke with a NullHandler by 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

sg_antinuke-0.1.0-cp313-cp313-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.13Windows x86-64

sg_antinuke-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl (8.7 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

sg_antinuke-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

sg_antinuke-0.1.0-cp313-cp313-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

sg_antinuke-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

sg_antinuke-0.1.0-cp312-cp312-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.12Windows x86-64

sg_antinuke-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

sg_antinuke-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

sg_antinuke-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

sg_antinuke-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

sg_antinuke-0.1.0-cp311-cp311-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.11Windows x86-64

sg_antinuke-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl (8.3 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

sg_antinuke-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (8.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

sg_antinuke-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (2.0 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

sg_antinuke-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

sg_antinuke-0.1.0-cp310-cp310-win_amd64.whl (1.9 MB view details)

Uploaded CPython 3.10Windows x86-64

sg_antinuke-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl (7.9 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

sg_antinuke-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (7.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

sg_antinuke-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (2.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

sg_antinuke-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file sg_antinuke-0.1.0-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8dd53e1b7f8daeff544178dd5efd361b8b5832ac215f0c12494272e75532e01b
MD5 64f9a191e82be770c40e495105de5029
BLAKE2b-256 ac3464af3334e8761b51ba44ab98f5f0621b85c7de2d9aa93ad81792543b002d

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b5a2a4d787f05e42eddc3ef4d6237ace574d41fc2cdfb695f9f80ae791b223e3
MD5 5db7e6e8259c918b287e589133931310
BLAKE2b-256 83a15b599807cc1080cde05d42336f2956516ec3789e4341728b1020aa5dadb7

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d90185b29324813acc5086ff56acf67cd9713cc2aa6835c17758b634f45e5ea
MD5 ff4c2c55d0922a28dd96f5282f0bb6c9
BLAKE2b-256 b5bf7dcdd5a56c7fa7401d810cab7a39af1d070fbc1da77b32b67a53b452779c

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 502a3a87f09d18e0318b2c9fe40d79a9f4dd433163f8f3bfe7e1eb92dc3444dc
MD5 a3ba237b021d540f1a4f5457440d2601
BLAKE2b-256 be9140ee59308f8dc9bf429f3cc33447b2978eeeb1f3d0c58b1afe2d988da798

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 7824b11bc6e3129e80857329a2f47724eedcb80eab277612397c7584b7212a99
MD5 cf7a6507f5344b45adad04a22a5b0901
BLAKE2b-256 d0f1a09c39e3803f12aa6e08ca34db3676d58dff6577350b578236a81b271683

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b64c75dce6777ada7a7b4cc8061dc2ac91e020cae6bf59b1510b12117615b28d
MD5 05a91bec1b12e38e148bb4a22c5dff86
BLAKE2b-256 1c6a62608aa4d3508e1d56d118fd2c147b35a04b4a76ca85d5b1b58d0e5dbc01

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b87f80f7f3193516a2b2f9e1c7617ec8347e51478677a77a2d61586917301c2c
MD5 8eec0690f009767e99b136673725c9f2
BLAKE2b-256 1161a04d7672f9b5f5af53d2a958e6dca3c37a151f91610013ff9e1a31f1bd57

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b84580e51b18b48eb64fd301cd895ff75b7a579d5efa431bb2c15174614c73cb
MD5 47bdf150460bdc48251b608e79e776dd
BLAKE2b-256 34bfa0703a3000010735132e6884c8723dc56d9547ec2f14533fda80ad613a92

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4f149735f50835b88d24553cfc1891103f4b5e9961742323972216912d27f4b7
MD5 fd93a869dc6a2e0f64e954b4adb77330
BLAKE2b-256 28fc9c6cc8c134bb5463e20dcf098635d575c1ddbc354f97e3d02d882b6d73a8

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d70b525e0dce75b705fe480305a9ebea01a7641fb635279e838381ee2290f720
MD5 f6c625d4fc4575d7578fc48ff3904f53
BLAKE2b-256 367450e921a892bcd8d1977546c98d23d86d2acc362fc281a7c2422653eff598

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 25a768f0d61263dae4bdbc1993c78b4e0b461ebbb197afd18cb014a2de707c61
MD5 bf5d9740cb4fc369b4f9aab22d2b1d21
BLAKE2b-256 413d14794634e829f567a7e8513abde9f7bb4e9a09af2174a91aaf26f70592ec

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1e8a09f26420593d9cf1703e95c247605083247ea5dbfab86cf252a95f35fecf
MD5 c2167cf58be723884bb1549f6b5c8786
BLAKE2b-256 049680511cd00ccff78413993bc7f0924117b4851090ad7db9099790f71066ae

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 72d4361a4c3c147b098812cae015578b517aefad896b130906cb0c3720f280b9
MD5 85a2b7b87c4b9104a6c67d89da7d1ac0
BLAKE2b-256 6da45ebde46092cc440641557a4d528c3eda858d7efa5ace7285cdbe8d3e8961

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 50e567263be1ce54a66e26e8f51bb199e4f4376f54a792961e66cbf9babcbb6b
MD5 69011ea95483e8c39aaec87f276fd1f3
BLAKE2b-256 d5c5d2cdda3ced29809dba20589b53f1f0b001b06964f677e5b9bc34c395a68e

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1dd1a445db3e2cd682ae6381c64054059530a0cadd81a08e9d68639b9b9fbc31
MD5 11291e30f661149f9566a25ac95caf26
BLAKE2b-256 89352fae511a5e2273f2bacec99a4cd1d2124976a528bf441191d6609b4ebd47

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a27f7dfe6bac41ba0b280ed4312a569ecfe3e76d6b51ae00a60559f5ccdb5728
MD5 d8f1051ae4c9142c03044b4488898a34
BLAKE2b-256 0426fe558ed565626e1de79d5b320ed42e780f576a11b3a1e6d37aa64fea2c34

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 371eeab3a1c9923fa1fe7616f512382a5ad362da44e368ceedfb420b95975ae8
MD5 42135469c2d4dc9beeb6b7e9c0a87a11
BLAKE2b-256 ea3d7d47c2ff2bc145e76756d85f7daad4b5e5965139577e7dcaa75b79634514

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ca739d4cbf66da3c7b8ae8f183d2f448bf297afc92271863ef6d6e7c5e764449
MD5 55dd6cf2fdb243d482efe600a2efdf5b
BLAKE2b-256 5587c2a58f29d65eef34b81286fdc5e5544212afbbb3386199fa942cdb446bf2

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d837b33a42deb71026fe889e7fa1ed3a4cbfaf1789cde853c834fff5e2725d20
MD5 d6391e1c375846f95b41c4f14b93e2df
BLAKE2b-256 c93da1c64fc2619c5920bc2124fc94543893e44e31e6ab71d906f7502130e454

See more details on using hashes here.

File details

Details for the file sg_antinuke-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for sg_antinuke-0.1.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8e7df8c2ba66cb661cca26a624c850e663333052e34933d329a835638ae06156
MD5 a3da9e4b93a5c27d7c735049f54460c1
BLAKE2b-256 c532db7b49a66c9bee76c5ed14e1939699e8b437b3d40db52b8599cffe03f7d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page