DiscordPYComponents 0.2.11__tar.gz → 0.2.31__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 (19) hide show
  1. discordpycomponents-0.2.31/DiscordPYComponents.egg-info/PKG-INFO +64 -0
  2. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/DiscordPYComponents.egg-info/SOURCES.txt +1 -0
  3. discordpycomponents-0.2.31/PKG-INFO +64 -0
  4. discordpycomponents-0.2.31/README.md +56 -0
  5. discordpycomponents-0.2.31/py_components/ui.py +48 -0
  6. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/pyproject.toml +2 -1
  7. discordpycomponents-0.2.11/DiscordPYComponents.egg-info/PKG-INFO +0 -6
  8. discordpycomponents-0.2.11/PKG-INFO +0 -6
  9. discordpycomponents-0.2.11/py_components/ui.py +0 -28
  10. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/DiscordPYComponents.egg-info/dependency_links.txt +0 -0
  11. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/DiscordPYComponents.egg-info/requires.txt +0 -0
  12. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/DiscordPYComponents.egg-info/top_level.txt +0 -0
  13. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/py_components/__init__.py +0 -0
  14. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/py_components/components.py +0 -0
  15. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/py_components/enums.py +0 -0
  16. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/py_components/http.py +0 -0
  17. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/py_components/registry.py +0 -0
  18. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/py_components/view.py +0 -0
  19. {discordpycomponents-0.2.11 → discordpycomponents-0.2.31}/setup.cfg +0 -0
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: DiscordPYComponents
3
+ Version: 0.2.31
4
+ Summary: Discord Components V2 for discord.py
5
+ Author: 2gm49
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: aiohttp
8
+
9
+ # py-components
10
+
11
+ **Discord Components V2 for discord.py** — a lightweight helper library for building Discord UI components.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install py-components
17
+ ```
18
+
19
+ ## Requirements
20
+
21
+ - Python 3.10+
22
+ - discord.py
23
+ - aiohttp
24
+
25
+ ## Usage
26
+
27
+ ```python
28
+ from py_components import Button, Text, UI, ButtonStyle
29
+
30
+ @bot.command()
31
+ async def menu(ctx):
32
+ ui = UI(
33
+ Text("Choose an option:"),
34
+ Button("Confirm", custom_id="confirm", style=ButtonStyle.success),
35
+ Button("Cancel", custom_id="cancel", style=ButtonStyle.danger)
36
+ )
37
+ await ui.send(ctx)
38
+ ```
39
+
40
+ ### Button Styles
41
+
42
+ | Style | Colour |
43
+ |-------------------------|--------|
44
+ | `ButtonStyle.primary` | Blue |
45
+ | `ButtonStyle.secondary` | Grey |
46
+ | `ButtonStyle.success` | Green |
47
+ | `ButtonStyle.danger` | Red |
48
+
49
+ ### View & Callbacks
50
+
51
+ ```python
52
+ from py_components import View
53
+
54
+ view = View()
55
+
56
+ async def on_click(interaction):
57
+ await interaction.response.send_message("Clicked!")
58
+
59
+ view.add_button("Click Me", custom_id="btn", callback=on_click)
60
+ ```
61
+
62
+ ## License
63
+
64
+ MIT
@@ -1,3 +1,4 @@
1
+ README.md
1
2
  pyproject.toml
2
3
  DiscordPYComponents.egg-info/PKG-INFO
3
4
  DiscordPYComponents.egg-info/SOURCES.txt
@@ -0,0 +1,64 @@
1
+ Metadata-Version: 2.4
2
+ Name: DiscordPYComponents
3
+ Version: 0.2.31
4
+ Summary: Discord Components V2 for discord.py
5
+ Author: 2gm49
6
+ Description-Content-Type: text/markdown
7
+ Requires-Dist: aiohttp
8
+
9
+ # py-components
10
+
11
+ **Discord Components V2 for discord.py** — a lightweight helper library for building Discord UI components.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ pip install py-components
17
+ ```
18
+
19
+ ## Requirements
20
+
21
+ - Python 3.10+
22
+ - discord.py
23
+ - aiohttp
24
+
25
+ ## Usage
26
+
27
+ ```python
28
+ from py_components import Button, Text, UI, ButtonStyle
29
+
30
+ @bot.command()
31
+ async def menu(ctx):
32
+ ui = UI(
33
+ Text("Choose an option:"),
34
+ Button("Confirm", custom_id="confirm", style=ButtonStyle.success),
35
+ Button("Cancel", custom_id="cancel", style=ButtonStyle.danger)
36
+ )
37
+ await ui.send(ctx)
38
+ ```
39
+
40
+ ### Button Styles
41
+
42
+ | Style | Colour |
43
+ |-------------------------|--------|
44
+ | `ButtonStyle.primary` | Blue |
45
+ | `ButtonStyle.secondary` | Grey |
46
+ | `ButtonStyle.success` | Green |
47
+ | `ButtonStyle.danger` | Red |
48
+
49
+ ### View & Callbacks
50
+
51
+ ```python
52
+ from py_components import View
53
+
54
+ view = View()
55
+
56
+ async def on_click(interaction):
57
+ await interaction.response.send_message("Clicked!")
58
+
59
+ view.add_button("Click Me", custom_id="btn", callback=on_click)
60
+ ```
61
+
62
+ ## License
63
+
64
+ MIT
@@ -0,0 +1,56 @@
1
+ # py-components
2
+
3
+ **Discord Components V2 for discord.py** — a lightweight helper library for building Discord UI components.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install py-components
9
+ ```
10
+
11
+ ## Requirements
12
+
13
+ - Python 3.10+
14
+ - discord.py
15
+ - aiohttp
16
+
17
+ ## Usage
18
+
19
+ ```python
20
+ from py_components import Button, Text, UI, ButtonStyle
21
+
22
+ @bot.command()
23
+ async def menu(ctx):
24
+ ui = UI(
25
+ Text("Choose an option:"),
26
+ Button("Confirm", custom_id="confirm", style=ButtonStyle.success),
27
+ Button("Cancel", custom_id="cancel", style=ButtonStyle.danger)
28
+ )
29
+ await ui.send(ctx)
30
+ ```
31
+
32
+ ### Button Styles
33
+
34
+ | Style | Colour |
35
+ |-------------------------|--------|
36
+ | `ButtonStyle.primary` | Blue |
37
+ | `ButtonStyle.secondary` | Grey |
38
+ | `ButtonStyle.success` | Green |
39
+ | `ButtonStyle.danger` | Red |
40
+
41
+ ### View & Callbacks
42
+
43
+ ```python
44
+ from py_components import View
45
+
46
+ view = View()
47
+
48
+ async def on_click(interaction):
49
+ await interaction.response.send_message("Clicked!")
50
+
51
+ view.add_button("Click Me", custom_id="btn", callback=on_click)
52
+ ```
53
+
54
+ ## License
55
+
56
+ MIT
@@ -0,0 +1,48 @@
1
+ from .http import send_message
2
+ from .components import Button
3
+
4
+
5
+ class UI:
6
+ def __init__(self, *components):
7
+ self.components = list(components)
8
+
9
+ def add(self, component):
10
+ self.components.append(component)
11
+
12
+ def to_payload(self):
13
+ top_level = []
14
+ button_buffer = []
15
+
16
+ for c in self.components:
17
+ if isinstance(c, Button):
18
+ button_buffer.append(c.to_dict())
19
+ if len(button_buffer) == 5:
20
+ top_level.append({"type": 1, "components": button_buffer})
21
+ button_buffer = []
22
+ else:
23
+ if button_buffer:
24
+ top_level.append({"type": 1, "components": button_buffer})
25
+ button_buffer = []
26
+ top_level.append(c.to_dict())
27
+
28
+ if button_buffer:
29
+ top_level.append({"type": 1, "components": button_buffer})
30
+
31
+ return {
32
+ "flags": 1 << 15,
33
+ "components": [
34
+ {
35
+ "type": 17,
36
+ "components": top_level
37
+ }
38
+ ]
39
+ }
40
+
41
+ async def send(self, ctx):
42
+ token = ctx.bot.http.token
43
+ return await send_message(ctx.channel.id, token, self.to_payload())
44
+
45
+
46
+ async def send_ui(ctx, ui):
47
+ token = ctx.bot.http.token
48
+ return await send_message(ctx.channel.id, token, ui.to_payload())
@@ -1,9 +1,10 @@
1
1
  [project]
2
2
  name = "DiscordPYComponents"
3
- version = "0.2.11"
3
+ version = "0.2.31"
4
4
  description = "Discord Components V2 for discord.py"
5
5
  authors = [{name="2gm49"}]
6
6
  dependencies = ["aiohttp"]
7
+ readme = "README.md"
7
8
 
8
9
  [build-system]
9
10
  requires = ["setuptools"]
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: DiscordPYComponents
3
- Version: 0.2.11
4
- Summary: Discord Components V2 for discord.py
5
- Author: 2gm49
6
- Requires-Dist: aiohttp
@@ -1,6 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: DiscordPYComponents
3
- Version: 0.2.11
4
- Summary: Discord Components V2 for discord.py
5
- Author: 2gm49
6
- Requires-Dist: aiohttp
@@ -1,28 +0,0 @@
1
- from .http import send_message
2
-
3
- class UI:
4
- def __init__(self, *components):
5
- self.components = list(components)
6
-
7
- def add(self, component):
8
- self.components.append(component)
9
-
10
- def to_payload(self):
11
- return {
12
- "flags": 1 << 15,
13
- "components": [
14
- {
15
- "type": 17,
16
- "components": [c.to_dict() for c in self.components]
17
- }
18
- ]
19
- }
20
-
21
- async def send(self, ctx):
22
- token = ctx.bot.http.token
23
- return await send_message(ctx.channel.id, token, self.to_payload())
24
-
25
-
26
- async def send_ui(ctx, ui):
27
- token = ctx.bot.http.token
28
- return await send_message(ctx.channel.id, token, ui.to_payload())