disnake icon indicating copy to clipboard operation
disnake copied to clipboard

New components features

Open lightmanLP opened this issue 3 years ago • 2 comments

Summary

I just decided to improve the interface of View. I did some useful things for myself and decided to add them.

Changes:

Some methods of View now returns self for chained usage. Example:

view = (
  View(...)
  .add_item(...)
  .add_item(...)
)

Added Keyboard view with some useful features. Example:

view = (
  Keyboard(timeout=999)
  .add_row(awesome_button1, awesome_button2)
  .from_iterables(
    (b1, b2),
    (b3, b4),
    start=1
  )
)

Checklist

  • [x] If code changes were made, then they have been tested
    • [ ] I have updated the documentation to reflect the changes
    • [x] I have formatted the code properly by running pre-commit run --all-files
  • [ ] This PR fixes an issue
  • [x] 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, ...)

P.S.: Im not sure about docstrings.

lightmanLP avatar Jan 08 '22 08:01 lightmanLP

Why do the new methods have to be in Keyboard instead of View?

ashleney avatar Jan 08 '22 10:01 ashleney

Why do the new methods have to be in Keyboard instead of View?

Just separated them so as not mix with general methods.

lightmanLP avatar Jan 08 '22 10:01 lightmanLP

Thank you for the PR. At this time we don't plan on implementing a Keyboard-like type or methods, they can easily be implemented by subclassing View in user code and using that as the base class for all views, as they just build on top of the existing view interface.

shiftinv avatar Sep 12 '22 18:09 shiftinv