Skip to content

Parse channel.type using more clear "names" #77

@SuperSajuuk

Description

@SuperSajuuk

Type of Feature Request

Code

Describe the feature you would like to see implemented.

Currently, if you want to check the channels' type, you have to write code like this:

async def on_message(message):
    if message.channel.type == 1:
        # do something where the channel type equals 1

Writing numbers will get very confusing as you'll have to keep checking the enums.py to see what the numbers mean. To begin with, that will be fine, but if more types are added, it'll not be easy.

In that vein, I'd recommend that we should map channel types more naturally so that you can use the isinstance() method, like so:

async def on_message(message):
    if isinstance(message.channel, fluxer.TextChannel):
        # do something where the channel type is a TextChannel

Obviously, if Fluxer adds new channel types in the future, they can be parsed as ints normally in older library versions until an update of the library adds the proper check.

Why do you think this feature would be beneficial?

It will make code easier to read and avoid situations where people have to keep referencing the enums.py file to see what numbers mean what channel type. Ultimately, people can still do manual integer checks, but its just a lot easier to read the suggested format over numbers.

No Duplicates

  • I believe this is not a duplicate request.

Attachments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions