PycordViews 1.1.3__tar.gz → 1.2.0__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 (39) hide show
  1. pycordviews-1.2.0/PKG-INFO +241 -0
  2. pycordviews-1.2.0/PycordViews.egg-info/PKG-INFO +241 -0
  3. {pycordviews-1.1.3 → pycordviews-1.2.0}/PycordViews.egg-info/SOURCES.txt +6 -9
  4. pycordviews-1.2.0/PycordViews.egg-info/requires.txt +1 -0
  5. pycordviews-1.2.0/README.md +207 -0
  6. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/__init__.py +2 -2
  7. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/menu/__init__.py +1 -1
  8. pycordviews-1.2.0/pycordViews/menu/menu.py +118 -0
  9. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/menu/selectMenu.py +29 -9
  10. pycordviews-1.2.0/pycordViews/multibot/__init__.py +1 -0
  11. pycordviews-1.2.0/pycordViews/multibot/bot.py +194 -0
  12. pycordviews-1.2.0/pycordViews/multibot/errors.py +30 -0
  13. pycordviews-1.2.0/pycordViews/multibot/multibot.py +206 -0
  14. pycordviews-1.2.0/pycordViews/multibot/process.py +217 -0
  15. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/pagination/pagination_view.py +7 -0
  16. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/views/easy_modified_view.py +40 -18
  17. {pycordviews-1.1.3 → pycordviews-1.2.0}/setup.py +4 -4
  18. pycordviews-1.1.3/PKG-INFO +0 -80
  19. pycordviews-1.1.3/PycordViews.egg-info/PKG-INFO +0 -80
  20. pycordviews-1.1.3/PycordViews.egg-info/requires.txt +0 -1
  21. pycordviews-1.1.3/README.md +0 -47
  22. pycordviews-1.1.3/pycordViews/menu/menu.py +0 -57
  23. pycordviews-1.1.3/pycordViews/multibot/__init__.py +0 -5
  24. pycordviews-1.1.3/pycordViews/multibot/errors.py +0 -10
  25. pycordviews-1.1.3/pycordViews/multibot/process_for_bots.py +0 -112
  26. pycordviews-1.1.3/pycordViews/multibot/process_messages.py +0 -7
  27. pycordviews-1.1.3/pycordViews/multibot/runner.py +0 -14
  28. pycordviews-1.1.3/pycordViews/multibot/start_multibot.py +0 -80
  29. pycordviews-1.1.3/pycordViews/typeViews.py +0 -4
  30. {pycordviews-1.1.3 → pycordviews-1.2.0}/LICENSE +0 -0
  31. {pycordviews-1.1.3 → pycordviews-1.2.0}/PycordViews.egg-info/dependency_links.txt +0 -0
  32. {pycordviews-1.1.3 → pycordviews-1.2.0}/PycordViews.egg-info/top_level.txt +0 -0
  33. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/menu/errors.py +0 -0
  34. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/pagination/__init__.py +0 -0
  35. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/pagination/errors.py +0 -0
  36. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/views/__init__.py +0 -0
  37. {pycordviews-1.1.3 → pycordviews-1.2.0}/pycordViews/views/errors.py +0 -0
  38. {pycordviews-1.1.3 → pycordviews-1.2.0}/pyproject.toml +0 -0
  39. {pycordviews-1.1.3 → pycordviews-1.2.0}/setup.cfg +0 -0
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.4
2
+ Name: PycordViews
3
+ Version: 1.2.0
4
+ Summary: Views and multibot for py-cord library
5
+ Home-page: https://github.com/BOXERRMD/Py-cord_Views
6
+ Author: Chronos (alias BOXERRMD)
7
+ Author-email: vagabonwalybi@gmail.com
8
+ Maintainer: Chronos
9
+ License: MIT License
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 11
14
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 10
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: immutable-Python-type
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: license
29
+ Dynamic: license-file
30
+ Dynamic: maintainer
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ # Py-cord_Views
36
+ Views for py-cord library
37
+
38
+ # Paginator
39
+ The paginator instance is used to create a view acting as a “book”, with pages that can be turned using buttons.
40
+ ## `Paginator`
41
+ > ```python
42
+ > Paginator(timeout: Union[float, None] = None, disabled_on_timeout: bool = False)`
43
+ > ```
44
+ > > **Method** `add_page(*args, **kwargs) -> Pagination` : add a new page with send message function parameters _(content, embed, embeds, files...)_
45
+ >
46
+ > > **Method** `delete_pages(*page_numbers: Union[str, int]) -> Pagination` : Deletes pages in the order in which they were added _(start to 0)_
47
+ >
48
+ > > **Method** `send(target: Union[Member, TextChannel]) -> Any` : Send the pagination in dm member or channels
49
+ >
50
+ > > **Method** `respond(ctx: ApplicationContext) -> Any` : Respond at slash command call
51
+ >
52
+ > > **@property** `get_view -> EasyModifiedViews` : Return the pagination view. Can be used in `view` parameter to setup a view
53
+ >
54
+ > > **@property** `get_page -> int` : get the showed page number
55
+
56
+ ```python
57
+ from pycordViews.pagination import Pagination
58
+ import discord
59
+
60
+ intents = discord.Intents.all()
61
+ bot = discord.AutoShardedBot(intents=intents)
62
+
63
+ @bot.command(name="My command paginator", description="...")
64
+ async def pagination_command(ctx):
65
+ """
66
+ Create a command pagination
67
+ """
68
+ pages: Pagination = Pagination(timeout=None, disabled_on_timeout=False)
69
+
70
+ pages.add_page(content="It's my first page !!", embed=None)# reset embed else he show the embed of the page after
71
+
72
+ embed = discord.Embed(title="My embed title", description="..........")
73
+ pages.add_page(content=None, embed=embed) # reset content else he show the content of the page before
74
+
75
+ pages.add_page(content="My last page !", embed=None)# reset embed else he show the embed of the page before
76
+
77
+ await pages.respond(ctx=ctx) # respond to the command
78
+ await pages.send(send_to=ctx.author) # send the message to the command author
79
+
80
+ bot.run("Your token")
81
+ ```
82
+
83
+ # SelectMenu
84
+ The SelectMenu instance is used to create drop-down menus that can be easily modified at will.
85
+
86
+ ## `SelectMenu`
87
+ > ```python
88
+ > SelectMenu(timeout: Union[float, None] = None, disabled_on_timeout: bool = False)`
89
+ > ```
90
+ > > **Method** `add_string_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` : Add a string select menu in the ui. Return Menu instance to set options
91
+ >
92
+ > > **Method** `add_user_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` : Add a user select menu in the ui. Return Menu instance to set options
93
+ >
94
+ > > **Method** `add_role_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` Add a role select menu in the ui. Return Menu instance to set options
95
+ >
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
+ >
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
99
+ >
100
+ > > **Method** `send(target: Union[Member, TextChannel]) -> Any` : Send the selectmenu in dm member or channels
101
+ >
102
+ > > **Method** `respond(ctx: ApplicationContext) -> Any` : Respond at slash command call
103
+ >
104
+ > > **Method** `update() -> None` : Update the view dynamically if there was sent before.
105
+ >
106
+ > > **@Method** `get_callable(self, custom_id: str) -> Union[Callable, None]` : Get the callable _async_ function link to the custom_id ui. If any callable set, return None
107
+ >
108
+ > > **@property** `get_view -> EasyModifiedViews` : Return the selectmenu view. Can be used in `view` parameter to setup a view
109
+
110
+ ### Menu
111
+
112
+ ## `Menu`
113
+ > ```python
114
+ > Menu(...)` # Not to be initialized by the user
115
+ > ```
116
+ > > **Method** `set_callable(_callable: Union[Callable, None]) -> Menu` : Set a callable for menus associated. This callable _(async function)_ will be set to respond at selected menus interactions
117
+ >
118
+ > > **Method** `add_option(label: str, value: str = MISSING, description: Union[str, None] = None, emoji: Union[str, Emoji, PartialEmoji, None] = None, default: bool = False) -> Menu` : Add a string select option. Only for string select menu !
119
+ >
120
+ > > **Method** `remove_options(*labels: str) -> Menu` : Remove options with labels. Only for string select menu !
121
+ >
122
+ > > **Method** `update_option(current_label: str, new_label: str = None, value: str = None, description: Union[str, None] = None, emoji: Union[str, Emoji, PartialEmoji, None] = None, default: Union[bool, None] = None) -> Menu` : Update option associated with `current_label` parameter
123
+ >
124
+ > > **@property** `component -> CustomSelect` : Return the Select component class
125
+ >
126
+ > > **@property** `selectmenu -> SelectMenu` : Return the current SelectMenu instance associated
127
+ >
128
+ > > **@property** `callable -> Callable` : Return the current callable menu
129
+
130
+ ```python
131
+ from pycordViews.menu import SelectMenu
132
+ import discord
133
+
134
+ intents = discord.Intents.all()
135
+ bot = discord.AutoShardedBot(intents=intents)
136
+
137
+ @bot.command(name="My command select")
138
+ async def select_command(ctx):
139
+ """
140
+ Create a command select
141
+ """
142
+ async def your_response(select, interaction):
143
+ await interaction.response.send(f"You have selected {select.values[0]} !")
144
+
145
+ my_selector = SelectMenu(timeout=None, disabled_on_timeout=False) # A basic selector menu
146
+ my_menu = my_selector.add_string_select_menu(placeholder="Choice anything !") # add string_select UI
147
+
148
+ my_menu.add_option(label="My first choice !", emoji="😊", default=True, description="It's the first choice !", value='first choice')
149
+ my_menu.add_option(label="My second choice !", value='second choice')
150
+ my_menu.set_callable(your_response)
151
+
152
+ await my_selector.respond(ctx)
153
+
154
+ bot.run("Your token")
155
+ ```
156
+
157
+ # Multibot
158
+ The Multibot instance is used to manage several bots dynamically.
159
+
160
+ Each instance of this class creates a process where bots can be added. These bots will each be launched in a different thread with their own asyncio loop.
161
+
162
+ ## `Multibot`
163
+ > ```python
164
+ > Multibot(global_timeout: int = 30) # global_timeout is the time in seconds the program waits before abandoning the request
165
+ > ```
166
+ > > **Method** `add_bot(bot_name: str, token: str, intents: Intents) -> None` : Add a bot. The name given here is not the real bot name, it's juste an ID
167
+ >
168
+ > > **Method** `remove_bot(bot_name: str) -> dict[str, str]` : Remove à bot. If the bot is online, it will turn off properly. It can take a long time !
169
+ >
170
+ > > **Method** `start(*bot_names: str) -> list[dict[str, str]]` : Start bots
171
+ >
172
+ > > **Method** `def stop(*bot_names: str) -> list[dict[str, str]]` : Stop bots properly
173
+ >
174
+ > > **Method** `start_all() -> list[dict[str, list[str]]]` : Start all bot in the process
175
+ >
176
+ > > **Method** `stop_all() -> list[dict[str, list[str]]]` : Stop all bot in the process properly
177
+ >
178
+ > > **Method** `is_started(bot_name: str) -> bool` : Return if the bot is connected at the Discord WebSocket
179
+ >
180
+ > > **Method** `is_ready(bot_name: str) -> bool` : Return if the bot is ready in Discord
181
+ >
182
+ > > **Method** `is_ws_ratelimited(bot_name: str) -> bool` : Return if the bot is rate limited by Discord
183
+ >
184
+ > > **Method** `reload_commands(*bot_names: str) -> list[dict[str, str]]` : Reload all commands for each bot passed in parameters
185
+ >
186
+ > > **Method** `add_pyFile_commands(bot_name: str, file: str, setup_function: str = 'setup', reload_command: bool = True) -> dict[str, str]` : Add a python Discord command file to the bot. `file` parameter require a file path, absolute or not. By default, it automatically reloads commands on the bot after adding the file.
187
+ > >
188
+ > > ### _Blob_commands.py_
189
+ > > ```python
190
+ > > """
191
+ > > Discord command file example. Follow it !
192
+ > > This file doesn't have 'bot.run()' function. It's managed by Multibot instance.
193
+ > > """
194
+ > >
195
+ > > from discord import Bot, ApplicationContext, Message # autoaticly imported by importlib module
196
+ > >
197
+ > > # this function is called when the bot load a python file command. It is mandatory to have it with a bot parameter !
198
+ > > def setup(bot: Bot):
199
+ > > """
200
+ > > Function called by the process and give the bot instance.
201
+ > > This function is mandatory to have it with a bot parameter but can be renamed with 'setup_function' parameter in 'add_pyFile_commands' method.
202
+ > > Every discord command and discord event can be in this function, but you can make function and class outside setup function.
203
+ > > -> bot : Instance of your started bot.
204
+ > > """
205
+ > > @bot.command()
206
+ > > async def my_first_command(ctx: ApplicationContext):
207
+ > > await ctx.respond("It's my first command !")
208
+ > >
209
+ > > @bot.event
210
+ > > async def on_message(message: Message):
211
+ > > await message.add_reaction(emoji="😊")
212
+ > >
213
+ > > # You don't need 'bot.run(...)' here !
214
+ > > ```
215
+ >
216
+ > > **Method** `modify_pyFile_commands(bot_name: str, file: str, setup_function: str = 'setup') -> dict[str, str]` : Modify python discord command file and setup function. This method doesn't reload automatically commands on the bot. Use `reload_commands` after. `file` parameter require a file path, absolute or not.
217
+ >
218
+ > > **@property** `bot_count -> int` : Return the total number of bots
219
+ >
220
+ > > **@property** `started_bot_count -> int` : Return the total number of started bots
221
+ >
222
+ > > **@property** `shutdown_bot_count( -> int` : Return the total number of shutdown bots
223
+ >
224
+ > > **@property** `get_bots_name -> list[str]` : Return all bots name _(not real name of bots)_
225
+ ```python
226
+ from pycordViews.multibot import Multibot
227
+ from discord import Intents
228
+
229
+ if __name__ == '__main__': # Obligatory !
230
+ process = Multibot()
231
+
232
+ process.add_bot(bot_name="Blob", token="TOKEN FIRST BOT", intents=Intents.all())
233
+ process.add_bot(bot_name="Bee", token="TOKEN SECOND BOT", intents=Intents.all())
234
+
235
+ process.start_all()
236
+ process.add_pyFile_commands(bot_name='Blob', file='Blob_commands.py', reload_command=True)
237
+ process.add_pyFile_commands(bot_name='Bee', file='Bee_commandes.py', reload_command=True)
238
+
239
+ process.modify_pyFile_commands(bot_name='Blob', file='others_commands/Blob2_commands.py', setup_function='started_bot')
240
+ process.reload_commands('Blob')
241
+ ```
@@ -0,0 +1,241 @@
1
+ Metadata-Version: 2.4
2
+ Name: PycordViews
3
+ Version: 1.2.0
4
+ Summary: Views and multibot for py-cord library
5
+ Home-page: https://github.com/BOXERRMD/Py-cord_Views
6
+ Author: Chronos (alias BOXERRMD)
7
+ Author-email: vagabonwalybi@gmail.com
8
+ Maintainer: Chronos
9
+ License: MIT License
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 11
14
+ Classifier: Operating System :: Microsoft :: Windows :: Windows 10
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Operating System :: MacOS
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Requires-Python: >=3.9
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: immutable-Python-type
22
+ Dynamic: author
23
+ Dynamic: author-email
24
+ Dynamic: classifier
25
+ Dynamic: description
26
+ Dynamic: description-content-type
27
+ Dynamic: home-page
28
+ Dynamic: license
29
+ Dynamic: license-file
30
+ Dynamic: maintainer
31
+ Dynamic: requires-dist
32
+ Dynamic: requires-python
33
+ Dynamic: summary
34
+
35
+ # Py-cord_Views
36
+ Views for py-cord library
37
+
38
+ # Paginator
39
+ The paginator instance is used to create a view acting as a “book”, with pages that can be turned using buttons.
40
+ ## `Paginator`
41
+ > ```python
42
+ > Paginator(timeout: Union[float, None] = None, disabled_on_timeout: bool = False)`
43
+ > ```
44
+ > > **Method** `add_page(*args, **kwargs) -> Pagination` : add a new page with send message function parameters _(content, embed, embeds, files...)_
45
+ >
46
+ > > **Method** `delete_pages(*page_numbers: Union[str, int]) -> Pagination` : Deletes pages in the order in which they were added _(start to 0)_
47
+ >
48
+ > > **Method** `send(target: Union[Member, TextChannel]) -> Any` : Send the pagination in dm member or channels
49
+ >
50
+ > > **Method** `respond(ctx: ApplicationContext) -> Any` : Respond at slash command call
51
+ >
52
+ > > **@property** `get_view -> EasyModifiedViews` : Return the pagination view. Can be used in `view` parameter to setup a view
53
+ >
54
+ > > **@property** `get_page -> int` : get the showed page number
55
+
56
+ ```python
57
+ from pycordViews.pagination import Pagination
58
+ import discord
59
+
60
+ intents = discord.Intents.all()
61
+ bot = discord.AutoShardedBot(intents=intents)
62
+
63
+ @bot.command(name="My command paginator", description="...")
64
+ async def pagination_command(ctx):
65
+ """
66
+ Create a command pagination
67
+ """
68
+ pages: Pagination = Pagination(timeout=None, disabled_on_timeout=False)
69
+
70
+ pages.add_page(content="It's my first page !!", embed=None)# reset embed else he show the embed of the page after
71
+
72
+ embed = discord.Embed(title="My embed title", description="..........")
73
+ pages.add_page(content=None, embed=embed) # reset content else he show the content of the page before
74
+
75
+ pages.add_page(content="My last page !", embed=None)# reset embed else he show the embed of the page before
76
+
77
+ await pages.respond(ctx=ctx) # respond to the command
78
+ await pages.send(send_to=ctx.author) # send the message to the command author
79
+
80
+ bot.run("Your token")
81
+ ```
82
+
83
+ # SelectMenu
84
+ The SelectMenu instance is used to create drop-down menus that can be easily modified at will.
85
+
86
+ ## `SelectMenu`
87
+ > ```python
88
+ > SelectMenu(timeout: Union[float, None] = None, disabled_on_timeout: bool = False)`
89
+ > ```
90
+ > > **Method** `add_string_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` : Add a string select menu in the ui. Return Menu instance to set options
91
+ >
92
+ > > **Method** `add_user_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` : Add a user select menu in the ui. Return Menu instance to set options
93
+ >
94
+ > > **Method** `add_role_select_menu(custom_id: str = None, placeholder: str = None, min_values: int = 1, max_values: int = 1, disabled=False, row=None) -> Menu` Add a role select menu in the ui. Return Menu instance to set options
95
+ >
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
+ >
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
99
+ >
100
+ > > **Method** `send(target: Union[Member, TextChannel]) -> Any` : Send the selectmenu in dm member or channels
101
+ >
102
+ > > **Method** `respond(ctx: ApplicationContext) -> Any` : Respond at slash command call
103
+ >
104
+ > > **Method** `update() -> None` : Update the view dynamically if there was sent before.
105
+ >
106
+ > > **@Method** `get_callable(self, custom_id: str) -> Union[Callable, None]` : Get the callable _async_ function link to the custom_id ui. If any callable set, return None
107
+ >
108
+ > > **@property** `get_view -> EasyModifiedViews` : Return the selectmenu view. Can be used in `view` parameter to setup a view
109
+
110
+ ### Menu
111
+
112
+ ## `Menu`
113
+ > ```python
114
+ > Menu(...)` # Not to be initialized by the user
115
+ > ```
116
+ > > **Method** `set_callable(_callable: Union[Callable, None]) -> Menu` : Set a callable for menus associated. This callable _(async function)_ will be set to respond at selected menus interactions
117
+ >
118
+ > > **Method** `add_option(label: str, value: str = MISSING, description: Union[str, None] = None, emoji: Union[str, Emoji, PartialEmoji, None] = None, default: bool = False) -> Menu` : Add a string select option. Only for string select menu !
119
+ >
120
+ > > **Method** `remove_options(*labels: str) -> Menu` : Remove options with labels. Only for string select menu !
121
+ >
122
+ > > **Method** `update_option(current_label: str, new_label: str = None, value: str = None, description: Union[str, None] = None, emoji: Union[str, Emoji, PartialEmoji, None] = None, default: Union[bool, None] = None) -> Menu` : Update option associated with `current_label` parameter
123
+ >
124
+ > > **@property** `component -> CustomSelect` : Return the Select component class
125
+ >
126
+ > > **@property** `selectmenu -> SelectMenu` : Return the current SelectMenu instance associated
127
+ >
128
+ > > **@property** `callable -> Callable` : Return the current callable menu
129
+
130
+ ```python
131
+ from pycordViews.menu import SelectMenu
132
+ import discord
133
+
134
+ intents = discord.Intents.all()
135
+ bot = discord.AutoShardedBot(intents=intents)
136
+
137
+ @bot.command(name="My command select")
138
+ async def select_command(ctx):
139
+ """
140
+ Create a command select
141
+ """
142
+ async def your_response(select, interaction):
143
+ await interaction.response.send(f"You have selected {select.values[0]} !")
144
+
145
+ my_selector = SelectMenu(timeout=None, disabled_on_timeout=False) # A basic selector menu
146
+ my_menu = my_selector.add_string_select_menu(placeholder="Choice anything !") # add string_select UI
147
+
148
+ my_menu.add_option(label="My first choice !", emoji="😊", default=True, description="It's the first choice !", value='first choice')
149
+ my_menu.add_option(label="My second choice !", value='second choice')
150
+ my_menu.set_callable(your_response)
151
+
152
+ await my_selector.respond(ctx)
153
+
154
+ bot.run("Your token")
155
+ ```
156
+
157
+ # Multibot
158
+ The Multibot instance is used to manage several bots dynamically.
159
+
160
+ Each instance of this class creates a process where bots can be added. These bots will each be launched in a different thread with their own asyncio loop.
161
+
162
+ ## `Multibot`
163
+ > ```python
164
+ > Multibot(global_timeout: int = 30) # global_timeout is the time in seconds the program waits before abandoning the request
165
+ > ```
166
+ > > **Method** `add_bot(bot_name: str, token: str, intents: Intents) -> None` : Add a bot. The name given here is not the real bot name, it's juste an ID
167
+ >
168
+ > > **Method** `remove_bot(bot_name: str) -> dict[str, str]` : Remove à bot. If the bot is online, it will turn off properly. It can take a long time !
169
+ >
170
+ > > **Method** `start(*bot_names: str) -> list[dict[str, str]]` : Start bots
171
+ >
172
+ > > **Method** `def stop(*bot_names: str) -> list[dict[str, str]]` : Stop bots properly
173
+ >
174
+ > > **Method** `start_all() -> list[dict[str, list[str]]]` : Start all bot in the process
175
+ >
176
+ > > **Method** `stop_all() -> list[dict[str, list[str]]]` : Stop all bot in the process properly
177
+ >
178
+ > > **Method** `is_started(bot_name: str) -> bool` : Return if the bot is connected at the Discord WebSocket
179
+ >
180
+ > > **Method** `is_ready(bot_name: str) -> bool` : Return if the bot is ready in Discord
181
+ >
182
+ > > **Method** `is_ws_ratelimited(bot_name: str) -> bool` : Return if the bot is rate limited by Discord
183
+ >
184
+ > > **Method** `reload_commands(*bot_names: str) -> list[dict[str, str]]` : Reload all commands for each bot passed in parameters
185
+ >
186
+ > > **Method** `add_pyFile_commands(bot_name: str, file: str, setup_function: str = 'setup', reload_command: bool = True) -> dict[str, str]` : Add a python Discord command file to the bot. `file` parameter require a file path, absolute or not. By default, it automatically reloads commands on the bot after adding the file.
187
+ > >
188
+ > > ### _Blob_commands.py_
189
+ > > ```python
190
+ > > """
191
+ > > Discord command file example. Follow it !
192
+ > > This file doesn't have 'bot.run()' function. It's managed by Multibot instance.
193
+ > > """
194
+ > >
195
+ > > from discord import Bot, ApplicationContext, Message # autoaticly imported by importlib module
196
+ > >
197
+ > > # this function is called when the bot load a python file command. It is mandatory to have it with a bot parameter !
198
+ > > def setup(bot: Bot):
199
+ > > """
200
+ > > Function called by the process and give the bot instance.
201
+ > > This function is mandatory to have it with a bot parameter but can be renamed with 'setup_function' parameter in 'add_pyFile_commands' method.
202
+ > > Every discord command and discord event can be in this function, but you can make function and class outside setup function.
203
+ > > -> bot : Instance of your started bot.
204
+ > > """
205
+ > > @bot.command()
206
+ > > async def my_first_command(ctx: ApplicationContext):
207
+ > > await ctx.respond("It's my first command !")
208
+ > >
209
+ > > @bot.event
210
+ > > async def on_message(message: Message):
211
+ > > await message.add_reaction(emoji="😊")
212
+ > >
213
+ > > # You don't need 'bot.run(...)' here !
214
+ > > ```
215
+ >
216
+ > > **Method** `modify_pyFile_commands(bot_name: str, file: str, setup_function: str = 'setup') -> dict[str, str]` : Modify python discord command file and setup function. This method doesn't reload automatically commands on the bot. Use `reload_commands` after. `file` parameter require a file path, absolute or not.
217
+ >
218
+ > > **@property** `bot_count -> int` : Return the total number of bots
219
+ >
220
+ > > **@property** `started_bot_count -> int` : Return the total number of started bots
221
+ >
222
+ > > **@property** `shutdown_bot_count( -> int` : Return the total number of shutdown bots
223
+ >
224
+ > > **@property** `get_bots_name -> list[str]` : Return all bots name _(not real name of bots)_
225
+ ```python
226
+ from pycordViews.multibot import Multibot
227
+ from discord import Intents
228
+
229
+ if __name__ == '__main__': # Obligatory !
230
+ process = Multibot()
231
+
232
+ process.add_bot(bot_name="Blob", token="TOKEN FIRST BOT", intents=Intents.all())
233
+ process.add_bot(bot_name="Bee", token="TOKEN SECOND BOT", intents=Intents.all())
234
+
235
+ process.start_all()
236
+ process.add_pyFile_commands(bot_name='Blob', file='Blob_commands.py', reload_command=True)
237
+ process.add_pyFile_commands(bot_name='Bee', file='Bee_commandes.py', reload_command=True)
238
+
239
+ process.modify_pyFile_commands(bot_name='Blob', file='others_commands/Blob2_commands.py', setup_function='started_bot')
240
+ process.reload_commands('Blob')
241
+ ```
@@ -8,17 +8,15 @@ PycordViews.egg-info/dependency_links.txt
8
8
  PycordViews.egg-info/requires.txt
9
9
  PycordViews.egg-info/top_level.txt
10
10
  pycordViews/__init__.py
11
- pycordViews/typeViews.py
12
11
  pycordViews/menu/__init__.py
13
12
  pycordViews/menu/errors.py
14
13
  pycordViews/menu/menu.py
15
14
  pycordViews/menu/selectMenu.py
16
15
  pycordViews/multibot/__init__.py
16
+ pycordViews/multibot/bot.py
17
17
  pycordViews/multibot/errors.py
18
- pycordViews/multibot/process_for_bots.py
19
- pycordViews/multibot/process_messages.py
20
- pycordViews/multibot/runner.py
21
- pycordViews/multibot/start_multibot.py
18
+ pycordViews/multibot/multibot.py
19
+ pycordViews/multibot/process.py
22
20
  pycordViews/pagination/__init__.py
23
21
  pycordViews/pagination/errors.py
24
22
  pycordViews/pagination/pagination_view.py
@@ -30,11 +28,10 @@ pycordViews/menu/errors.py
30
28
  pycordViews/menu/menu.py
31
29
  pycordViews/menu/selectMenu.py
32
30
  pycordViews/multibot/__init__.py
31
+ pycordViews/multibot/bot.py
33
32
  pycordViews/multibot/errors.py
34
- pycordViews/multibot/process_for_bots.py
35
- pycordViews/multibot/process_messages.py
36
- pycordViews/multibot/runner.py
37
- pycordViews/multibot/start_multibot.py
33
+ pycordViews/multibot/multibot.py
34
+ pycordViews/multibot/process.py
38
35
  pycordViews/pagination/__init__.py
39
36
  pycordViews/pagination/errors.py
40
37
  pycordViews/pagination/pagination_view.py
@@ -0,0 +1 @@
1
+ immutable-Python-type