one can argue that it is intrinsically wrong for type hints (which are metadata, much like comments) to modify the program's behavior at all, but in reality nearly everyone is fine with it since it does makes sense in cases like this one and other libraries that parse structured input in similar ways.
I see, it's basically like the argparse "type" parameter. Isn't it convenient ? If you want to get the input unchanged you can always use str isn't it ?
View all comments
Show parent comment
3
u/Jonno_FTW hisss Nov 26 '22
Command handlers in discord.py will turn arguments into their type hinted type.
So if someone in the chat sends:
And the handler would look like:
In the function body, the
numwill be an int. You can also convert mentions of users to a discord user object.