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

Commit 2a156a5

Browse files
author
kuso-senpai
committed
Version 1.0.3
Hash support added
1 parent 1832be7 commit 2a156a5

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,6 @@ LinkButton(url: str, label: str, emoji: discord.Emoji or str, new_line: bool, di
392392
- disabled: `bool`
393393
> Whether the button is disabled
394394
395-
- hash: `str`
396-
> The unique hash for the button
397-
398395
</details>
399396

400397

@@ -590,7 +587,11 @@ Added events for `client.wait_for` and `client.listen`
590587
<summary>on_button_press</summary>
591588

592589
```py
593-
(async) def listen(btn: PressedButton, msg: ResponseMessage):
590+
async def on_button(btn: PressedButton, msg: ResponseMessage):
591+
```
592+
593+
```py
594+
def check(btn: PressedButton, msg: ResponseMessage):
594595
```
595596

596597
This event will be dispatched whenever a button was pressed

discord_py_buttons/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .buttons import Button, LinkButton, Colors
33
from .receive import ResponseMessage, Message, PressedButton
44

5-
__version__ = "1.0.2"
5+
__version__ = "1.0.3"

discord_py_buttons/buttons.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,6 @@ class LinkButton():
230230
Whether a new line should be added before the button
231231
disabled: `bool`
232232
whether the button is clickable or not
233-
hash: `str`
234-
A unique hash for the button
235233
"""
236234
def __init__(self, url: str, label: str = None, emoji: Emoji or str = None, new_line: bool = False, disabled: bool = False) -> None:
237235
"""Creates a new LinkButton Object
@@ -368,10 +366,6 @@ def disabled(self) -> bool:
368366
@disabled.setter
369367
def disabled(self, val):
370368
self._json["disabled"] = val
371-
372-
@property
373-
def hash(self) -> str:
374-
return self._json.get('hash', None)
375369
#endregion
376370

377371
@staticmethod

discord_py_buttons/client.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,17 @@ async def send(self, channel: discord.TextChannel, content=None, *, tts=False,
128128
```py
129129
(Message)
130130
```
131-
T he sent message including buttons
131+
The sent message including buttons
132132
"""
133133
if type(channel) != discord.TextChannel:
134134
raise discord.InvalidArgument("Channel must be of type discord.TextChannel")
135135

136136
r = apiRequests.POST(self._discord.http.token, f"{apiRequests.url}/channels/{channel.id}/messages", data=apiRequests.jsonifyMessage(content, tts=tts, embed=embed, embeds=embeds, file=file, files=files, nonce=nonce, allowed_mentions=allowed_mentions, reference=reference, mention_author=mention_author, buttons=buttons))
137137
if r.status_code == 403:
138-
raise discord.Forbidden(r, "Got forbidden response")
138+
raise discord.ClientException(r.json(), "Got forbidden response")
139139
if r.status_code != 200:
140-
raise Exception(r.text)
141-
140+
raise Exception(r.json())
141+
142142
msg = await getResponseMessage(self._discord, r.json(), response=False)
143143

144144
if delete_after is not None:

discord_py_buttons/receive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def acknowledge(self):
343343
"type": 5
344344
})
345345
if r.status_code == 403:
346-
raise discord.Forbidden(r, "forbidden")
346+
raise discord.ClientException(r.json(), "forbidden")
347347

348348
def respond(self, content=None, *, tts=False, embed = None, embeds=None, file=None, files=None, nonce=None,
349349
allowed_mentions=None, reference=None, mention_author=None, buttons=None,
@@ -419,6 +419,6 @@ def respond(self, content=None, *, tts=False, embed = None, embeds=None, file=No
419419
"data": json
420420
})
421421
if r.status_code == 403:
422-
raise discord.Forbidden(r, "Forbidden")
422+
raise discord.ClientException(r.json(), "Forbidden")
423423
if r.status_code == 400:
424424
raise discord.ClientException(r.json(), "Error while sending message")

0 commit comments

Comments
 (0)