Skip to content

Commit 5f44a5d

Browse files
Merge pull request #223 from LilSpazJoekp/is_fixes
Fix improper usage if `is`
2 parents 43e6a42 + 83dc3c5 commit 5f44a5d

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

discord_slash/client.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -535,8 +535,7 @@ def add_slash_command(
535535
"""
536536
name = name or cmd.__name__
537537
name = name.lower()
538-
guild_ids = guild_ids if guild_ids else []
539-
if not all(isinstance(item, int) for item in guild_ids) and guild_ids is not []:
538+
if not all(isinstance(item, int) for item in guild_ids):
540539
raise error.IncorrectGuildIDType(
541540
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."
542541
)
@@ -617,8 +616,7 @@ def add_subcommand(
617616
name = name or cmd.__name__
618617
name = name.lower()
619618
description = description or getdoc(cmd)
620-
guild_ids = guild_ids if guild_ids else []
621-
if not all(isinstance(item, int) for item in guild_ids) and guild_ids is not []:
619+
if guild_ids and not all(isinstance(item, int) for item in guild_ids):
622620
raise error.IncorrectGuildIDType(
623621
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."
624622
)

discord_slash/dpy_overrides.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ def get_component(self, custom_id: int) -> typing.Optional[dict]:
2323
"""
2424
for row in self.components:
2525
for component in row["components"]:
26-
if component["custom_id"] is custom_id:
26+
if component["custom_id"] == custom_id:
2727
return component
2828

2929

3030
def new_override(cls, *args, **kwargs):
31-
if cls is discord.Message:
31+
if isinstance(cls, discord.Message):
3232
return object.__new__(ComponentMessage)
3333
else:
3434
return object.__new__(cls)

discord_slash/utils/manage_components.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def spread_to_rows(*components, max_in_row=5) -> typing.List[dict]:
4747
rows = []
4848
button_row = []
4949
for component in list(components) + [None]:
50-
if component is not None and component["type"] is ComponentType.button:
50+
if component is not None and component["type"] == ComponentType.button:
5151
button_row.append(component)
5252

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

6363
if component is None:
6464
pass
65-
elif component["type"] is ComponentType.actionrow:
65+
elif component["type"] == ComponentType.actionrow:
6666
rows.append(component)
67-
elif component["type"] is ComponentType.select:
67+
elif component["type"] == ComponentType.select:
6868
rows.append(create_actionrow(component))
6969

7070
if len(rows) > 5:

0 commit comments

Comments
 (0)