Moderation
onlyNSFW
$onlyNSFW
The guard function $onlyNSFW checks that the channel where the command is executed is marked as NSFW (Not Safe For Work) on Discord. If the channel is not NSFW, the command is interrupted and errorMessage is output.
Syntax
$onlyNSFW[errorMessage]
Parameters
| Parameter | Description |
|---|---|
errorMessage |
Required (may be empty: $onlyNSFW[]). Message output when the channel is not NSFW. |
A bare $onlyNSFW (no brackets) is invalid: it takes exactly one argument.
Behavior
- If the channel is NSFW, the command continues normally.
- If the channel is not NSFW, the command is interrupted (implicit
$stop) anderrorMessageis output in place of the response; with an emptyerrorMessagenothing is displayed. - Comparable to
$onlyIf[$channelNSFW==true;errorMessage], but for a thread the NSFW flag of its parent channel is used, and the guard also stops when the channel cannot be found.
Examples
NSFW-only command
$onlyNSFW[This command only works in NSFW channels.]
$sendMessage[This content is visible only in NSFW channels.]
Manual check with a custom error message
$if[$channelNSFW==false]
$sendMessage[❌ Switch to an NSFW channel to use this command.]
$stop
$endif
$sendMessage[NSFW content.]
Content filtering
$if[$channelNSFW==true]
$sendMessage[🔞 Search result...]
$else
$sendMessage[Filtered search (SFW mode)...]
$endif
Notes
- Pass an empty
errorMessage($onlyNSFW[]) for a silent guard. - NSFW marking is configured in the Discord channel settings (Channel Settings → Overview → NSFW Channel).
- Use
$channelNSFWfor an inline check without interrupting the command. - For a thread, the NSFW status of its parent channel is used.
Try it
Paste an example into the playground to preview its message (functions that act on Discord are not run), or build the same thing with blocks.