Repository: Pycord-Development/pycord

Issue:
BridgeOption not raising BadArgument when conversion fails 
### Summary

BridgeOption does not raise the correct error when conversion fails for a built-in type.

### Reproduction Steps

Create a bridge command with an Option parameter of type `int` (other built-ins also work here).
Then use the prefixed command with an invalid value.
This will raise ValueError (in the case of int), when BadArgument should be raised instead.

### Minimal Reproducible Code

```python
@bot.bridge_command()
async def test(ctx, value: Option(int, name='value')):
    await ctx.respond(str(value))
```


### Expected Results

BadArgument to be raised when using `-test a`

### Actual Results

ValueError is raised

```
Traceback (most recent call last):
  File "site-packages\discord\ext\commands\converter.py", line 1071, in _actual_conversion
    return await converter.convert(ctx, argument)
  File "site-packages\discord\ext\bridge\core.py", line 161, in convert
    converted = converter(argument)
ValueError: invalid literal for int() with base 10: 'a'
```

### Intents

default + message_content

### System Information

- Python v3.10.1-final
- py-cord v2.0.0-beta
    - py-cord pkg_resources: v2.0.0b7
- aiohttp v3.8.1
- system info: Windows 10 10.0.19042

### Checklist

- [X] I have searched the open issues for duplicates.
- [X] I have shown the entire traceback, if possible.
- [X] I have removed my token from display, if visible.

### Additional Context

_No response_


Discussion:

Resolving patch:
diff --git a/discord/ext/bridge/core.py b/discord/ext/bridge/core.py
--- a/discord/ext/bridge/core.py
+++ b/discord/ext/bridge/core.py
@@ -41,6 +41,8 @@
 
 __all__ = ("BridgeCommand", "bridge_command", "BridgeExtCommand", "BridgeSlashCommand")
 
+from ..commands.converter import _convert_to_bool
+
 from ...utils import get
 
 
@@ -140,38 +142,40 @@ def attachment_callback(*args):  # pylint: disable=unused-argument
 
 class BridgeOption(Option, Converter):
     async def convert(self, ctx, argument) -> Any:
-        if self.converter is not None:
-            converted = await self.converter.convert(ctx, argument)
-        else:
-            mapping = {
-                SlashCommandOptionType.string: str,
-                SlashCommandOptionType.integer: int,
-                SlashCommandOptionType.boolean: bool,
-                SlashCommandOptionType.user: UserConverter,
-                SlashCommandOptionType.channel: GuildChannelConverter,
-                SlashCommandOptionType.role: RoleConverter,
-                SlashCommandOptionType.mentionable: MentionableConverter,
-                SlashCommandOptionType.number: float,
-                SlashCommandOptionType.attachment: attachment_callback,
-            }
-            converter = mapping[self.input_type]
-            if issubclass(converter, Converter):
-                converted = await converter().convert(ctx, argument)
-            else:
-                converted = converter(argument)
-        if self.choices:
-            choices_names = [choice.name for choice in self.choices]
-            if converted in choices_names:
-                converted = get(self.choices, name=converted).value
+        try:
+            if self.converter is not None:
+                converted = await self.converter.convert(ctx, argument)
             else:
-                choices = [choice.value for choice in self.choices]
-                if converted not in choices:
-                    print(self.choices)
-                    raise ValueError(
-                        f"{argument} is not a valid choice. Valid choices: {list(set(choices_names + choices))}"
-                    )
-
-        return converted
+                mapping = {
+                    SlashCommandOptionType.string: str,
+                    SlashCommandOptionType.integer: int,
+                    SlashCommandOptionType.boolean: lambda val: _convert_to_bool(str(val)),
+                    SlashCommandOptionType.user: UserConverter,
+                    SlashCommandOptionType.channel: GuildChannelConverter,
+                    SlashCommandOptionType.role: RoleConverter,
+                    SlashCommandOptionType.mentionable: MentionableConverter,
+                    SlashCommandOptionType.number: float,
+                    SlashCommandOptionType.attachment: attachment_callback,
+                }
+                converter = mapping[self.input_type]
+                if issubclass(converter, Converter):
+                    converted = await converter().convert(ctx, argument)
+                else:
+                    converted = converter(argument)
+            if self.choices:
+                choices_names = [choice.name for choice in self.choices]
+                if converted in choices_names:
+                    converted = get(self.choices, name=converted).value
+                else:
+                    choices = [choice.value for choice in self.choices]
+                    if converted not in choices:
+                        raise ValueError(
+                            f"{argument} is not a valid choice. Valid choices: {list(set(choices_names + choices))}"
+                        )
+
+            return converted
+        except ValueError as exc:
+            raise BadArgument() from exc
 
 
 discord.commands.options.Option = BridgeOption


Test patch: