PycordViews 1.2.8__tar.gz → 1.2.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pycordviews-1.2.8 → pycordviews-1.2.10}/PKG-INFO +1 -1
- {pycordviews-1.2.8 → pycordviews-1.2.10}/PycordViews.egg-info/PKG-INFO +1 -1
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/modal/easy_modal_view.py +3 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/views/easy_modified_view.py +12 -8
- {pycordviews-1.2.8 → pycordviews-1.2.10}/setup.py +1 -1
- {pycordviews-1.2.8 → pycordviews-1.2.10}/LICENSE +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/PycordViews.egg-info/SOURCES.txt +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/PycordViews.egg-info/dependency_links.txt +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/PycordViews.egg-info/requires.txt +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/PycordViews.egg-info/top_level.txt +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/README.md +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/__init__.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/kit/__init__.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/kit/confirm.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/kit/poll.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/menu/__init__.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/menu/errors.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/menu/menu.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/menu/selectMenu.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/modal/__init__.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/modal/errors.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/multibot/__init__.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/multibot/bot.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/multibot/errors.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/multibot/multibot.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/multibot/process.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/pagination/__init__.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/pagination/errors.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/pagination/page.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/pagination/pagination_view.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/views/__init__.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pycordViews/views/errors.py +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/pyproject.toml +0 -0
- {pycordviews-1.2.8 → pycordviews-1.2.10}/setup.cfg +0 -0
@@ -41,6 +41,7 @@ class EasyModal(Modal):
|
|
41
41
|
|
42
42
|
x = InputText(label=label, style=style, custom_id=custom_id, placeholder=placeholder, min_length=min_length, max_length=max_length, required=required, row=row, value=value)
|
43
43
|
self.__callback[x.custom_id] = None
|
44
|
+
self.add_item(x)
|
44
45
|
return partial(self.set_inputText_callable, x.custom_id)
|
45
46
|
|
46
47
|
def set_inputText_callable(self, inputText_id: str, _callable: Callable) -> "EasyModal":
|
@@ -87,6 +88,8 @@ class EasyModal(Modal):
|
|
87
88
|
if _callable is not None:
|
88
89
|
await _callable(self.get_input_text(inputTextID),interaction)
|
89
90
|
|
91
|
+
|
92
|
+
|
90
93
|
def get_input_text(self, inputText_id: str) -> InputText:
|
91
94
|
"""
|
92
95
|
Return the inputText associated to the inputText_id
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
2
2
|
from discord import Interaction, ApplicationContext, Message, Member
|
3
3
|
from discord.abc import GuildChannel
|
4
4
|
from discord.ui import View, Item
|
5
|
-
from typing import Union, Callable, TYPE_CHECKING, Optional
|
5
|
+
from typing import Union, Callable, TYPE_CHECKING, Optional, Any
|
6
6
|
from asyncio import iscoroutinefunction, create_task
|
7
7
|
|
8
8
|
from .errors import CustomIDNotFound, CoroutineError
|
@@ -30,7 +30,7 @@ class EasyModifiedViews(View):
|
|
30
30
|
super().__init__(*items, timeout=timeout)
|
31
31
|
self.__timeout: Optional[float] = timeout
|
32
32
|
self.__disabled_on_timeout: bool = disabled_on_timeout
|
33
|
-
self.__callback: dict[str, dict[str, Union[Callable[[Interaction], None], Item]]] = {}
|
33
|
+
self.__callback: dict[str, dict[str, Union[Callable[[Interaction], None], Item, Any]]] = {}
|
34
34
|
self.__ctx: Union[Message, Interaction] = None
|
35
35
|
self.__call_on_timeout: Callable = call_on_timeout
|
36
36
|
|
@@ -72,7 +72,7 @@ class EasyModifiedViews(View):
|
|
72
72
|
self.set_callable(item.custom_id, _callable=ui.get_callable(item.custom_id))
|
73
73
|
|
74
74
|
else:
|
75
|
-
self.__callback[ui.custom_id] = {'ui': ui, 'func': None}
|
75
|
+
self.__callback[ui.custom_id] = {'ui': ui, 'func': None, 'data': {}}
|
76
76
|
self.add_item(ui)
|
77
77
|
|
78
78
|
return self
|
@@ -96,7 +96,7 @@ class EasyModifiedViews(View):
|
|
96
96
|
await self._update()
|
97
97
|
return self
|
98
98
|
|
99
|
-
def set_callable_decorator(self, custom_id: str):
|
99
|
+
def set_callable_decorator(self, custom_id: str, data: dict[str, Any] = {}):
|
100
100
|
"""
|
101
101
|
Decorator to set up a callable for the item
|
102
102
|
|
@@ -113,30 +113,33 @@ class EasyModifiedViews(View):
|
|
113
113
|
await ctx.respond('coucou', view=view)
|
114
114
|
|
115
115
|
:param custom_id: item ID of the view
|
116
|
+
:param data: Add any data to pass in called function.
|
116
117
|
"""
|
117
118
|
|
118
119
|
def decorator(_callable: Callable):
|
119
120
|
self.__check_custom_id(custom_id)
|
120
121
|
|
121
122
|
self.__callback[custom_id]['func'] = _callable
|
123
|
+
self.__callback[custom_id]['data'] = data
|
122
124
|
return _callable
|
123
125
|
|
124
126
|
return decorator
|
125
127
|
|
126
|
-
def set_callable(self, *custom_ids: str, _callable: Callable):
|
128
|
+
def set_callable(self, *custom_ids: str, _callable: Callable, data: dict[str, Any] = {}):
|
127
129
|
"""
|
128
130
|
set up a callable for items
|
129
131
|
:param custom_ids: items IDs of the view
|
130
132
|
:param _callable: The asynchronous callable linked. Take UI (Button, Select...) and Interaction parameters.
|
133
|
+
:param data: Add any data to pass in called function.
|
131
134
|
|
132
135
|
**UI and Interaction parameter is required in callable function !**
|
133
136
|
|
134
137
|
view = EasyModifiedViews(None)
|
135
138
|
|
136
|
-
view.add_view(discord.ui.Button(label='coucou', custom_id='test_ID'))
|
139
|
+
view.add_view(discord.ui.Button(label='coucou', custom_id='test_ID', data={'message': 'Hello !'}))
|
137
140
|
|
138
|
-
async def rep(**UI**, **interaction
|
139
|
-
await interaction.response.send_message('
|
141
|
+
async def rep(**UI**, **interaction**, data: dict[str, Any]):
|
142
|
+
await interaction.response.send_message(data['message'])
|
140
143
|
|
141
144
|
view.set_callable(custom_id='test_ID', callable=rep)
|
142
145
|
await ctx.respond('coucou', view=view)
|
@@ -145,6 +148,7 @@ class EasyModifiedViews(View):
|
|
145
148
|
self.__check_custom_id(custom_id)
|
146
149
|
|
147
150
|
self.__callback[custom_id]['func'] = _callable
|
151
|
+
self.__callback[custom_id]['data'] = data
|
148
152
|
|
149
153
|
def get_callable(self, custom_id: str) -> Union[Callable, None]:
|
150
154
|
"""
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|