breqdev/flask-discord-interactions

Can't seem to get if channel is NSFW or not

dwilliamsuk opened this issue · 3 comments

Using your example code I can't seem to get if a channel is NSFW or not, it seems

# Channel info, too!
@discord.command()
def channel_info(ctx, channel: Channel):
    return Response(embed={
        "title": channel.name,
        "description": channel.topic,
        "fields": [
            {
                "name": "Channel ID",
                "value": channel.id
            },
            {
                "name": "NSFW?",
                "value": "Yes" if channel.nsfw else "No"
            }
        ]
    })

leads to TypeError: channel_info() missing 1 required positional argument: 'channel'

Can you confirm that you're using the latest version of the library, v0.1.5? The ability to automatically set what the options are based on the function parameters was introduced in this version. Previous versions required you to explicitly define each option.

(In trying to reproduce this, I did notice some issues with the channel.topic and channel.nsfw not being defined, which is because Discord doesn't send all the information about the channel object. I've removed those in 2264f11.)

As per this gist,

Channel: a partial channel object containing id, type, name, and permissions (which is the computed permissions for the invoking user in that channel, including overwrites)

Discord does not send the NSFW status of a channel over the gateway API. Sorry for leading you astray with the example command--it has been corrected in 2264f11.

As for the TypeError, let me know if that is still happening in the latest version of the library.

The TypeError does seem to be fixed, It's a shame discord don't send info like that as it means I can't make NSFW commands. Cheers for the help though.