Package: discord.py-listen-overloads
discord.py-listen-overloadsA stubs package fordiscord.pythat adds overloads to the@commands.Bot.listendecorator.Installationpython-mpipinstalldiscord.py-listen-overloadsOr the development version:python-mpipinstall"discord.py-listen-overloads @ git+https://github.com/Soheab/discord.py-listen-overloads"The versions depends on the latest stable release ofdiscord.py on PyPi.For example if the discord.py version on PyPi is2.5.1then running the first command will also installdiscord.py-listen-overloads==2.5.1and the development version will probably be2.6.0a.You can also install this stub for specific discord.py version by adding==the.version.herefrom version2.3.2to the first command.ExampleBefore:bot=commands.Bot(**kwargs)@bot.listen("on_typing")# no errorsasyncdefon_typing_event(channel):...@bot.listen("non_extisting_event")# no errorsasyncdefnon_extisting_event(random:bool):...reveal_type(on_typing_event)# Type of "on_typing_event" is "(channel: Unknown) -> Coroutine[Any, Any, None]"reveal_type(non_extisting_event)# Type of "non_extisting_event" is "(random: bool) -> Coroutine[Any, Any, None]"After:bot=commands.Bot(**kwargs)@bot.listen("on_typing")# <--# - Argument of type "(channel: Unknown) -> Coroutine[Any, Any, None]" cannot be assigned to parameter of type "TypingEvent"#  Type "(channel: Unknown) -> Coroutine[Any, Any, None]" cannot be assigned to type "(channel: Messageable, user: Member | User, when: datetime) -> Coroutine[Any, Any, Any]"#    Function accepts too many positional parameters; expected 1 but received 3asyncdefon_typing_event(channel):...@bot.listen("non_extisting_event")# <--# DISCLAIMER: the error can be different for you but similar.# - Argument of type "Literal['non_extisting_event']" cannot be assigned to parameter "name" of type "Literal['on_command', 'on_command_completion']" in function "listen"#  Type "Literal['non_extisting_event']" cannot be assigned to type "Literal['on_command', 'on_command_completion']"#    "Literal['non_extisting_event']" cannot be assigned to type "Literal['on_command']"#    "Literal['non_extisting_event']" cannot be assigned to type "Literal['on_command_completion']"asyncdefnon_extisting_event(random:bool):...reveal_type(on_typing_event)# Type of "on_typing_event" is "TypingEvent"So now we know that theon_typingis an existing event butnon_extisting_eventis not. that is takes 3 parameters and all their types. Here
is the correct correct version that shouldn't error:fromtypingimportAnyimportdatetime@bot.listen("on_typing")# no errorsasyncdefon_typing_event(channel:discord.abc.Messageable,user:discord.Member|discord.User,when:datetime.datetime)->Any:...Custom events are not supported unfortunately since that would defeat the whole point of such package.Why?Idk you're reading this.But like isn't cool to be able to use events without having to pull up docs for it?ContactYou can contact me on Discord atSoheab_or mention me in the discord.pyserver. Also welcome to open an issue/pull-request on this repo for anything.CreditsThis package is heavily inpsired bybryanforbes'spackage calleddiscord.py-stubs. It provides stubs for the whole library from versions 1.3.4.0 to the last 1.x release (1.7.3).