feat: user apps - #1173
Conversation
I agree that the naming is weird, and it still may change. But personally I feel like naming things similarly but differently compared to the discord docs could just wind up adding unnecessary confusion to an already murky situation. Especially for people trying to search by specific keywords. |
|
This should have a way to automatically apply the same context to every single command. Like a bot default_contexts parameter. |
|
DM Permission requires a bit more work (shouldn't impact user-facing side, should not actually touch the API) but this was the quickest change to make it no longer touch the API |
this ends up not changing the logic
|
Going to go ahead and merge this now; I'm quite happy with the current state, and it's been long overdue. The only two remaining points are bot-wide defaults for |
Summary
discord/discord-api-docs@1eaa1af :woo:
(+ discord/discord-api-docs@462cddc)
Adds support for all things related to user-installed applications.
Some parts of the API aren't... great. Particularly some of the terminology/naming used is just confusing, and some parts are just completely nontransparent wrt. defaults and fields taking priority over others. It is what it is. /shrug
Issues
A probably non-exhaustive list of things that are still missing, could be improved, or are still uncertain.
API issues/unclear behavior:
contextsdoes not default to[0, 1, 2]on the api side, despite the documentation's claims.Application.install_paramsand.integration_types_configwork together. Right now it seems that the latter takes precedence over the former, if set. The dev portal sends both, looks like the API isn't doing any data shuffling here.Same thing goes forApplicationCommand.dm_permissionand.contexts. I'm not sure if we even want to deprecatedm_permissionright now.dm_permission; if both are set, we raise an exception. fwiw, if both are sent, the API preferscontextsoverdm_permissionWe might want to send a fixed default value forcontextsinstead of the currentnull, in case the API ever starts choosing for us.Theauthorizing_integration_ownersfield is weird, and its structure varies heavily based on configuration/context of commands and interactions. It already has a lengthy docstring, but it might be easier to instead split it into two separate properties and add some of our own fallbacks.AuthorizingIntegrationOwnersclass nowmessage.interaction_metadata.nameisn't documented - quote, "well it will still be there, but i dont want to officially document it". It's an optional field, so implementing it nonetheless is probably fine.Bugs/Missing features:
This needs feat(interactions): deserializechannelfrom data #1012, feat: deserialize dm/group channels in interactions #1233. Additionally, feat!: use the guild data provided on interactions #1236 for theguildattribute in guilds without the bot user. And then likely a ton of mocking forguild.meand several permissions-related methods. Still very uncertain about this part.TheGuildCommandInteractionannotation (which ends up settingdm_permission=False) silently conflicts with thecontextsparameter. See 3.contexts = InteractionContextTypes(guild=True)instead ofdm_permission = FalseQOL:
There are no utility decorators yet (like@commands.default_member_permissions()).@commands.integration_typesand@commands.contextsdecoratorsAllowing a command e.g. in all contexts is very verbose due tocontexts=[InteractionContextType.guild, ..., ...]. An.all()property on the two new enums could be useful, but also feels a bit weird. Might be resolved by 10. eventually..all()As mentioned, the official naming is weird. "interaction context" vs "installation context"/"integration type" is easy to mix up, and "integration type" in itself just seems... wrong. Considering renaming allintegration_typestoinstallation_types(the one combination of these words that the api docs don't use!).Interaction.guild, e.g. in ext.commands checks.TODOs in the code.Documentation:
The docs page still needs updates.integration_typesandcontexts, and removed thedm_permissionpartChecklist
pdm lintpdm pyright