@@ -96,6 +96,28 @@ class BridgeExtCommand(Command):
96
96
def __init__ (self , func , ** kwargs ):
97
97
super ().__init__ (func , ** kwargs )
98
98
99
+ # TODO: v2.7: Remove backwards support for Option in bridge commands.
100
+ for name , option in self .params .items ():
101
+ if isinstance (option .annotation , Option ) and not isinstance (
102
+ option .annotation , BridgeOption
103
+ ):
104
+ # Warn not to do this
105
+ warn_deprecated (
106
+ "Using Option for bridge commands" ,
107
+ "BridgeOption" ,
108
+ "2.5" ,
109
+ "2.7" ,
110
+ reference = "https://github.com/Pycord-Development/pycord/pull/2417" ,
111
+ stacklevel = 6 ,
112
+ )
113
+ # Override the convert method of the parameter's annotated Option.
114
+ # We can use the convert method from BridgeOption, and bind "self"
115
+ # using a manual invocation of the descriptor protocol.
116
+ # Definitely not a good approach, but gets the job done until removal.
117
+ self .params [name ].annotation .convert = BridgeOption .convert .__get__ (
118
+ self .params [name ].annotation
119
+ )
120
+
99
121
async def dispatch_error (self , ctx : BridgeExtContext , error : Exception ) -> None :
100
122
await super ().dispatch_error (ctx , error )
101
123
ctx .bot .dispatch ("bridge_command_error" , ctx , error )
@@ -653,27 +675,3 @@ def decorator(func):
653
675
return func
654
676
655
677
return decorator
656
-
657
-
658
- # TODO: Fix this, it doesn't work if discord.Option is imported before discord.ext.bridge
659
-
660
-
661
- # TODO: 2.7: Remove this
662
- class BridgeOptionDeprecated (BridgeOption ):
663
- @staticmethod
664
- def _warn ():
665
- warn_deprecated (
666
- "Option" ,
667
- "BridgeOption" ,
668
- "2.5" ,
669
- "2.7" ,
670
- reference = "https://github.com/Pycord-Development/pycord/pull/2417" ,
671
- )
672
-
673
- def __init__ (self , * args , ** kwargs ):
674
- self ._warn ()
675
- super ().__init__ (* args , ** kwargs )
676
-
677
-
678
- discord .commands .options .Option = BridgeOptionDeprecated
679
- discord .Option = BridgeOptionDeprecated
0 commit comments