Math & Text
isNSFW
$isNSFW
The function $isNSFW[channelID] checks if a Discord channel is marked as NSFW (Not Safe For Work).
Syntax
$isNSFW[channelID]
The argument is required: $isNSFW without brackets is refused (“Invalid argument count”). To test the current channel pass $channelID, or use $channelNSFW, whose argument is optional.
Parameters
| Parameter | Description |
|---|---|
channelID |
Required, exactly one argument. A positive integer channel ID, otherwise the error “Invalid channel ID.” is raised. |
Return Value
- Type : Boolean
"true"if the channel is marked NSFW."false"if the channel is not NSFW, or is not a server channel (a DM channel).- If no channel with this ID can be fetched, the command stops with the error “Channel not found.”; the function does not return
falsein that case.
Behavior
- Fetches the channel by ID from Discord and reads its
nsfwattribute. - Only server channels can be NSFW; any other channel (for example a DM) gives
false.
Examples
Restricted command
$if[$isNSFW[$channelID]==true]
$sendMessage[🔞 NSFW content...]
$else
$sendMessage[❌ This command can only be used in an NSFW channel.]
$endif
Channel information
$title[📺 Channel information]
$description[
**Name:** $channelName[$channelID]
**ID:** $channelID
**NSFW:** $if[$isNSFW[$channelID]==true;🔞 Yes;✅ No]
**Category:** $channelCategoryID[$channelID]
]
Check another channel
$var[channel;$message[1]]
$if[$isNSFW[$var[channel]]==true]
$sendMessage[🔞 Channel <#$var[channel]> is NSFW.]
$else
$sendMessage[✅ Channel <#$var[channel]> is not NSFW.]
$endif
Notes
- To check the channel where the command is executed, pass
$channelID. - A DM channel gives
false. - To modify the NSFW status of a channel, use
$modifyChannel[].
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.