Skip to content

Commit

Permalink
Merge pull request #223 from LilSpazJoekp/is_fixes
Browse files Browse the repository at this point in the history
Fix improper usage if `is`
  • Loading branch information
LordOfPolls authored Jun 23, 2021
2 parents 43e6a42 + 83dc3c5 commit 5f44a5d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
6 changes: 2 additions & 4 deletions discord_slash/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,7 @@ def add_slash_command(
"""
name = name or cmd.__name__
name = name.lower()
guild_ids = guild_ids if guild_ids else []
if not all(isinstance(item, int) for item in guild_ids) and guild_ids is not []:
if not all(isinstance(item, int) for item in guild_ids):
raise error.IncorrectGuildIDType(
f"The snowflake IDs {guild_ids} given are not a list of integers. Because of discord.py convention, please use integer IDs instead. Furthermore, the command '{name}' will be deactivated and broken until fixed."
)
Expand Down Expand Up @@ -617,8 +616,7 @@ def add_subcommand(
name = name or cmd.__name__
name = name.lower()
description = description or getdoc(cmd)
guild_ids = guild_ids if guild_ids else []
if not all(isinstance(item, int) for item in guild_ids) and guild_ids is not []:
if guild_ids and not all(isinstance(item, int) for item in guild_ids):
raise error.IncorrectGuildIDType(
f"The snowflake IDs {guild_ids} given are not a list of integers. Because of discord.py convention, please use integer IDs instead. Furthermore, the command '{name}' will be deactivated and broken until fixed."
)
Expand Down
4 changes: 2 additions & 2 deletions discord_slash/dpy_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ def get_component(self, custom_id: int) -> typing.Optional[dict]:
"""
for row in self.components:
for component in row["components"]:
if component["custom_id"] is custom_id:
if component["custom_id"] == custom_id:
return component


def new_override(cls, *args, **kwargs):
if cls is discord.Message:
if isinstance(cls, discord.Message):
return object.__new__(ComponentMessage)
else:
return object.__new__(cls)
Expand Down
6 changes: 3 additions & 3 deletions discord_slash/utils/manage_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def spread_to_rows(*components, max_in_row=5) -> typing.List[dict]:
rows = []
button_row = []
for component in list(components) + [None]:
if component is not None and component["type"] is ComponentType.button:
if component is not None and component["type"] == ComponentType.button:
button_row.append(component)

if len(button_row) == max_in_row:
Expand All @@ -62,9 +62,9 @@ def spread_to_rows(*components, max_in_row=5) -> typing.List[dict]:

if component is None:
pass
elif component["type"] is ComponentType.actionrow:
elif component["type"] == ComponentType.actionrow:
rows.append(component)
elif component["type"] is ComponentType.select:
elif component["type"] == ComponentType.select:
rows.append(create_actionrow(component))

if len(rows) > 5:
Expand Down

0 comments on commit 5f44a5d

Please sign in to comment.