mirror of
				https://github.com/Rapptz/discord.py.git
				synced 2025-10-30 21:12:58 +00:00 
			
		
		
		
	Suppress exceptions from invoking autocomplete
This commit is contained in:
		| @@ -887,11 +887,11 @@ class Command(Generic[GroupT, P, T]): | |||||||
|         predicates = getattr(param.autocomplete, '__discord_app_commands_checks__', []) |         predicates = getattr(param.autocomplete, '__discord_app_commands_checks__', []) | ||||||
|         if predicates: |         if predicates: | ||||||
|             try: |             try: | ||||||
|                 if not await async_all(f(interaction) for f in predicates): |                 passed = await async_all(f(interaction) for f in predicates) | ||||||
|                     if not interaction.response.is_done(): |  | ||||||
|                         await interaction.response.autocomplete([]) |  | ||||||
|                     return |  | ||||||
|             except Exception: |             except Exception: | ||||||
|  |                 passed = False | ||||||
|  |  | ||||||
|  |             if not passed: | ||||||
|                 if not interaction.response.is_done(): |                 if not interaction.response.is_done(): | ||||||
|                     await interaction.response.autocomplete([]) |                     await interaction.response.autocomplete([]) | ||||||
|                 return |                 return | ||||||
|   | |||||||
| @@ -1235,7 +1235,13 @@ class CommandTree(Generic[ClientT]): | |||||||
|             focused = next((opt['name'] for opt in options if opt.get('focused')), None) |             focused = next((opt['name'] for opt in options if opt.get('focused')), None) | ||||||
|             if focused is None: |             if focused is None: | ||||||
|                 raise AppCommandError('This should not happen, but there is no focused element. This is a Discord bug.') |                 raise AppCommandError('This should not happen, but there is no focused element. This is a Discord bug.') | ||||||
|             await command._invoke_autocomplete(interaction, focused, namespace) |  | ||||||
|  |             try: | ||||||
|  |                 await command._invoke_autocomplete(interaction, focused, namespace) | ||||||
|  |             except Exception: | ||||||
|  |                 # Suppress exception since it can't be handled anyway. | ||||||
|  |                 pass | ||||||
|  |  | ||||||
|             return |             return | ||||||
|  |  | ||||||
|         try: |         try: | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user