disnakecommunity / disnake-ext-components Goto Github PK
View Code? Open in Web Editor NEWAn extension for disnake aimed at making component interactions with listeners somewhat less cumbersome.
License: MIT License
An extension for disnake aimed at making component interactions with listeners somewhat less cumbersome.
License: MIT License
use sphinx for documentation
The documentation
no docs
docs
none
would be cool, maybe even nice
Add the documentation as a hyperlink in the readme
The documentation
None
First of all, I'm talking about this documentation page: https://disnake-ext-components.readthedocs.io/en/docs/
This could be done in many ways but the most simple one would be to add it as a hyperlink like so:
An extension for disnake aimed at making component interactions with listeners somewhat less cumbersome.
Requires disnake version 2.5.0 or above.
No response
No response
A way to assign a callback to always listen for components matching certain attributes.
eg, a button the button colour and custom_id, and the fact that it is a button
@components.match_component(disnake.Button(custom_id="button!", color="..."))
@components.match_component(component_type=disnake.ComponentType.button, custom_id="...")
This effectively allows a button callback.
To make this even nicer, using the decorated function could have a method or function attached that creates a component with the specified parameters, as that would allow sending the created and matching button or select quite easily.
Use a custom dataclass solution instead of attrs.
disnake.ext.components
Currently, the lib (rewrite) uses attrs to generate its parser classes. The resulting classes can do a lot more than strictly necessary. By creating a custom dataclass-like implementation, we can cut down on a lot of functionality we do not need, and considerably simplify class creation logic (just take a look at how convoluted the component metaclass is).
An example of this is field metadata. Currently, any specialised data is stored in attrs fields' metadata. This is an immutable mapping (types.MappingProxyType
). Therefore, to update the metadata, one would need to create a copy of the field and overwrite the existing one with the copy. A custom implementation would allow us to control when this data is frozen, considerably simplifying the instantiation logic.
Due to the heavy-handed nature of this suggestion, it is of very low priority. Our main concern at this moment is making sure the rewrite is feature-complete, and any refactors like this can come after.
Create a fully customised dataclass-like implementation. First and foremost, custom fields that natively support everything components need (e.g. built-in parser support). After that, a modified component metaclass that handles these custom fields in such a way that the resulting "API" remains compatible with the existing one.
No response
This is of very low priority. We shouldn't bother with this until at least after the library is feature-complete.
A couple rather handy parameter types such as List[T]
are not yet supported outside of special parameters.
disnake.ext.components
Currently, to convert input to e.g. a list of values, one would need to make a custom converter using components.Converted
. It would be nice to innately support a variety of collection types by default. Furthermore, certain disnake types such as disnake.Colour
and disnake.PartialEmoji
are not yet supported either.
Implement support for these missing types.
Writing custom converters using components.Converted
; e.g.
def to_list(arg: str) -> typing.List[str]:
return arg.split(",")
def from_list(arg: typing.List[str]) -> str:
return ",".join(arg)
# annotation:
components.Converted[
components.patterns.STRING, # not really any regex validation
to_list,
from_list,
]
No response
Add logging to e.g. custom_id creation such that it is easier for people to figure out if something went wrong and why.
disnake.ext.components
Currently, just about everything the module does, happens internally, away from the user's influence except for any exceptions that are raised. Providing logging for some internal actions that are taken would make it easier to debug any issues. This holds both for fixing bugs with the library, and for the end-developer to more quickly figure out if something went wrong due to an error they made in setting up the component listeners.
Add logging debug logging to a couple parts of the internals. Ideally use different loggers so users can pick which they want to enable/disable. of
There currently is no solution to this problem, outside of writing custom listener classes, which is not really feasible.
No response
Add parser classes for a bunch of disnake classes that should have them.
disnake.ext.components
Currently, the types supported by disnake-ext-components' parsers are
str
, int
, float
, bool
, etc.;abc.Snowflake
and Object
; both map to Object
);This means that a lot of types that should have parsers currently do not. This means that type annotations for custom id parameters with these types will not work, and raise an exception instead. It is therefore desirable to implement more types. These missing types include:
disnake.User
/disnake.Member
;disnake.Guild
,disnake.Message
and disnake.PartialMessage
;disnake.PartialMessageable
(Note, this one may need some special attention);disnake.Role
;disnake.Emoji
and disnake.PartialEmoji
;disnake.Permissions
;Similarly, there's some other standard-library types that could do with parsers:
enum.Enum
and enum.Flag
;Given the large scale of this issue, it is perfectly fine and much appreciated even to contribute only a small bit of the missing parsers and we'll tackle all the types over time.
Implement parser classes for the aforementioned types.
Writing custom parsers for all these types. While this is possible right now, it's not sufficient in the long-term.
No response
Add string compression for custom ids, such that users can store more data than normally allowed by discord's 100-character limit.
disnake.ext.components
Discord enforces a maximum length of 100 characters for their components' custom ids. Since ext-components stores data in these custom ids, it is feasible to run out of space. It would be nice to provide the user with hooks with which they can (de)compress custom ids with a compression lib of their choice.
Provide users with hooks to (de)compress custom ids. Provide a 'default' library through installation of e.g. disnake-ext-components[compress]
. This default library will probably be python bindings to unishox-2
: unishox2-py3
, as this can handle the complex nature of custom ids an d still provide compression.
note: discord only cares about text-length, not byte length, which we can make optimal use of with this lib.
Currently, the only way to make use of compression would be to use a custom converter on each callback parameter to individually compress them. In many situations, this would barely provide any gains.
This should come paired with proper length checks for created custom ids.
Rewrite parsers to be actual class definitions instead of generated shorthands.
disnake.ext.components
Currently, a bunch of parsers are generated by means of a _build_<type>_parser
helper function and some parameters to make them work as intended. This doesn't play nice with typehinting (we can't modify typehints on a per-parser basis) and documentation, so we should use explicit class definitions for all parsers.
Replace all "functional" parser definitions with actual classes.
No response
This is especially relevant given upcoming changes moving away from requiring an interaction to parse a component.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.