> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omex.pro/llms.txt
> Use this file to discover all available pages before exploring further.

# Antinuke

> Impose restrictions on moderators to prevent destructive behavior.

## Why use an antinuke system?

An antinuke system helps protect your server from destructive actions performed by moderators/staff — whether intentionally, accidentally, or through a compromised account. It limits how many high‑impact actions someone can do within a short time window and automatically responds when that limit is exceeded.

## How does **this** antinuke work?

This system is **event + audit‑log + rate‑limit** based.

1. **A server event happens** (e.g. channel created, role deleted, member banned).
2. The bot reads the **Audit Log** to determine **who** performed the action.
3. The bot checks if the actor is **bypassed** (server owner / whitelisted).
4. A **rate limiter** counts how many actions that actor performs within **10 seconds**.
5. If the actor exceeds the configured **threshold**, AntiNuke:
   * **Logs** an alert to your configured log channel (if enabled)
   * **Punishes** the actor (`ban`, `kick`, or `stripstaff`)
   * **Reverts** what it can (e.g. deletes newly‑created channels/roles, reverts permission escalation, removes dangerous roles, deletes mention spam)

### What it can and cannot revert

**Can revert:**

* Channel creation (deletes the created channel after trigger)
* Role creation (deletes the created role after trigger)
* Dangerous permission escalation on roles (reverts permissions back)
* Dangerous roles granted to members (removes the dangerous roles)
* Mention spam (deletes cached mention messages from the last 10 seconds)
* Webhook abuse (deletes abusive webhooks if it has permission)
* Bot adds (kicks unauthorized bots when triggered)

**Cannot reliably revert:**

* Channel deletions (Discord does not provide a true restore)
* Role deletions (same limitation)

AntiNuke will still **punish and log** the actor for deletions.

***

## Requirements

### Bot permissions (important)

AntiNuke relies heavily on audit logs and moderation permissions. Recommended permissions:

* **View Audit Log** *(required for most modules to function)*
* **Ban Members** *(if you use ban punishment)*
* **Kick Members** *(if you use kick punishment)*
* **Manage Roles** *(required for stripstaff + reverting perms + removing dangerous roles)*
* **Manage Channels** *(required to delete channels it created / clean up)*
* **Manage Webhooks** *(required to remove abusive webhooks)*
* **Read Message History** *(for mention spam deletion)*
* **Manage Messages** *(helps with deleting mention messages)*

> If your bot does not have a required permission, that module may silently fail to punish/revert.

***

## Quick setup

1. Invite the bot with the permissions above.
2. Enable Antinuke: `.antinuke on`
3. Set a log channel: `.antinuke logchannel #logs`
4. Add trusted Antinuke admins (optional): `.antinuke admin @user`
5. Configure modules (recommended set below).
6. Verify config: `.antinuke configuration`

***

## Core commands

### Enable AntiNuke (server owner only)

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke on
  ```

  ```javascript Example theme={null}
  .antinuke on
  ```
</CodeGroup>

<br />

<Frame>
  <img src="https://mintcdn.com/omex/ri-HdBsEpqoZ2Npt/images/security/antinuke/on.png?fit=max&auto=format&n=ri-HdBsEpqoZ2Npt&q=85&s=d9fac4c2d3b742380af55d948dab4896" alt="" style={{ width:"100%" }} width="645" height="160" data-path="images/security/antinuke/on.png" />
</Frame>

### Disable AntiNuke (server owner only)

This disables AntiNuke and resets the stored configuration.

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke off
  ```

  ```javascript Example theme={null}
  .antinuke off
  ```
</CodeGroup>

<br />

<Frame>
  <img src="https://mintcdn.com/omex/ri-HdBsEpqoZ2Npt/images/security/antinuke/off.png?fit=max&auto=format&n=ri-HdBsEpqoZ2Npt&q=85&s=7551fb476e1563e37b6247d59c8208fe" alt="" style={{ width:"100%" }} width="671" height="171" data-path="images/security/antinuke/off.png" />
</Frame>

### Set the log channel (server owner only)

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke logchannel (#channel)
  ```

  ```javascript Example theme={null}
  .antinuke logchannel #security-logs
  ```
</CodeGroup>

#### Disable logging

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke logchannel
  ```

  ```javascript Example theme={null}
  .antinuke logchannel
  ```
</CodeGroup>

<br />

<Frame>
  <img src="https://mintcdn.com/omex/ri-HdBsEpqoZ2Npt/images/security/antinuke/logchannel.png?fit=max&auto=format&n=ri-HdBsEpqoZ2Npt&q=85&s=87a1d89d11960ed99a09d9892b47e4eb" alt="" style={{ width:"100%" }} width="585" height="177" data-path="images/security/antinuke/logchannel.png" />
</Frame>

***

## Admins and bypassing

### Allowing other users to configure AntiNuke (server owner only)

The server owner can toggle AntiNuke Admin on a member.

<Warning>
  This is dangerous. AntiNuke Admins can alter protections and reduce thresholds.
</Warning>

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke admin (user)
  ```

  ```javascript Example theme={null}
  .antinuke admin @aj.wtf
  ```
</CodeGroup>

<br />

<Frame>
  <img src="https://mintcdn.com/omex/TJ888WojwYn8NCIi/images/security/antinuke/admin.png?fit=max&auto=format&n=TJ888WojwYn8NCIi&q=85&s=c5066c5ca0f61a59ea8675ffcd0b9bf8" alt="" style={{ width:"100%" }} width="544" height="175" data-path="images/security/antinuke/admin.png" />
</Frame>

### Viewing AntiNuke Admins (server owner only)

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke admins
  ```

  ```javascript Example theme={null}
  .antinuke admins
  ```
</CodeGroup>

<br />

<Frame>
  <img src="https://mintcdn.com/omex/ri-HdBsEpqoZ2Npt/images/security/antinuke/admins.png?fit=max&auto=format&n=ri-HdBsEpqoZ2Npt&q=85&s=0d1729a50c4f44cb755ff8f9d5c801cc" alt="" style={{ width:"100%" }} width="526" height="238" data-path="images/security/antinuke/admins.png" />
</Frame>

### Whitelisting (bypass AntiNuke)

Whitelisted users do not trigger antinuke punishments.

<Warning>
  Dangerous: this bypasses ALL modules.
</Warning>

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke whitelist (user)
  ```

  ```javascript Example theme={null}
  .antinuke whitelist @Aj
  ```
</CodeGroup>

<br />

<Frame>
  <img src="https://mintcdn.com/omex/CuZkJP56Wwo5eWp9/images/security/antinuke/wl.png?fit=max&auto=format&n=CuZkJP56Wwo5eWp9&q=85&s=c5c6832f8f1489024e5e4123a8ed5918" alt="" style={{ width:"100%" }} width="547" height="170" data-path="images/security/antinuke/wl.png" />
</Frame>

#### Unwhitelist

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke unwhitelist (user)
  ```

  ```javascript Example theme={null}
  .antinuke unwhitelist @Aj
  ```
</CodeGroup>

#### View whitelisted users

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke whitelisted
  ```

  ```javascript Example theme={null}
  .antinuke whitelisted
  ```
</CodeGroup>

<br />

<Frame>
  <img src="https://mintcdn.com/omex/hQmz-37BNI2o3TXz/images/security/antinuke/whitelisted.png?fit=max&auto=format&n=hQmz-37BNI2o3TXz&q=85&s=6d7a060557dff95107cbc507d3894080" alt="" style={{ width:"100%" }} width="506" height="233" data-path="images/security/antinuke/whitelisted.png" />
</Frame>

***

## Enabling an antinuke module

Modules are configured per feature (ban/kick/channelcreation/etc). Each module is stored with:

* `status` (on/off)
* `punishment` (`ban`, `kick`, `stripstaff`)
* `threshold` (1–12)
* `command` (true/false) *(stored; triggers are event/audit-log based)*

### Available Flags

<AccordionGroup>
  <Accordion title="Threshold">
    Number of actions allowed in a **10 second** window before AntiNuke triggers.

    <Info>
      Recommended:

      * **1–2** for destructive actions (deletions, dangerous permissions)
      * **2–4** for creation spam (channels/roles)
      * **3–5** for mentions
    </Info>

    <CodeGroup>
      ```javascript Syntax theme={null}
      --threshold (number)
      ```

      ```javascript Example theme={null}
      --threshold 3
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Punishment">
    Action taken against the actor when the module triggers.

    <Info>
      Punishments:

      * `ban`
      * `kick`
      * `stripstaff` (removes staff roles the bot is allowed to remove)
    </Info>

    <CodeGroup>
      ```javascript Syntax theme={null}
      --do (punishment)
      ```

      ```javascript Example theme={null}
      --do stripstaff
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Command detection">
    Stored in configuration as `command: true/false`.

    <Info>
      Triggers rely on server events + audit logs, not command parsing.
      Keep this enabled for consistency with your config schema.
    </Info>

    <CodeGroup>
      ```javascript Syntax theme={null}
      --command (true | false)
      ```

      ```javascript Example theme={null}
      --command true
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

***

## Modules (exactly matching your bot)

<AccordionGroup>
  <Accordion title="Mass ban">
    Triggers when bans are detected and attributes the action using audit logs.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke ban (on or off) --threshold (number) --do (punishment) --command (true | false)
      ```

      ```javascript Example theme={null}
      .antinuke ban on --threshold 3 --do ban --command true
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Mass kick">
    Triggers when kicks are detected and attributes the action using audit logs.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke kick (on or off) --threshold (number) --do (punishment) --command (true | false)
      ```

      ```javascript Example theme={null}
      .antinuke kick on --threshold 3 --do kick --command true
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Channel creation">
    If triggered, it punishes the actor and deletes the created channel.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke channelcreation (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke channelcreation on --threshold 2 --do stripstaff
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Channel deletion">
    Punishes/logs on threshold.

    <Warning>
      Deleted channels cannot be automatically restored.
    </Warning>

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke channeldeletion (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke channeldeletion on --threshold 1 --do ban
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Channel update">
    Watches channel edits (name/permissions/settings) and punishes if abused.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke channelupdate (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke channelupdate on --threshold 2 --do stripstaff
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Role creation">
    If triggered, it punishes the actor and deletes the created role.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke rolecreation (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke rolecreation on --threshold 2 --do stripstaff
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Role deletion">
    Punishes/logs on threshold.

    <Warning>
      Deleted roles cannot be automatically restored.
    </Warning>

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke roledeletion (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke roledeletion on --threshold 1 --do ban
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Role update">
    Watches role edits (name/permissions/settings) and punishes if abused.
    If dangerous permissions were added, it can revert the role permissions back.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke roleupdate (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke roleupdate on --threshold 1 --do ban
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Webhooks">
    Looks for webhook create/delete/update in audit logs.
    If triggered and the bot has **Manage Webhooks**, it deletes webhooks in that channel.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke webhooks (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke webhooks on --threshold 1 --do ban
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Mass mentions">
    Counts mentions per message:

    * `@everyone/@here` adds **5**
    * user mentions add **1 each**
    * role mentions add **1 each**

    When triggered, it deletes cached mention messages from the last 10 seconds and punishes/logs.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke mentions (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke mentions on --threshold 3 --do stripstaff
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Dangerous permissions">
    Covers two cases:

    1. Role permission escalation (reverts permissions back if dangerous perms were added)
    2. Dangerous roles granted to members (removes the dangerous roles)

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke permissions (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke permissions on --threshold 1 --do ban
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Bot add protection">
    Triggers when bots are added to the server.
    If triggered, it can kick the bot and punish the actor.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke botadd (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke botadd on --threshold 1 --do ban
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Emoji updates">
    Triggers on emoji create/update/delete activity attributed via audit logs.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke emoji (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke emoji on --threshold 2 --do stripstaff
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Sticker updates">
    Triggers on sticker create/update/delete activity attributed via audit logs.

    <CodeGroup>
      ```javascript Syntax theme={null}
      .antinuke sticker (on or off) --threshold (number) --do (punishment)
      ```

      ```javascript Example theme={null}
      .antinuke sticker on --threshold 2 --do stripstaff
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

***

## Viewing configuration

Shows AntiNuke enabled status + each module state and parameters.

<CodeGroup>
  ```javascript Syntax theme={null}
  .antinuke configuration
  ```

  ```javascript Example theme={null}
  .antinuke configuration
  ```
</CodeGroup>

<br />

<Frame>
  <img src="https://mintcdn.com/omex/hQmz-37BNI2o3TXz/images/security/antinuke/config.png?fit=max&auto=format&n=hQmz-37BNI2o3TXz&q=85&s=c22a1bd243813851d6c6507a56a4ffe9" alt="" style={{ width:"100%" }} width="651" height="409" data-path="images/security/antinuke/config.png" />
</Frame>

***

## Troubleshooting

### Nothing triggers

* Ensure the bot has **View Audit Log**
* Ensure AntiNuke is enabled: `.antinuke configuration`
* Ensure the specific module is enabled (shows ✅)
* Ensure the bot’s role is high enough to punish/remove roles
* Check your log channel is set properly

### stripstaff doesn’t work

* Bot must have **Manage Roles**
* Bot’s highest role must be **above** the roles it is attempting to remove

### mentions module doesn’t work

* Ensure **Message Content** intent is enabled
* Ensure the bot can read messages in the channels
* Ensure the module is enabled: `.antinuke mentions on ...`

***

## Dangerous permissions tracked in code

These permission keys are treated as “dangerous”:

| Dangerous Permission Keys |
| ------------------------- |
| `administrator`           |
| `manage_guild`            |
| `manage_roles`            |
| `manage_channels`         |
| `manage_webhooks`         |
| `ban_members`             |
| `kick_members`            |
| `mention_everyone`        |
| `moderate_members`        |
| `manage_nicknames`        |
