# Moderation

Source: https://righteousbot.dev/docs/features/moderation/

Ban, kick, timeout, mute, jail and warn members, undo them, and know what happens when someone rejoins.

Every punishment command takes a target, an optional time and an optional reason. Two rules apply to all of
them: hierarchy is checked separately from permission, and undoing a punishment is easier than applying one.

Name the target with a mention, an ID or their **exact** name. A typo or a name two members share does nothing,
and so does a name too many members start with.

## Punish a member [#punish-a-member]

| Command                                                                              | Does                                                          |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------- |
| [`,ban <person> [purge-window] [reason]`](/commands/moderation/ban/#ban)             | Ban, optionally deleting recent messages                      |
| [`,tempban <person> <time> [purge] [reason]`](/commands/moderation/tempban/#tempban) | Ban that lifts itself when the time runs out                  |
| [`,kick <person> [reason]`](/commands/moderation/kick/#kick)                         | Kick                                                          |
| [`,timeout <person> <time> [reason]`](/commands/moderation/timeout/#timeout)         | Discord timeout, up to 28 days                                |
| [`,mute <person> [time] [reason]`](/commands/moderation/mute/#mute)                  | Take away send access (needs the mute role)                   |
| [`,jail <person> [time] [reason]`](/commands/moderation/jail/#jail)                  | Confine to the jail channel (needs the jail role and channel) |
| [`,warn <person> [reason]`](/commands/moderation/warn/#warn)                         | Record a warning on their punishment history                  |
| [`,hackban <id> [purge-window] [reason]`](/commands/moderation/hackban/#hackban)     | Ban by ID, even if they aren't in the server                  |

<CommandBlock syntax=",ban <person> [purge-window] [reason] [-s]" example=",ban @Sam 7d ban evasion" />

Add `-s` (or `-silent`) to ban, kick, timeout, mute or jail to skip the DM (on slash, `silent:`). The DM names the moderator who ran it, so use `-s` when you don't want that. [`,setup`](/commands/server-tools/setup/#setup)
creates the mute role, jail role and jail channel. The purge window is only read if the word after the
target is a duration up to **7 days**; a longer one is refused, and anything else is part of the reason.
`,hackban` on someone who is in the server gets the same hierarchy check as `,ban`.

`,tempban` and [`/ban`](/commands/moderation/ban/#ban)'s `duration:` take up to 365 days. `,tempban` also takes the
ID of someone who isn't in the server, but refuses someone already banned. Banning them for good with `,hackban`
(they are no longer in the server), or unbanning them with `,unban` or in Discord, cancels the timer.

<DiscordEmbed caption="The DM a member gets from a timed `,mute`. A permanent mute has no Time line. The stripe is the moderator's role colour." color="#6397FF" fields="[{ name: &#x22;**Muted in Righteous.**&#x22;, value: &#x22;›**Staff:** @begging (ID: 123456789012345678)\n›**Channel:** general (ID: 345678901234567890)\n›**Time:** 30m\n›**Reason:** spamming&#x22; }]" footer="Righteous" />

<DiscordEmbed caption="The DM a member gets from `,kick`. It is the same embed the moderation log shows; `,ban` sends the same thing with the field named Ban, and a temporary ban adds a Time line." color="#1e90ff" fields="[{ name: &#x22;Kick&#x22;, value: &#x22;›**Staff:** @begging (ID: 123456789012345678)\n›**User:** sam (ID: 234567890123456789)\n›**Reason:** spamming&#x22; }]" footer="Righteous" />

## Undo a punishment [#undo-a-punishment]

<CommandBlock syntax=",unban <person> [reason]" example=",unmute @Sam" />

[`,unban`](/commands/moderation/unban/#unban), [`,unmute`](/commands/moderation/unmute/#unmute),
[`,untimeout`](/commands/moderation/untimeout/#untimeout) and [`,unjail`](/commands/moderation/unjail/#unjail)
need the same permission as the punishment but skip the part where you must outrank the member.
`/unmute` and `/unjail` take `silent:` too.

## Hierarchy is a separate check [#hierarchy-is-a-separate-check]

Having `BAN_MEMBERS` (even through a fake permission) doesn't let you punish someone above you. The server
owner is always refused, before roles are compared, except by the bot owner. If your own highest role can't be
read, the command refuses. It also refuses anyone who outranks the bot's own top role.

## What jail and mute actually do [#what-jail-and-mute-actually-do]

* **Jail** removes every other role the member has, so the jail channel is all they can see.
  `,unjail` (or the timer ending) gives them back. Roles above the bot, and roles Discord manages (bot,
  integration, Nitro booster), are left alone. A role deleted or moved above the bot meanwhile isn't
  restored, and the reply says how many came back.
* **Mute** touches no roles. It adds a restriction only in channels where another role of theirs would
  override it, and `,unmute` removes exactly those. A channel created mid-mute gets the restriction too.
* `/mute` and `/jail` refuse a duration they can't read, rather than making it permanent.

## Rejoining doesn't pardon anything [#rejoining-doesnt-pardon-anything]

A member who leaves while muted, jailed or timed out gets it **re-applied** when they return, and nothing
else (role history, level rewards, autorole) hands their roles back first. The one exception is a punishment
that **expired while they were away**: it is cleared, not re-applied. See
[Autorole and verification](/docs/features/autorole-and-verification/).

## Mute one thing in one channel [#mute-one-thing-in-one-channel]

<CommandBlock syntax=",cmute [all|#channel] <person>" example=",cmute #general @Sam" />

[`,cmute`](/commands/moderation/cmute/#cmute) (send), [`,imute`](/commands/moderation/imute/#imute)
(images and embeds), [`,emute`](/commands/moderation/emute/#emute) (external emoji),
[`,rmute`](/commands/moderation/rmute/#rmute) (reactions) and [`,hmute`](/commands/moderation/hmute/#hmute)
(hides the channel; also needs `MANAGE_CHANNELS`) each have a matching `,c/i/e/r/hunmute`. On slash they are
one command, [`/channelmute`](/commands/moderation/cmute/#cmute), with a group per permission. A channel unmute
leaves a server-wide `,mute` in place.

## Control the channel [#control-the-channel]

| Command                                                                                                                                                       | Does                                                                                                                                   |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| [`,lockdown [#channel] [time] [hide]`](/commands/moderation/lockdown/#lockdown)                                                                               | Lock a channel, or `all`; `restrict` keeps one out of the sweep. A time schedules the undo. `all` and `hide` also need Manage Channels |
| [`,unlock [#channel]`](/commands/moderation/unlock/#unlock)                                                                                                   | Unlock it                                                                                                                              |
| [`,slowmode <on\|off> [time]`](/commands/moderation/slowmode/#slowmode)                                                                                       | Set slowmode                                                                                                                           |
| [`,disconnect <person>`](/commands/moderation/disconnect/#disconnect)                                                                                         | Remove from voice                                                                                                                      |
| [`,channel`](/commands/moderation/channel/#channel), [`,threads`](/commands/moderation/threads/#threads), [`,invites`](/commands/moderation/invites/#invites) | Manage channels, threads and invites                                                                                                   |

## Sweep recent joiners [#sweep-recent-joiners]

<CommandBlock syntax="/raid <ban|jail> <minutes> [reason]" example="/raid ban 15 mass join spam" />

[`/raid`](/commands/moderation/raid/#raid) punishes everyone who joined in the last 1 to 60 minutes. Anyone
you don't outrank is **skipped and counted**, not a reason to stop. The final report gives both numbers.

## Check history [#check-history]

<CommandBlock syntax=",punishmenthistory <person>" example=",punishmenthistory @Sam" />

[`,punishmenthistory`](/commands/moderation/punishmenthistory/#punishmenthistory) lists every punishment
against a member. [`,moderationhistory`](/commands/moderation/moderationhistory/#moderationhistory) lists
what one staff member has issued. Each punishment gets a case number in its server, shown as `#12` in
`,punishmenthistory`.

| Command                                                                                                       | Does                                 |
| ------------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| [`,punishmenthistory case <number>`](/commands/moderation/punishmenthistory/#punishmenthistory-case)          | Show one case                        |
| [`,punishmenthistory edit <number> <reason>`](/commands/moderation/punishmenthistory/#punishmenthistory-edit) | Change its reason. **Manage Server** |
| [`,punishmenthistory remove <number>`](/commands/moderation/punishmenthistory/#punishmenthistory-remove)      | Delete it. **Manage Server**         |

Nobody can edit, remove or clear their own record, the server owner included, and the moderation log notes
every change and who made it.

<Callout type="warn" title="Clearing a record can't be undone">
  [`,punishmenthistory clear <person>`](/commands/moderation/punishmenthistory/#punishmenthistory-clear) wipes a
  member's record and needs **Manage Server**. Trap and anti-spam escalation counts reset with it. There is no
  equivalent for a staff member's issued list. The right-click **Apps → Punishment History** menu only reads, so
  it can't clear.
</Callout>

## Common issues [#common-issues]

**"Couldn't find that member" or "members have that exact name".** Mention them or paste their ID.

**"Invalid Mute Role" or "Invalid Jail Role".** The role isn't set yet. Run `,setup`, or set it with
[`,config`](/commands/server-tools/config/#config).

**"Higher Role Hierarchy" on a command I'm allowed to use.** You must also outrank the target. Compare your
highest role with theirs.

**A punishment didn't come back after the member rejoined.** If it expired while they were gone, that's
correct. Otherwise check the mute or jail role still exists below the bot's top role.

**`,unjail` restored fewer roles than they had.** Read the count. Deleted roles, roles above the bot, and
jails with no stored record can't be restored.

**`/raid` punished fewer people than joined.** Check the skipped count: anyone you don't outrank is left alone.

Still stuck? See [common issues](/docs/common-issues/).
