A :func:`.check` that checks if the channel is a NSFW channel.

    This check raises a special exception, :exc:`.NSFWChannelRequired`
    that is derived from :exc:`.CheckFailure`.

    .. versionchanged:: 1.1.0

        Raise :exc:`.NSFWChannelRequired instead of generic :exc:`.CheckFailure`.
        DM channels will also now pass this check.

def is_nsfw():
    """A :func:`.check` that checks if the channel is a NSFW channel.

    This check raises a special exception, :exc:`.NSFWChannelRequired`
    that is derived from :exc:`.CheckFailure`.

    .. versionchanged:: 1.1.0

        Raise :exc:`.NSFWChannelRequired instead of generic :exc:`.CheckFailure`.
        DM channels will also now pass this check.
    """
    def pred(ctx):
        ch = ctx.channel
        if ctx.guild is None or (isinstance(ch, discord.TextChannel) and ch.is_nsfw()):
            return True
        raise NSFWChannelRequired(ch)
    return check(pred)