Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions interactions/client/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def __check_options(command, data):
if any(option not in _command_option_names for option in _data_option_names) or len(
_data_option_names
) != len(_command_option_names):
return False, command
return False

for option in command.get("options"):
for _option in data.get("options"):
Expand All @@ -206,7 +206,7 @@ def __check_options(command, data):
or not option.get(option_attr)
and _option.get(option_attr)
):
return False, command
return False
elif option_attr == "choices":
if not option.get("choices") or not _option.get("choices"):
continue
Expand All @@ -221,7 +221,7 @@ def __check_options(command, data):
if any(
_ not in _option_choice_names for _ in _data_choice_names
) or len(_data_choice_names) != len(_option_choice_names):
return False, command
return False

for choice in option.get("choices"):
for _choice in _option.get("choices"):
Expand All @@ -233,17 +233,17 @@ def __check_options(command, data):
or not choice.get(choice_attr)
and _choice.get(choice_attr)
):
return False, command
return False
elif choice.get(choice_attr) != _choice.get(
choice_attr
):
return False, command
return False
else:
continue

for i, __name in enumerate(_option_choice_names):
if _data_choice_names[i] != __name:
return False, command
return False

elif option_attr == "required":
if (
Expand All @@ -256,22 +256,21 @@ def __check_options(command, data):
elif option_attr == "options":
if not option.get(option_attr) and not _option.get("options"):
continue
_clean, _command = __check_options(option, _option)
_clean = __check_options(option, _option)
if not _clean:
return _clean, _command
return _clean

elif option.get(option_attr) != _option.get(option_attr):
return False, command
return False
else:
continue

return next(
(
(False, command)
False
for i, __name in enumerate(_command_option_names)
if _data_option_names[i] != __name
),
(True, command),
True,
)

for command in pool:
Expand Down Expand Up @@ -301,8 +300,7 @@ def __check_options(command, data):

elif command.get("options") and data.get("options"):

clean, _command = __check_options(command, data)

clean = __check_options(command, data)
if not clean:
return clean, _command

Expand Down