sync_commands doesnt raise error
Lumabots opened this issue · 4 comments
Summary
sync_commands doesnt raise error when a list is passed
Reproduction Steps
use the sync_command and pass command with an error as arg and not only await bot.sync_commands()
the issue is when the command should not be able to be register because there is an issue its still registering it without raising error. If a command doesnt have error its working fine
Minimal Reproducible Code
async def on_connect(bot: discord.Client):
async def sync_command(command):
nonlocal num_not_loaded
try:
await bot.sync_commands([command])
except Exception as e:
logger.critical(f"Error loading command {command.name}: {e}")
Expected Results
it should raise an error like when using await bot.sync_commands()
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In 2.options.5.name: String value did not match validation regex.
Actual Results
no error raise command but command will not be register (doesnt appear on discord)
Intents
all
System Information
py-cord 2.5.0
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Additional Context
No response
you're using try-except...
you're using try-except...
yeah and the except is not trigger
Update:
it raise an error if im loading the command but not if am loading a subcommand etc.
for command in bot._pending_application_commands:
await sync_command(command)
continue
if isinstance(command, discord.SlashCommandGroup):
for sub_command in command.subcommands:
if isinstance(sub_command, discord.SlashCommandGroup):
for sub_sub_command in sub_command.subcommands:
await sync_command(sub_sub_command)
else:
await sync_command(sub_command)
else:
await sync_command(command)
here with the continue is raise the error :
Error loading command bot: 400 Bad Request (error code: 50035): Invalid Form Body
and without the continue, it does not raise anything
So to summarise it load the subcommand etc but does not raise error, while if i load the command, it raise the error. Why does the subcommand doesnt raise error while it still loading it (if subcommand without error it appear on discord, if subcommand with error, doesnt raise anythign but command doesnt appear on discord)
Anyways I think syncommand is just not mean to be used like that