Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit 0bd05dc

Browse files
author
kuso-senpai
committed
added python 3.6 < support
1 parent 3f836dc commit 0bd05dc

File tree

7 files changed

+43
-21
lines changed

7 files changed

+43
-21
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,19 @@ You can find more (and better) examples [here](https://github.com/discord-py-ui/
172172

173173
# Changelog
174174

175+
- <details>
176+
<summary>4.1.0</summary>
177+
178+
## **Added**
179+
- py 3.6 < support
180+
> You should be able to use this package with python 3.6 or newer
181+
182+
## **Fixed**
183+
- print
184+
> Forgot to remove print statements💀
185+
186+
</details>
187+
175188
- <details>
176189
<summary>4.0.4</summary>
177190

discord_ui/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@
4444

4545

4646
__title__ = "discord-ui"
47-
__version__ = "4.0.4"
47+
__version__ = "4.1.0"

discord_ui/client.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
import inspect
2121
import asyncio
2222
import contextlib
23-
from typing import Coroutine, Dict, List, Literal, Tuple, Union
23+
from typing import Coroutine, Dict, List, Tuple, Union
24+
try:
25+
from typing import Literal
26+
except:
27+
from typing_extensions import Literal
2428

2529
logging = setup_logger(__name__)
2630

@@ -1140,7 +1144,6 @@ async def _on_response(self, msg):
11401144
if data["type"] != 3:
11411145
return
11421146

1143-
print(data)
11441147
guild = None
11451148
if data.get("guild_id") is not None:
11461149
guild = cache_data(data["guild_id"], AdditionalType.GUILD, data, self._discord._connection)

discord_ui/cogs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
import asyncio
1111
import datetime
1212
import inspect
13-
from typing import Literal, Optional, Union
13+
from typing import Optional, Union
14+
try:
15+
from typing import Literal
16+
except:
17+
from typing_extensions import Literal
1418

1519
class WrongListener(errors.CheckFailure):
1620
"""Exception raised when a listening component received a component event that doesn't meet the check conditions

discord_ui/receive.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
from discord.ext.commands import Bot
21
from .errors import InvalidEvent, OutOfValidRange, WrongType
32
from .slash.errors import AlreadyDeferred, EphemeralDeletion
43
from .slash.types import ContextCommand, SlashCommand, SlashPermission, SlashSubcommand
@@ -11,7 +10,11 @@
1110
from discord.errors import HTTPException
1211
from discord.state import ConnectionState
1312

14-
import typing
13+
from typing import List, Union, Dict
14+
try:
15+
from typing import Literal
16+
except:
17+
from typing_extensions import Literal
1518

1619
logging = setup_logger("discord-ui")
1720

@@ -31,7 +34,7 @@ def __init__(self, state, data, user=MISSING, message=None) -> None:
3134
self._original_payload: dict = data
3235

3336
if user is not MISSING:
34-
self.author: typing.Union[discord.Member, discord.User] = user
37+
self.author: Union[discord.Member, discord.User] = user
3538
"""The user who created the interaction"""
3639
self.application_id: int = data["application_id"]
3740
"""The ID of the bot application"""
@@ -59,7 +62,7 @@ def guild(self) -> discord.Guild:
5962
"""
6063
return self._state._get_guild(self.guild_id)
6164
@property
62-
def channel(self) -> typing.Union[discord.TextChannel, discord.DMChannel]:
65+
def channel(self) -> Union[discord.TextChannel, discord.DMChannel]:
6366
"""The channel where the interaction was created
6467
6568
:type: :class:`discord.TextChannel` | :class:`discord.DMChannel`
@@ -94,7 +97,7 @@ async def defer(self, hidden=False):
9497

9598
async def respond(self, content=MISSING, *, tts=False, embed=MISSING, embeds=MISSING, file=MISSING, files=MISSING, nonce=MISSING,
9699
allowed_mentions=MISSING, mention_author=MISSING, components=MISSING, delete_after=MISSING, hidden=False,
97-
ninja_mode=False) -> typing.Union['Message', 'EphemeralMessage']:
100+
ninja_mode=False) -> Union['Message', 'EphemeralMessage']:
98101
"""Responds to the interaction
99102
100103
Parameters
@@ -202,7 +205,7 @@ async def respond(self, content=MISSING, *, tts=False, embed=MISSING, embeds=MIS
202205
return msg
203206

204207
async def send(self, content=None, *, tts=False, embed=MISSING, embeds=MISSING, file=MISSING, files=MISSING, nonce=MISSING,
205-
allowed_mentions=MISSING, mention_author=MISSING, components=MISSING, hidden=False) -> typing.Union['Message', 'EphemeralMessage']:
208+
allowed_mentions=MISSING, mention_author=MISSING, components=MISSING, hidden=False) -> Union['Message', 'EphemeralMessage']:
206209
"""Sends a message to the interaction using a webhook
207210
208211
Parameters
@@ -272,7 +275,7 @@ def __init__(self, data, user, s, msg, client) -> None:
272275
self._json = s.to_dict()
273276
self.bot: Bot = client
274277
#region selected_values
275-
self.selected_values: typing.List[SelectOption] = []
278+
self.selected_values: List[SelectOption] = []
276279
"""The list of values which were selected"""
277280
for val in data["data"]["values"]:
278281
for x in self.options:
@@ -303,7 +306,7 @@ def __init__(self, client, command: SlashCommand, data, user, args = None, guild
303306
"""The channel where the slash command was used"""
304307
self.guild_ids = guild_ids
305308
"""The ids of the guilds where the command is available"""
306-
self.args: typing.Dict[str, typing.Union[str, int, bool, discord.Member, discord.TextChannel, discord.Role, float]] = args
309+
self.args: Dict[str, Union[str, int, bool, discord.Member, discord.TextChannel, discord.Role, float]] = args
307310
"""The options that were received"""
308311
self.permissions: SlashPermission = guild_permissions.get(self.guild_id)
309312
"""The permissions for the guild"""
@@ -319,9 +322,9 @@ def __init__(self, client, command: ContextCommand, data, user, param, guild_ids
319322
ContextCommand.__init__(self, None, "EMPTY", guild_ids=guild_ids, guild_permissions=guild_permissions)
320323
self.bot: Bot = client
321324
self._json = command.to_dict()
322-
self.guild_ids: typing.List[int] = guild_ids
325+
self.guild_ids: List[int] = guild_ids
323326
"""The guild_ids where the command is available"""
324-
self.param: typing.Union[Message, discord.Member, discord.User] = param
327+
self.param: Union[Message, discord.Member, discord.User] = param
325328
"""The parameter that was received"""
326329
self.permissions: SlashPermission = guild_permissions.get(self.guild_id)
327330
"""The permissions for the guild"""
@@ -367,7 +370,7 @@ def __init__(self, *, state, channel, data):
367370

368371
self._state: ConnectionState = None
369372
super().__init__(state=state, channel=channel, data=data)
370-
self.components: typing.List[typing.Union[Button, LinkButton, SelectMenu]] = []
373+
self.components: List[Union[Button, LinkButton, SelectMenu]] = []
371374
"""The components in the message
372375
373376
:type: List[]:class:`~Button` | :class:`~LinkButton` | :class:`SelectMenu`]
@@ -377,7 +380,7 @@ def __init__(self, *, state, channel, data):
377380

