Utilize SlashCommand fields for validation

This commit is contained in:
Zeva Rose 2022-05-01 09:19:42 -06:00
parent c260b93530
commit 334b578ae6

View file

@ -3,7 +3,6 @@ import asyncio
import logging
import platform
from io import BytesIO
from typing import get_type_hints
import git
import psutil
@ -115,17 +114,23 @@ class BotutilCog(Scale):
lambda x: x.resolved_name == command.resolved_name,
current_commands[module],
)
old_args = get_type_hints(old_command)
new_args = get_type_hints(command)
# Extract useful info
old_args = old_command.options
old_arg_names = [x.name for x in old_args]
new_args = command.options
new_arg_names = [x.name for x in new_args]
# Check if number arguments have changed
if len(old_args) != len(new_args):
self.bot.reload_extension(module)
reloaded.append(module)
elif any(x not in old_args for x in new_args) or any(
x not in new_args for x in old_args
elif any(x not in old_arg_names for x in new_arg_names) or any(
x not in new_arg_names for x in old_arg_names
):
self.bot.reload_extension(module)
reloaded.append(module)
elif any(new_args[x] != y for x, y in old_args):
elif any(new_args[idx].type != x.type for idx, x in enumerate(old_args)):
self.bot.reload_extension(module)
reloaded.append(module)