Skip to content

feat(commands): generalize @is_nsfw() check for potential future channel types - #1609

Open
shiftinv wants to merge 4 commits into
masterfrom
fix/commands-forum-is-nsfw
Open

shiftinv wants to merge 4 commits into
masterfrom
fix/commands-forum-is-nsfw

Conversation

@shiftinv

Copy link
Copy Markdown
Member

Summary

Manually maintaining this list isn't great, but alternatively something like callable(getattr(ch, "is_nsfw", None)) and ch.is_nsfw() # type: ignore feels even worse.
New channel types don't get added all that often, after all.

Checklist

  • If code changes were made, then they have been tested
    • I have updated the documentation to reflect the changes
    • I have formatted the code properly by running uv run nox -s lint
    • I have type-checked the code by running uv run nox -s pyright
  • This PR fixes an issue
  • This PR adds something new (e.g. new method or parameters)
  • This PR is a breaking change (e.g. methods or parameters removed/renamed)
  • This PR is not a code change (e.g. documentation, README, ...)

@read-the-docs-community

read-the-docs-community Bot commented Sep 11, 2026

Copy link
Copy Markdown

Documentation build overview

📚 disnake | 🛠️ Build #34511003 | 📁 Comparing 59ea97c against latest (a71a371)

  🔍 Preview build  

No files changed.

@Enegg

Enegg commented Sep 11, 2026

Copy link
Copy Markdown
Member

Hmm, couldn't we just have a .is_nsfw() on each channel type?
Basically make it a part of the "Channel" interface

@shiftinv

Copy link
Copy Markdown
Member Author

The remaining channels, i.e. categories and dm/group channels, don't really have a concept of nsfw (or spoiler content in #1577, for that matter), and unlike is_spoiler or is_obfuscated in other PRs I wouldn't be sure about reasonable defaults here

@shiftinv

Copy link
Copy Markdown
Member Author

Realizing that this is perhaps a bit silly, as ultimately neither prefix commands nor any interactions can occur in the context of these channels directly.
iac, as long as the GuildMessageable type alias remains correct, a simple isinstance(ch, (abc.GuildChannel, Thread)) actually does it just fine.

@shiftinv shiftinv changed the title fix(commands): support ForumChannel and MediaChannel in @is_nsfw() check feat(commands): generalize @is_nsfw() check for potential future channel types Sep 11, 2026

@Enegg Enegg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rare instance of deleting lines of code :>

@github-project-automation github-project-automation Bot moved this from Todo to Needs Merge in disnake Sep 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Needs Merge

Development

Successfully merging this pull request may close these issues.

2 participants