378381
# region attributes
379382
@property
380-
def buttons(self) -> typing.List[typing.Union[Button, LinkButton]]:
383+
def buttons(self) -> List[Union[Button, LinkButton]]:
381384
"""The button components in the message
382385
383386
:type: List[:class:`~Button` | :class:`~LinkButton`]
@@ -386,7 +389,7 @@ def buttons(self) -> typing.List[typing.Union[Button, LinkButton]]:
386389
return [x for x in self.components if type(x) in [Button, LinkButton]]
387390
return []
388391
@property
389-
def select_menus(self) -> typing.List[SelectMenu]:
392+
def select_menus(self) -> List[SelectMenu]:
390393
"""The select menus components in the message
391394
392395
:type: List[:class:`~SelectMenu`]
@@ -514,7 +517,7 @@ def action_rows(self):
514517
515518
:type: List[:class:`~Button` | :class:`LinkButton` | :class:`SelectMenu`]
516519
"""
517-
rows: typing.List[typing.List[typing.Union[Button, LinkButton, SelectMenu]]] = []
520+
rows: List[List[Union[Button, LinkButton, SelectMenu]]] = []
518521

519522
c_row = []
520523
i = 0
@@ -528,7 +531,7 @@ def action_rows(self):
528531
rows.append(c_row)
529532
return rows
530533

531-
async def wait_for(self, event_name: typing.Literal["select", "button"], client, custom_id=MISSING, by=MISSING, check=lambda component: True, timeout=None) -> typing.Union[PressedButton, SelectedMenu]:
534+
async def wait_for(self, event_name: Literal["select", "button"], client, custom_id=MISSING, by=MISSING, check=lambda component: True, timeout=None) -> Union[PressedButton, SelectedMenu]:
532535
"""Waits for a message component to be invoked in this message
533536
534537
Parameters

discord_ui/slash/types.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ def name(self) -> str:
469469
return self._json["name"]
470470
@name.setter
471471
def name(self, value):
472-
print(value)
473472
if value in [None, MISSING]:
474473
raise InvalidArgument("You have to specify a name")
475474
if type(value) is not str:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def get_readme():
2626
long_description_content_type="text/markdown",
2727
url="https://github.com/discord-py-ui/discord-ui",
2828
packages=setuptools.find_packages(),
29-
python_requires='>=3.9' if 'READTHEDOCS' not in os.environ else None,
29+
python_requires='>=3.6',
3030
classifiers=[
3131
"Programming Language :: Python :: 3"
3232
]

0 commit comments

Comments
 (0)