Skip to content
This repository was archived by the owner on Dec 18, 2021. It is now read-only.

Commit 0d35369

Browse files
committed
pull
2 parents 7591f18 + 98f4f90 commit 0d35369

File tree

8 files changed

+123
-124
lines changed

8 files changed

+123
-124
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
[![PyPI version](https://badge.fury.io/py/discord-components.svg)](https://badge.fury.io/py/discord-components)
44
[![Documentation Status](https://readthedocs.org/projects/discord-components/badge/?version=latest)](https://discord-components.readthedocs.io/)
55

6-
unofficial library for discord components(on development)
6+
An unofficial library for Discord components. (on development)
77

88
- [GitHub](https://github.com/kiki7000/discord.py-components)
99
- [Discord Server](https://discord.gg/pKM6stqPxS)
1010

11-
## Install
11+
## Installation
1212
```sh
1313
pip install --upgrade discord-components
1414
```
@@ -53,9 +53,9 @@ bot.run("token")
5353
[The docs](https://discord-components.readthedocs.io/) can contain lot of spelling mistakes, grammar errors so if there is a problem please create an issue!
5454

5555
## Features
56-
+ Send, Edit discord components
56+
+ Send, edit Discord components.
5757
+ Get components interact event!
58-
+ Supports discord.ext.commands
58+
+ Supports discord.py command extension.
5959

6060
## Helps
6161
+ [Minibox](https://github.com/minibox24) - Button API explanation

discord_components/button.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class ButtonStyle:
14-
"""A class containing button styles"""
14+
"""Contains button styles."""
1515

1616
blue = 1
1717
gray = 2
@@ -22,7 +22,7 @@ class ButtonStyle:
2222

2323
@classmethod
2424
def randomColor(cls) -> int:
25-
"""Returns a random number between 1, 4
25+
"""Returns a random number between 1, 4.
2626
2727
:returns: :class:`int`
2828
"""
@@ -31,7 +31,7 @@ def randomColor(cls) -> int:
3131

3232
@classmethod
3333
def to_dict(cls) -> dict:
34-
"""Returns a dict containing style information
34+
"""Returns a dict containing style information.
3535
3636
:returns: :class:`dict`
3737
"""
@@ -46,24 +46,24 @@ def to_dict(cls) -> dict:
4646

4747

4848
class Button(Component):
49-
"""The button class
49+
"""The button class.
5050
5151
Parameters
5252
----------
5353
label: :class:`str`
54-
The bot's label
54+
The button's label.
5555
style: :class:`int`
56-
The bot's style (1 or more and 5 or less)
56+
The button's style. (1 ~ 5)
5757
id: :class:`str`
5858
The button's id.
59-
60-
If this was not passed as an argument when initailized, this value is random
59+
Defaults to :class:`ButtonStyle.gray`
6160
url: :class:`str`
62-
The button's hyperlink.
61+
The button's url.
6362
disabled: :class:`bool`
64-
bool: If the buttons is disabled
63+
bool: Indicates if the button is disabled.
64+
Defaults to ``True``.
6565
emoji: :class:`discord.PartialEmoji`
66-
The button's emoji
66+
The button's emoji.
6767
"""
6868

6969
__slots__ = ("_style", "_label", "_id", "_url", "_disabled", "_emoji")
@@ -79,14 +79,14 @@ def __init__(
7979
emoji=None,
8080
):
8181
if style == ButtonStyle.URL and not url:
82-
raise InvalidArgument("You must provide a URL when the style is URL")
82+
raise InvalidArgument("You must provide a URL when the style is set to URL.")
8383
if style == ButtonStyle.URL and id:
84-
raise InvalidArgument("You musn't use both id and url")
84+
raise InvalidArgument("Both ID and URL are set.")
8585
if not (1 <= style <= ButtonStyle.URL):
86-
raise InvalidArgument(f"Style must be in between 1, {ButtonStyle.URL}")
86+
raise InvalidArgument(f"Style must be between 1, {ButtonStyle.URL}.")
8787

8888
if not len(str(label)) and not emoji:
89-
raise InvalidArgument(f"Label or emoji must be given")
89+
raise InvalidArgument(f"Label or emoji must be given.")
9090

9191
self._style = style
9292
self._label = str(label)
@@ -109,7 +109,7 @@ def __init__(
109109

110110
def to_dict(self) -> dict:
111111
"""
112-
Converts the button information required for API request to dict and returns
112+
Gets the button information required for API request in dict form.
113113
114114
:returns: :class:`dict`
115115
"""
@@ -128,22 +128,22 @@ def to_dict(self) -> dict:
128128

129129
@property
130130
def style(self) -> int:
131-
""":class:`int`: The button's style (1 or more and 5 or less)"""
131+
""":class:`int`: The button's style. (1 ~ 5)"""
132132
return self._style
133133

134134
@property
135135
def label(self) -> str:
136-
""":class:`str`: The button's label"""
136+
""":class:`str`: The button's label."""
137137
return self._label
138138

139139
@property
140140
def id(self) -> str:
141-
""":class:`str`: The button's id."""
141+
""":class:`str`: The button's ID."""
142142
return self._id
143143

144144
@property
145145
def url(self) -> Optional[str]:
146-
"""Optional[:class:`str`]: The button's hyperlink.
146+
"""Optional[:class:`str`]: The button's URL.
147147
148148
.. note::
149149
If the button's style is not `5`(URL), this value is `None`
@@ -152,41 +152,41 @@ def url(self) -> Optional[str]:
152152

153153
@property
154154
def disabled(self) -> bool:
155-
""":class:`bool`: If the buttons is disabled"""
155+
""":class:`bool`: Indicates if the button is disabled."""
156156
return self._disabled
157157

158158
@property
159159
def emoji(self) -> PartialEmoji:
160-
""":class:`discord.PartialEmoji`: The button's emoji"""
160+
""":class:`discord.PartialEmoji`: The button's emoji."""
161161
return self._emoji
162162

163163
@style.setter
164164
def style(self, value: int):
165165
if value == ButtonStyle.URL and self.id:
166-
raise InvalidArgument("You musn't use both id and url")
166+
raise InvalidArgument("Both ID and URL are set.")
167167
if not (1 <= value <= ButtonStyle.URL):
168-
raise InvalidArgument(f"Style must be in between 1, {ButtonStyle.URL}")
168+
raise InvalidArgument(f"Style must be between 1, {ButtonStyle.URL}.")
169169

170170
self._style = value
171171

172172
@label.setter
173173
def label(self, value: str):
174174
if not len(str(value)) and not self.emoji:
175-
raise InvalidArgument("Label musn't be empty")
175+
raise InvalidArgument("Label should not be empty.")
176176

177177
self._label = str(value)
178178

179179
@url.setter
180180
def url(self, value: str):
181181
if value and self.style != ButtonStyle.URL:
182-
raise InvalidArgument("button style is not URL")
182+
raise InvalidArgument("Button style is not URL. You shouldn't provide URL.")
183183

184184
self._url = value
185185

186186
@id.setter
187187
def id(self, value: str):
188188
if self.style == ButtonStyle.URL:
189-
raise InvalidArgument("button style is URL")
189+
raise InvalidArgument("Button style is set to URL. You shouldn't provide ID.")
190190

191191
self._id = value
192192

@@ -203,14 +203,14 @@ def emoji(self, emoji: PartialEmoji):
203203

204204
@staticmethod
205205
def from_json(data):
206-
"""Create button instance from json
206+
"""Creates button instance from json.
207207
208208
:returns: :class:`~discord_components.Button`
209209
210210
Parameters
211211
----------
212212
data: :class:`dict`
213-
The json
213+
The json to construct button from.
214214
"""
215215

216216
emoji = data.get("emoji")

discord_components/client.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,26 @@
3030

3131

3232
class DiscordComponents:
33-
"""discord_components client
33+
"""Represents discord_components client.
3434
3535
Parameters
3636
----------
3737
bot: Union[:class:`discord.Client`, :class:`discord.ext.commands.Bot`]
38-
The bot
38+
Discord client to use.
3939
change_discord_methods: Optional[:class:`bool`]
40-
Default value set to True
4140
42-
Whether to change the methods of the discord module
41+
Whether to override the methods of the discord.py module.
4342
44-
If this is enabled, you can just use :class:`await <Messageable>.send`, :class:`await <Context>.send` as :class:`await <DiscordButton>.send_button_msg`, :class:`await <Message>.edit`, as :class:`await <DiscordComponents>.edit_component_msg`
45-
46-
Also you can use `on_interact`
43+
If this is enabled, you can just use
44+
:class:`await <Messageable>.send`, :class:`await <Context>.send` as :class:`await <DiscordButton>.send_button_msg`,
45+
:class:`await <Message>.edit`, as :class:`await <DiscordComponents>.edit_component_msg`
46+
Alternatively, `on_interact` can be used.
47+
Defaults to ``True``.
4748
4849
Attributes
4950
----------
5051
bot: Union[:class:`discord.Client`, :class:`discord.ext.commands.Bot`]
51-
The bot
52+
Discord client to use.
5253
"""
5354

5455
def __init__(self, bot, change_discord_methods=True):
@@ -58,7 +59,7 @@ def __init__(self, bot, change_discord_methods=True):
5859
self.change_discord_methods()
5960

6061
def change_discord_methods(self):
61-
"""A function that change the methods of the discord module"""
62+
"""Overrides the methods of the discord.py module."""
6263

6364
async def send_component_msg_prop(ctxorchannel, *args, **kwargs) -> Message:
6465
if isinstance(ctxorchannel, DContext):
@@ -100,16 +101,16 @@ async def send_component_msg(
100101
components=None,
101102
**options,
102103
) -> Message:
103-
"""A function that sends a message with components
104+
"""Sends a message with components.
104105
105106
:returns: :class:`discord.Message`
106107
107108
Parameters
108109
----------
109110
channel: :class:`discord.Messageable`
110-
The channel to send the message
111+
The channel to send the message.
111112
content: str
112-
The message's content
113+
The message's content.
113114
tts: :class:`bool`
114115
Indicates if the message should be sent using text-to-speech.
115116
embed: :class:`discord.Embed`
@@ -124,10 +125,10 @@ async def send_component_msg(
124125
If no object is passed at all then the defaults given by :attr:`discord.Client.allowed_mentions`
125126
are used instead.
126127
reference: Union[:class:`discord.Message`, :class:`discord.MessageReference`]
127-
A reference to the Message to which you are replying.
128+
A reference to the Message you are replying.
128129
components: List[Union[:class:`~discord_components.Component`, List[:class:`~discord_components.Component`]]]
129130
The components to send.
130-
If this is 2-dimensional array, an array is a line
131+
2-dimensional array can be used to send multiple lines of components.
131132
"""
132133
state = self.bot._get_state()
133134
channel = await channel._get_channel()
@@ -148,7 +149,7 @@ async def send_component_msg(
148149
reference = reference.to_message_reference_dict()
149150
except AttributeError:
150151
raise InvalidArgument(
151-
"reference parameter must be Message or MessageReference"
152+
"Reference parameter must be either Message or MessageReference."
152153
) from None
153154

154155
data = {
@@ -195,16 +196,16 @@ async def edit_component_msg(
195196
**options,
196197
):
197198

198-
"""A function that edits a message with components
199+
"""Edits a message with components.
199200
200201
:returns: :class:`discord_components.ComponentMessage`
201202
202203
Parameters
203204
----------
204205
channel: :class:`discord.Messageable`
205-
The channel to send the message
206+
The channel to send the message.
206207
content: str
207-
The message's content
208+
The message's content.
208209
tts: :class:`bool`
209210
Indicates if the message should be sent using text-to-speech.
210211
embed: :class:`discord.Embed`
@@ -220,7 +221,7 @@ async def edit_component_msg(
220221
are used instead.
221222
components: List[Union[:class:`~discord_components.Component`, List[:class:`~discord_components.Component`]]]
222223
The components to send.
223-
If this is 2-dimensional array, an array is a line
224+
2-dimensional array can be used to send multiple lines of components.
224225
"""
225226
state = self.bot._get_state()
226227

@@ -376,7 +377,7 @@ async def fetch_component_message(self, message) -> ComponentMessage:
376377
Parameters
377378
----------
378379
message: :class:`discord.Message`
379-
The message to convert
380+
The message to convert.
380381
"""
381382

382383
res = await self.bot.http.request(

0 commit comments

Comments
 (0)