Skip to content

Commit

Permalink
Fixed HttpException when the custom_id is '0' (0)
Browse files Browse the repository at this point in the history
when custom_id was 0 it was equal to None so it doesn't add the custom_id to the field
  • Loading branch information
mccoderpy authored Aug 1, 2021
1 parent 5428b02 commit 0e651e4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions discord/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, label: str = None,
self.custom_id = int(custom_id)
else:
self.custom_id = custom_id
if self.custom_id and self.url:
if self.custom_id is not None and self.url:
raise URLAndCustomIDNotAlowed(self.custom_id)
if label and len(label) > 80:
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))
Expand Down Expand Up @@ -212,7 +212,7 @@ def set_style_if(self, check: Union[bool, typing.Callable], style: ButtonStyle,

def to_dict(self):
base = {'type': 2, 'label': self.label, 'style': int(self.style), 'disabled': self.disabled}
if self.custom_id:
if self.custom_id is not None:
base['custom_id'] = str(self.custom_id)
elif self.url:
base['url'] = self.url
Expand Down Expand Up @@ -317,7 +317,7 @@ class SelectMenu:
Parameters
----------
custom_id: Union[:class:`str`, :class:`int`]
custom_id: str or int
A developer-defined identifier for the :class:`SelectMenu`, max. 100 characters.
options: List[:class:`SelectOption`]
A :class:`list` of choices(:class:`SelectOption`) the :class:`SelectMenu` should have, max. 25.
Expand Down Expand Up @@ -390,7 +390,7 @@ def all_option_values(self):
def to_dict(self) -> dict:
base = {
'type': 3,
'custom_id': self.custom_id,
'custom_id': str(self.custom_id),
'options': [o.to_dict() for o in self.options if isinstance(o, SelectOption)],
'placeholder': self.placeholder,
'min_values': self.min_values,
Expand Down

0 comments on commit 0e651e4

Please sign in to comment.