Skip to content

Commit 67c9821

Browse files
committed
fix: subcommand checking in gateway.
1 parent 4163816 commit 67c9821

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ dist/
1111
.venv
1212
.vscode
1313
__pycache__
14-
.token
14+
15+
*.token

.token

Lines changed: 0 additions & 1 deletion
This file was deleted.

interactions/api/gateway.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -245,30 +245,30 @@ def handle_dispatch(self, event: str, data: dict) -> None:
245245
:type data: dict
246246
"""
247247

248-
def check_sub_command(self, option) -> dict:
248+
def check_sub_command(option) -> dict:
249249
_kwargs = dict()
250-
if "options" in option:
250+
if option._json.get("options"):
251251
if option["type"] == OptionType.SUB_COMMAND_GROUP:
252252
_kwargs["sub_command_group"] = option["name"]
253253
for group_option in option["options"]:
254254
_kwargs["sub_command"] = group_option["name"]
255-
if "options" in group_option:
255+
if group_option.get("options"):
256256
for sub_option in group_option["options"]:
257257
_kwargs[sub_option["name"]] = sub_option["value"]
258258
elif option["type"] == OptionType.SUB_COMMAND:
259259
_kwargs["sub_command"] = option["name"]
260260
for sub_option in option["options"]:
261261
_kwargs[sub_option["name"]] = sub_option["value"]
262262
else:
263-
_kwargs[option["name"]] = option["value"]
263+
_kwargs[option.name] = option.value
264264

265265
return _kwargs
266266

267-
def check_sub_auto(self, option) -> tuple:
268-
if "options" in option:
267+
def check_sub_auto(option) -> tuple:
268+
if option._json.get("options"):
269269
if option["type"] == OptionType.SUB_COMMAND_GROUP:
270270
for group_option in option["options"]:
271-
if "options" in group_option:
271+
if group_option.get("options"):
272272
for sub_option in option["options"]:
273273
if sub_option.get("focused"):
274274
return sub_option["name"], sub_option["value"]
@@ -310,15 +310,15 @@ def check_sub_auto(self, option) -> tuple:
310310
_kwargs: dict = dict()
311311
if data["type"] == InteractionType.APPLICATION_COMMAND:
312312
_name = context.data.name
313-
if hasattr(context.data, "options"):
313+
if context.data._json.get("options"):
314314
if context.data.options:
315315
for option in context.data.options:
316316
_kwargs.update(check_sub_command(option))
317317
elif data["type"] == InteractionType.MESSAGE_COMPONENT:
318318
_name = context.data.custom_id
319319
elif data["type"] == InteractionType.APPLICATION_COMMAND_AUTOCOMPLETE:
320320
_name = "autocomplete_"
321-
if hasattr(context.data, "options"):
321+
if context.data._json.get("options"):
322322
if context.data.options:
323323
for option in context.data.options:
324324
add_name, add_args = check_sub_auto(option)

simple_bot.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import interactions
22

3-
bot = interactions.Client(token=open(".token").read())
3+
bot = interactions.Client(token=open("bot.token").read())
44

55

66
@bot.event
@@ -11,7 +11,6 @@ async def on_ready():
1111
@bot.command(
1212
name="basic-command",
1313
description="ever wanted a basic command? well, here it is!",
14-
scope=852402668294766612,
1514
options=[
1615
interactions.Option(
1716
type=interactions.OptionType.STRING,
@@ -25,5 +24,5 @@ async def basic_command(ctx, option):
2524
await ctx.send(f"{option}")
2625

2726

28-
bot.load("simple_cog")
27+
# bot.load("simple_cog")
2928
bot.start()

0 commit comments

Comments
 (0)