Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-primitive values in Enum values for interactions #20

Open
Bluenix2 opened this issue Jun 10, 2022 · 0 comments
Open

Support non-primitive values in Enum values for interactions #20

Bluenix2 opened this issue Jun 10, 2022 · 0 comments
Labels
enhancement Improvement of an existing feature wumpy-interactions

Comments

@Bluenix2
Copy link
Collaborator

Bluenix2 commented Jun 10, 2022

Summary

Enum choices should be updated to only use the name. This makes the actual enum value hidden and allows more complex, non-serializable, values possible to store in the enum.

Description

Currently Enums can be used to type options for application command options but it is restricted to integers, floats, and strings. This is because the actual value of the Enum gets sent to Discord as the choice value.

Theoretically, this also presents a security risk if a user were to have sensitive information in the enum value - not expecting it to be sent to Discord. Even though the value isn't presented in the UI, it is not clear whether self-bots are able to access it.

To solve both of these problems the enum code should be changed to set the choice value to the enum name and then instead use item access as explained by the documentation:

>>> Color['RED']
<Color.RED: 1>
>>> Color['GREEN']
<Color.GREEN: 2>

While implementing this change, the converter attribute of Option should most likely be removed/renamed, to better fit the specific purpose of getting an Enum instance from the value returned by Discord. Perhaps that information should be moved to the type instance of the Option.

@Bluenix2 Bluenix2 added the enhancement Improvement of an existing feature label Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of an existing feature wumpy-interactions
Projects
Status: 📁 - Planning
Development

No branches or pull requests

1 participant