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

Commit ce74625

Browse files
committed
fixed listening_component issues and embeds
1 parent ae509c7 commit ce74625

File tree

6 files changed

+21
-9
lines changed

6 files changed

+21
-9
lines changed

README.md

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

176176
# Changelog
177177

178+
- <details>
179+
<summary>4.2.5</summary>
180+
181+
## **Fixed**
182+
183+
- listening_components
184+
> There was an issue with listening components that they needed two parameters but only one was passed
185+
> Another issue was `TypeError: __init__() missing 1 required positional argument: 'custom_id'`?
186+
187+
- emebds
188+
> there was an issue with sending embeds
189+
190+
</details>
191+
178192
- <details>
179193
<summary>4.2.2</summary>
180194

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.2.4"
47+
__version__ = "4.2.5"

discord_ui/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,12 +1384,12 @@ def add_listening_component(self, callback, custom_id, messages=MISSING, users=M
13841384
"""
13851385
if not inspect.iscoroutinefunction(callback):
13861386
raise NoAsyncCallback()
1387-
if len(inspect.signature(callback).parameters) < 2:
1387+
if len(inspect.signature(callback).parameters) < 1:
13881388
raise MissingListenedComponentParameters()
13891389

13901390
if self.listening_components.get(custom_id) is None:
13911391
self.listening_components[custom_id] = []
1392-
self.listening_components[custom_id].append(ListeningComponent(callback, messages, users, check, custom_id))
1392+
self.listening_components[custom_id].append(ListeningComponent(callback, messages, users, component_type, check, custom_id))
13931393
def remove_listening_components(self, custom_id):
13941394
"""
13951395
Removes all listening components for a custom_id

discord_ui/errors.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __init__(self, name, events, *args: object) -> None:
2626
class MissingListenedComponentParameters(Exception):
2727
"""This exception is thrown whenever a callback for a listening component is missing parameters"""
2828
def __init__(self, *args: object) -> None:
29-
super().__init__("Callback function for listening components needs to accept 2 parameters (the used component, the message)", *args)
29+
super().__init__("Callback function for listening components needs to accept one parameter (the used component)", *args)
3030
class CouldNotParse(Exception):
3131
"""This exception is thrown whenever the libary was unable to parse the data with the given method"""
3232
def __init__(self, data, type, method, *args: object) -> None:

discord_ui/http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def jsonifyMessage(content=MISSING, tts=False, embed: discord.Embed=MISSING, emb
6666
payload["embeds"] = []
6767
else:
6868
embeds.append(embed)
69-
if not isinstance(embeds):
69+
if not all(isinstance(x) for x in embeds):
7070
raise WrongType("embeds", embeds, 'list[discord.Embed]')
7171
payload["embeds"] = [em.to_dict() for em in embeds]
7272

discord_ui/override.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ def override_dpy():
4141
async def send(self: discord.TextChannel, content=None, **kwargs) -> Message:
4242
channel_id = self.id if not isinstance(self, commands.Context) else self.channel.id
4343

44-
if isinstance(self, discord.Member) or isinstance(self, discord.User):
45-
if self.dm_channel == None:
46-
dm_chnl = await self.create_dm()
47-
channel_id = dm_chnl.id
44+
if isinstance(self, (discord.Member, discord.User)) and self.dm_channel is None:
45+
channel_id = (await self.create_dm()).id
4846

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

0 commit comments

Comments
 (0)