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

Commit

Permalink
fixed listening_component issues and embeds
Browse files Browse the repository at this point in the history
  • Loading branch information
kvsxxx committed Sep 4, 2021
1 parent ae509c7 commit ce74625
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,20 @@ You can find more (and better) examples [here](https://github.com/discord-py-ui/

# Changelog

- <details>
<summary>4.2.5</summary>

## **Fixed**

- listening_components
> There was an issue with listening components that they needed two parameters but only one was passed
> Another issue was `TypeError: __init__() missing 1 required positional argument: 'custom_id'`?
- emebds
> there was an issue with sending embeds
</details>

- <details>
<summary>4.2.2</summary>

Expand Down
2 changes: 1 addition & 1 deletion discord_ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@


__title__ = "discord-ui"
__version__ = "4.2.4"
__version__ = "4.2.5"
4 changes: 2 additions & 2 deletions discord_ui/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,12 +1384,12 @@ def add_listening_component(self, callback, custom_id, messages=MISSING, users=M
"""
if not inspect.iscoroutinefunction(callback):
raise NoAsyncCallback()
if len(inspect.signature(callback).parameters) < 2:
if len(inspect.signature(callback).parameters) < 1:
raise MissingListenedComponentParameters()

if self.listening_components.get(custom_id) is None:
self.listening_components[custom_id] = []
self.listening_components[custom_id].append(ListeningComponent(callback, messages, users, check, custom_id))
self.listening_components[custom_id].append(ListeningComponent(callback, messages, users, component_type, check, custom_id))
def remove_listening_components(self, custom_id):
"""
Removes all listening components for a custom_id
Expand Down
2 changes: 1 addition & 1 deletion discord_ui/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, name, events, *args: object) -> None:
class MissingListenedComponentParameters(Exception):
"""This exception is thrown whenever a callback for a listening component is missing parameters"""
def __init__(self, *args: object) -> None:
super().__init__("Callback function for listening components needs to accept 2 parameters (the used component, the message)", *args)
super().__init__("Callback function for listening components needs to accept one parameter (the used component)", *args)
class CouldNotParse(Exception):
"""This exception is thrown whenever the libary was unable to parse the data with the given method"""
def __init__(self, data, type, method, *args: object) -> None:
Expand Down
2 changes: 1 addition & 1 deletion discord_ui/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def jsonifyMessage(content=MISSING, tts=False, embed: discord.Embed=MISSING, emb
payload["embeds"] = []
else:
embeds.append(embed)
if not isinstance(embeds):
if not all(isinstance(x) for x in embeds):
raise WrongType("embeds", embeds, 'list[discord.Embed]')
payload["embeds"] = [em.to_dict() for em in embeds]

Expand Down
6 changes: 2 additions & 4 deletions discord_ui/override.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ def override_dpy():
async def send(self: discord.TextChannel, content=None, **kwargs) -> Message:
channel_id = self.id if not isinstance(self, commands.Context) else self.channel.id

if isinstance(self, discord.Member) or isinstance(self, discord.User):
if self.dm_channel == None:
dm_chnl = await self.create_dm()
channel_id = dm_chnl.id
if isinstance(self, (discord.Member, discord.User)) and self.dm_channel is None:
channel_id = (await self.create_dm()).id

route = BetterRoute("POST", f"/channels/{channel_id}/messages")

Expand Down

0 comments on commit ce74625

Please sign in to comment.