Skip to content

Commit 71a5551

Browse files
authored
Merge pull request #226 from benwoo1110/small-fixing
Fix error when guild id is None.
2 parents a7f468b + f4cb20d commit 71a5551

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

discord_slash/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,6 +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 []
538539
if not all(isinstance(item, int) for item in guild_ids):
539540
raise error.IncorrectGuildIDType(
540541
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."
@@ -616,7 +617,8 @@ def add_subcommand(
616617
name = name or cmd.__name__
617618
name = name.lower()
618619
description = description or getdoc(cmd)
619-
if guild_ids and not all(isinstance(item, int) for item in guild_ids):
620+
guild_ids = guild_ids if guild_ids else []
621+
if not all(isinstance(item, int) for item in guild_ids):
620622
raise error.IncorrectGuildIDType(
621623
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."
622624
)

discord_slash/cog_ext.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,10 @@ def wrapper(cmd):
5858
else:
5959
opts = options
6060

61-
if guild_ids is not None:
62-
if not all(isinstance(item, int) for item in guild_ids):
63-
raise IncorrectGuildIDType(
64-
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 or cmd.__name__}' will be deactivated and broken until fixed."
65-
)
61+
if guild_ids and not all(isinstance(item, int) for item in guild_ids):
62+
raise IncorrectGuildIDType(
63+
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 or cmd.__name__}' will be deactivated and broken until fixed."
64+
)
6665

6766
_cmd = {
6867
"func": cmd,
@@ -147,11 +146,10 @@ def wrapper(cmd):
147146
else:
148147
opts = options
149148

150-
if guild_ids is not None:
151-
if not all(isinstance(item, int) for item in guild_ids):
152-
raise IncorrectGuildIDType(
153-
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 or cmd.__name__}' will be deactivated and broken until fixed."
154-
)
149+
if guild_ids and not all(isinstance(item, int) for item in guild_ids):
150+
raise IncorrectGuildIDType(
151+
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 or cmd.__name__}' will be deactivated and broken until fixed."
152+
)
155153

156154
_cmd = {
157155
"func": None,

0 commit comments

Comments
 (0)