PycordViews 1.2.16__tar.gz → 1.2.19__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.16 → pycordviews-1.2.19}/PKG-INFO +2 -2
- {pycordviews-1.2.16 → pycordviews-1.2.19}/PycordViews.egg-info/PKG-INFO +2 -2
- {pycordviews-1.2.16 → pycordviews-1.2.19}/README.md +1 -1
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/views/easy_modified_view.py +39 -5
- {pycordviews-1.2.16 → pycordviews-1.2.19}/setup.py +1 -1
- {pycordviews-1.2.16 → pycordviews-1.2.19}/LICENSE +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/PycordViews.egg-info/SOURCES.txt +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/PycordViews.egg-info/dependency_links.txt +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/PycordViews.egg-info/requires.txt +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/PycordViews.egg-info/top_level.txt +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/__init__.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/kit/__init__.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/kit/confirm.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/kit/poll.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/menu/__init__.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/menu/errors.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/menu/menu.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/menu/selectMenu.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/modal/__init__.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/modal/easy_modal_view.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/modal/errors.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/multibot/__init__.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/multibot/bot.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/multibot/errors.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/multibot/multibot.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/multibot/process.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/pagination/__init__.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/pagination/errors.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/pagination/page.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/pagination/pagination_view.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/views/__init__.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pycordViews/views/errors.py +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/pyproject.toml +0 -0
- {pycordviews-1.2.16 → pycordviews-1.2.19}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: PycordViews
|
3
|
-
Version: 1.2.
|
3
|
+
Version: 1.2.19
|
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)
|
@@ -95,7 +95,7 @@ The SelectMenu instance is used to create drop-down menus that can be easily mod
|
|
95
95
|
>
|
96
96
|
> > **Method** `add_mentionnable_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` : Add a mentionable select menu in the ui. Return Menu instance to set options
|
97
97
|
>
|
98
|
-
> > **Method** `set_callable(*custom_ids: str, _callable: Union[Callable, None]) -> SelectMenu` : Set a callable for menus associated with custom_ids. This callable _(async function)_ will be set to respond at selected menus interactions
|
98
|
+
> > **Method** `set_callable(*custom_ids: str, _callable: Union[Callable, None], data: Optional[dict[str, Any]]) -> SelectMenu` : Set a callable for menus associated with custom_ids. This callable _(async function)_ will be set to respond at selected menus interactions. _data_ parameter is a dict fill with any values to pass in _(async function)_ parameters
|
99
99
|
>
|
100
100
|
> > **Method** `send(target: Union[Member, TextChannel]) -> Any` : Send the selectmenu in dm member or channels
|
101
101
|
>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: PycordViews
|
3
|
-
Version: 1.2.
|
3
|
+
Version: 1.2.19
|
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)
|
@@ -95,7 +95,7 @@ The SelectMenu instance is used to create drop-down menus that can be easily mod
|
|
95
95
|
>
|
96
96
|
> > **Method** `add_mentionnable_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` : Add a mentionable select menu in the ui. Return Menu instance to set options
|
97
97
|
>
|
98
|
-
> > **Method** `set_callable(*custom_ids: str, _callable: Union[Callable, None]) -> SelectMenu` : Set a callable for menus associated with custom_ids. This callable _(async function)_ will be set to respond at selected menus interactions
|
98
|
+
> > **Method** `set_callable(*custom_ids: str, _callable: Union[Callable, None], data: Optional[dict[str, Any]]) -> SelectMenu` : Set a callable for menus associated with custom_ids. This callable _(async function)_ will be set to respond at selected menus interactions. _data_ parameter is a dict fill with any values to pass in _(async function)_ parameters
|
99
99
|
>
|
100
100
|
> > **Method** `send(target: Union[Member, TextChannel]) -> Any` : Send the selectmenu in dm member or channels
|
101
101
|
>
|
@@ -61,7 +61,7 @@ The SelectMenu instance is used to create drop-down menus that can be easily mod
|
|
61
61
|
>
|
62
62
|
> > **Method** `add_mentionnable_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` : Add a mentionable select menu in the ui. Return Menu instance to set options
|
63
63
|
>
|
64
|
-
> > **Method** `set_callable(*custom_ids: str, _callable: Union[Callable, None]) -> SelectMenu` : Set a callable for menus associated with custom_ids. This callable _(async function)_ will be set to respond at selected menus interactions
|
64
|
+
> > **Method** `set_callable(*custom_ids: str, _callable: Union[Callable, None], data: Optional[dict[str, Any]]) -> SelectMenu` : Set a callable for menus associated with custom_ids. This callable _(async function)_ will be set to respond at selected menus interactions. _data_ parameter is a dict fill with any values to pass in _(async function)_ parameters
|
65
65
|
>
|
66
66
|
> > **Method** `send(target: Union[Member, TextChannel]) -> Any` : Send the selectmenu in dm member or channels
|
67
67
|
>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
from __future__ import annotations
|
2
|
-
from discord import Interaction, ApplicationContext, Message, Member
|
2
|
+
from discord import Interaction, ApplicationContext, Message, Member, Role
|
3
3
|
from discord.abc import GuildChannel
|
4
4
|
from discord.ui import View, Item
|
5
5
|
from typing import Union, Callable, TYPE_CHECKING, Optional, Any
|
@@ -68,11 +68,14 @@ class EasyModifiedViews(View):
|
|
68
68
|
|
69
69
|
if type(ui).__name__ in ('SelectMenu', 'Pagination', 'Confirm', 'Poll', 'EasyModifiedViews'):
|
70
70
|
for item in ui.get_view.items:
|
71
|
+
if type(ui).__name__ in ('SelectMenu', 'Pagination', 'Confirm', 'Poll', 'EasyModifiedViews'):
|
72
|
+
self.add_items(item)
|
73
|
+
continue
|
71
74
|
self.add_items(item)
|
72
75
|
self.set_callable(item.custom_id, _callable=ui.get_callable(item.custom_id), data=ui.get_callable_data(item.custom_id))
|
73
76
|
|
74
77
|
else:
|
75
|
-
self.__callback[ui.custom_id] = {'ui': ui, 'func': None, 'data': {}}
|
78
|
+
self.__callback[ui.custom_id] = {'ui': ui, 'func': None, 'data': {}, 'autorised_roles': None, 'autorised_key': None}
|
76
79
|
self.add_item(ui)
|
77
80
|
|
78
81
|
return self
|
@@ -96,7 +99,10 @@ class EasyModifiedViews(View):
|
|
96
99
|
await self._update()
|
97
100
|
return self
|
98
101
|
|
99
|
-
def set_callable_decorator(self, custom_id: str,
|
102
|
+
def set_callable_decorator(self, custom_id: str,
|
103
|
+
data: Optional[dict[str, Any]] = None,
|
104
|
+
autorised_roles : Optional[list[Union[int, Role]]] = None,
|
105
|
+
autorised_key: Optional[Callable] = None):
|
100
106
|
"""
|
101
107
|
Decorator to set up a callable for the item
|
102
108
|
|
@@ -114,20 +120,32 @@ class EasyModifiedViews(View):
|
|
114
120
|
|
115
121
|
:param custom_id: item ID of the view
|
116
122
|
:param data: Add any data to pass in called function.
|
123
|
+
:param autorised_roles: Any role ID allowed to interact with the view
|
124
|
+
:param autorised_key: Callable function to check anything. The function get the current interaction passed in parameter
|
117
125
|
"""
|
118
126
|
|
119
127
|
def decorator(_callable: Callable):
|
120
|
-
self.set_callable(custom_id,
|
128
|
+
self.set_callable(custom_id,
|
129
|
+
_callable=_callable,
|
130
|
+
data=data,
|
131
|
+
autorised_roles=autorised_roles,
|
132
|
+
autorised_key=autorised_key)
|
121
133
|
return _callable
|
122
134
|
|
123
135
|
return decorator
|
124
136
|
|
125
|
-
def set_callable(self, *custom_ids: str,
|
137
|
+
def set_callable(self, *custom_ids: str,
|
138
|
+
_callable: Callable,
|
139
|
+
data: Optional[dict[str, Any]] = None,
|
140
|
+
autorised_roles : Optional[list[Union[int, Role]]] = None,
|
141
|
+
autorised_key: Optional[Callable] = None):
|
126
142
|
"""
|
127
143
|
set up a callable for items
|
128
144
|
:param custom_ids: items IDs of the view
|
129
145
|
:param _callable: The asynchronous callable linked. Take UI (Button, Select...) and Interaction parameters.
|
130
146
|
:param data: Add any data to pass in called function.
|
147
|
+
:param autorised_roles: Any role ID allowed to interact with the view
|
148
|
+
:param autorised_key: Callable function to check anything. The function get the current interaction passed in parameter
|
131
149
|
|
132
150
|
**UI and Interaction parameter is required in callable function !**
|
133
151
|
|
@@ -146,6 +164,11 @@ class EasyModifiedViews(View):
|
|
146
164
|
|
147
165
|
self.__callback[custom_id]['func'] = _callable
|
148
166
|
self.__callback[custom_id]['data'] = data if data is not None else {}
|
167
|
+
self.__callback[custom_id]['autorised_key'] = autorised_key
|
168
|
+
if autorised_roles is not None:
|
169
|
+
self.__callback[custom_id]['autorised_roles'] = [role.id if isinstance(role, Role) else role for role in autorised_roles if isinstance(role, (Role, int))]
|
170
|
+
else:
|
171
|
+
self.__callback[custom_id]['autorised_roles'] = None
|
149
172
|
|
150
173
|
def get_callable(self, custom_id: str) -> Union[Callable, None]:
|
151
174
|
"""
|
@@ -161,8 +184,19 @@ class EasyModifiedViews(View):
|
|
161
184
|
"""
|
162
185
|
func = self.__callback[interaction.custom_id]['func']
|
163
186
|
data = self.__callback[interaction.custom_id]['data']
|
187
|
+
autorised_roles = self.__callback[interaction.custom_id]['autorised_roles']
|
188
|
+
autorised_key = self.__callback[interaction.custom_id]['autorised_key']
|
164
189
|
|
165
190
|
if func is not None:
|
191
|
+
if autorised_roles is not None: # si des rôles sont obligatoires
|
192
|
+
if not (set(autorised_roles) & set([i.id for i in interaction.user.roles])): # si aucun rôle de l'user est dans les rôles aubligatoires
|
193
|
+
await interaction.response.defer(invisible=True)
|
194
|
+
return False
|
195
|
+
|
196
|
+
if autorised_key is not None: # si une fonction est config pour la vérification
|
197
|
+
if not autorised_key(interaction): # Si la fonction renvoie False
|
198
|
+
return False
|
199
|
+
|
166
200
|
return await func(self.__callback[interaction.custom_id]['ui'], interaction, data)
|
167
201
|
|
168
202
|
else:
|
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
|