Skip to content

Commit 0e651e4

Browse files
authored
Fixed HttpException when the custom_id is '0' (0)
when custom_id was 0 it was equal to None so it doesn't add the custom_id to the field
1 parent 5428b02 commit 0e651e4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

discord/components.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(self, label: str = None,
8585
self.custom_id = int(custom_id)
8686
else:
8787
self.custom_id = custom_id
88-
if self.custom_id and self.url:
88+
if self.custom_id is not None and self.url:
8989
raise URLAndCustomIDNotAlowed(self.custom_id)
9090
if label and len(label) > 80:
9191
raise InvalidArgument('The maximum length of Button-Labels\'s are 80; your one is %s long. (%s Characters to long)' % (len(label), len(label) - 80))
@@ -212,7 +212,7 @@ def set_style_if(self, check: Union[bool, typing.Callable], style: ButtonStyle,
212212

213213
def to_dict(self):
214214
base = {'type': 2, 'label': self.label, 'style': int(self.style), 'disabled': self.disabled}
215-
if self.custom_id:
215+
if self.custom_id is not None:
216216
base['custom_id'] = str(self.custom_id)
217217
elif self.url:
218218
base['url'] = self.url
@@ -317,7 +317,7 @@ class SelectMenu:
317317
318318
Parameters
319319
----------
320-
custom_id: Union[:class:`str`, :class:`int`]
320+
custom_id: str or int
321321
A developer-defined identifier for the :class:`SelectMenu`, max. 100 characters.
322322
options: List[:class:`SelectOption`]
323323
A :class:`list` of choices(:class:`SelectOption`) the :class:`SelectMenu` should have, max. 25.
@@ -390,7 +390,7 @@ def all_option_values(self):
390390
def to_dict(self) -> dict:
391391
base = {
392392
'type': 3,
393-
'custom_id': self.custom_id,
393+
'custom_id': str(self.custom_id),
394394
'options': [o.to_dict() for o in self.options if isinstance(o, SelectOption)],
395395
'placeholder': self.placeholder,
396396
'min_values': self.min_values,

0 commit comments

Comments
 (0)