PycordViews 1.2.9__tar.gz → 1.2.11__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.
Files changed (34) hide show
  1. {pycordviews-1.2.9 → pycordviews-1.2.11}/PKG-INFO +1 -1
  2. {pycordviews-1.2.9 → pycordviews-1.2.11}/PycordViews.egg-info/PKG-INFO +1 -1
  3. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/modal/easy_modal_view.py +2 -0
  4. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/views/easy_modified_view.py +14 -9
  5. {pycordviews-1.2.9 → pycordviews-1.2.11}/setup.py +1 -1
  6. {pycordviews-1.2.9 → pycordviews-1.2.11}/LICENSE +0 -0
  7. {pycordviews-1.2.9 → pycordviews-1.2.11}/PycordViews.egg-info/SOURCES.txt +0 -0
  8. {pycordviews-1.2.9 → pycordviews-1.2.11}/PycordViews.egg-info/dependency_links.txt +0 -0
  9. {pycordviews-1.2.9 → pycordviews-1.2.11}/PycordViews.egg-info/requires.txt +0 -0
  10. {pycordviews-1.2.9 → pycordviews-1.2.11}/PycordViews.egg-info/top_level.txt +0 -0
  11. {pycordviews-1.2.9 → pycordviews-1.2.11}/README.md +0 -0
  12. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/__init__.py +0 -0
  13. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/kit/__init__.py +0 -0
  14. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/kit/confirm.py +0 -0
  15. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/kit/poll.py +0 -0
  16. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/menu/__init__.py +0 -0
  17. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/menu/errors.py +0 -0
  18. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/menu/menu.py +0 -0
  19. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/menu/selectMenu.py +0 -0
  20. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/modal/__init__.py +0 -0
  21. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/modal/errors.py +0 -0
  22. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/multibot/__init__.py +0 -0
  23. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/multibot/bot.py +0 -0
  24. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/multibot/errors.py +0 -0
  25. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/multibot/multibot.py +0 -0
  26. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/multibot/process.py +0 -0
  27. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/pagination/__init__.py +0 -0
  28. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/pagination/errors.py +0 -0
  29. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/pagination/page.py +0 -0
  30. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/pagination/pagination_view.py +0 -0
  31. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/views/__init__.py +0 -0
  32. {pycordviews-1.2.9 → pycordviews-1.2.11}/pycordViews/views/errors.py +0 -0
  33. {pycordviews-1.2.9 → pycordviews-1.2.11}/pyproject.toml +0 -0
  34. {pycordviews-1.2.9 → pycordviews-1.2.11}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PycordViews
3
- Version: 1.2.9
3
+ Version: 1.2.11
4
4
  Summary: Views and multibot for py-cord library
5
5
  Home-page: https://github.com/BOXERRMD/Py-cord_Views
6
6
  Author: Chronos (alias BOXERRMD)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PycordViews
3
- Version: 1.2.9
3
+ Version: 1.2.11
4
4
  Summary: Views and multibot for py-cord library
5
5
  Home-page: https://github.com/BOXERRMD/Py-cord_Views
6
6
  Author: Chronos (alias BOXERRMD)
@@ -88,6 +88,8 @@ class EasyModal(Modal):
88
88
  if _callable is not None:
89
89
  await _callable(self.get_input_text(inputTextID),interaction)
90
90
 
91
+
92
+
91
93
  def get_input_text(self, inputText_id: str) -> InputText:
92
94
  """
93
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('coucou !!!')
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
  """
@@ -159,9 +163,10 @@ class EasyModifiedViews(View):
159
163
  Func to apply items
160
164
  """
161
165
  func = self.__callback[interaction.custom_id]['func']
166
+ data = self.__callback[interaction.custom_id]['data']
162
167
 
163
168
  if func is not None:
164
- return await func(self.__callback[interaction.custom_id]['ui'], interaction)
169
+ return await func(self.__callback[interaction.custom_id]['ui'], interaction, data) if data != {} else await func(self.__callback[interaction.custom_id]['ui'], interaction)
165
170
 
166
171
  else:
167
172
  await interaction.response.defer(invisible=True)
@@ -5,7 +5,7 @@ with open("README.md", encoding='utf-8') as file:
5
5
 
6
6
  setup(
7
7
  name="PycordViews",
8
- version="1.2.9",
8
+ version="1.2.11",
9
9
  url="https://github.com/BOXERRMD/Py-cord_Views",
10
10
  author="Chronos (alias BOXERRMD)",
11
11
  author_email="vagabonwalybi@gmail.com",
File without changes
File without changes
File without changes
File without changes