Skip to content

Commit d0679c6

Browse files
authored
Merge pull request #295 from goverfl0w/pr-1
Hotfix type-checking
2 parents ffaadc4 + 3f316c4 commit d0679c6

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

discord_slash/client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,6 +1435,9 @@ async def _on_slash(self, to_use): # slash commands only.
14351435

14361436
selected_cmd = self.commands[to_use["data"]["name"]]
14371437

1438+
if type(selected_cmd) == dict:
1439+
return # this is context dict storage.
1440+
14381441
if selected_cmd._type != 1:
14391442
return # If its a menu, ignore.
14401443

discord_slash/cog_ext.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -205,14 +205,11 @@ def cog_context_menu(*, name: str, guild_ids: list = None, target: int = 1):
205205
"""
206206

207207
def wrapper(cmd):
208-
# _obj = self.add_slash_command(
209-
# cmd,
210-
# name,
211-
# "",
212-
# guild_ids
213-
# )
214-
215-
# This has to call both, as its a arg-less menu.
208+
if name == "context":
209+
raise IncorrectFormat(
210+
"The name 'context' can not be used to register as a cog context menu,"
211+
"as this conflicts with this lib's checks. Please use a different name instead."
212+
)
216213

217214
_cmd = {
218215
"default_permission": None,

discord_slash/context.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ def __init__(
653653
logger,
654654
):
655655
super().__init__(_http=_http, _json=_json, _discord=_discord, logger=logger)
656+
self.name = self.command = self.invoked_with = _json["data"]["name"] # This exists.
656657
self.context_type = _json["type"]
657658
self._resolved = self.data["resolved"] if "resolved" in self.data.keys() else None
658659
self.target_message = None

0 commit comments

Comments
 (0)