-
-
Notifications
You must be signed in to change notification settings - Fork 715
Use LinePaginator
from bot-core
#2682
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
Conversation
bot/constants.py
Outdated
@@ -702,3 +703,5 @@ class _Keys(EnvConfig): | |||
"Noooooo!!", | |||
"I can't believe you've done this", | |||
] | |||
|
|||
PaginationEmojis = PaginationEmojisSettings() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is using defaults, wouldn't it be better for the paginator to use those settings by default? Meaning, you wouldn't need to explicitly send it settings for it to work, only when you want to use something custom. This will save another import and function arg every time you want to you the paginator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The entire problem lies within the trashcan. It's the thing that causes problems for contribs, since that emoji is only available in our server.
So if you don't pass those to the paginator when you're running bot, the paginator will crash since you can't use that emoji.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that's the case, it might be better to just use https://emojipedia.org/wastebasket/ instead, to avoid all those problems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean use it in our server as well ?
Tbh, I didn't consider that as an option, as I thought it was put in place on purpose.
If we were to use that, then we wouldn't be needing the pydnatinc model, import & extra parameter indeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, not sure why we decided on the custom emoji instead of this unicode one. We also have the option to use https://emojipedia.org/stop-sign/ too. Using a unicode emoji would remove a lot of hassle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant class method *
Well, i don't remember what it does specifically now but I'll see what I can do about it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey ! I'm trying to pick this up again and I was wondering what you meant exactly by
One simple way around this for now would be to just create a wrapper here that passes in the necessary constants and we can just use that instead. In the future we may want to think of other ways we can have configuration for bot-core.
Do you mean that we'd keep the pagination emojis as part of the parameters, and then make a decorator that will pass them for us ?
Something like
def pass_parameters(**kwargs_to_pass):
def inner(func):
def wrapper(*args, **kwargs):
kwargs.update(kwargs_to_pass)
return func(*args, **kwargs)
retun wrapper
return inner
Then we'd decorate the paginate
method and pass the emojis using the previous deco ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking we could replace bot/pagination.py
with something like this
from pydis_core import LinePaginator as _LinePaginator
...
PaginationEmojis = PaginationEmojisModel(delete=Emojis.trashcan)
class LinePaginator(_LinePaginator):
@classmethod
async def paginate(cls, *args, **kwargs) -> discord.Message | None:
return await super().paginate(PaginationEmojis, *args, **kwargs)
then we wouldn't need to update any imports either.
The main annoying thing there is by using "*args" and "**kwargs" you lose hints in the editor about what the arguments are and what types you can pass. Not sure if there's a nice way around that other than just copying the parameter list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, you meant that kind of wrapper.
Okay, I see.
Not sure if there's a nice way around that other than just copying the parameter list.
Don't think there is, even withPEP 692
it wouldn't be quite feasible.
I think just copying the parameter list is fine, this will be used by us only, and anyone who wishes to not used the default emojis we provide can fallback to _LinePaginator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wookie184 Implemented in #2879
4749e68
to
432e5e5
Compare
432e5e5
to
84c04e9
Compare
76505e4
to
43e3ce7
Compare
Superseded by #2879 |
This works in conjunction with bot-core#189
It serves as an example of how the new client code consuming bot-core's
LinePaginator
would look like.