-
-
Notifications
You must be signed in to change notification settings - Fork 479
feat: Add support for editing application info and new fields #2994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Introduces the AppInfo.edit coroutine to allow editing application settings. Updates AppInfo and related types to support new fields such as bot, flags, event webhooks, integration_types_config, and approximate_user_authorization_count. Also refactors type hints and improves handling of optional fields for better API compatibility.
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/2994/head:pr-2994
git checkout pr-2994This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/2994/head |
Soheab
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also missing docs for the new attributes.
Introduces the AppInfo.edit() method to allow editing application settings, including new and previously missing fields such as icon, cover_image, tags, install_params, integration_types_config, flags, event_webhooks_url, event_webhooks_status, and event_webhooks_types. Also adds related helper classes and properties for handling these fields and updates the CHANGELOG accordingly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request adds an AppInfo.edit() method for editing application settings and includes missing fields from the Discord API to the AppInfo class.
Key Changes:
- Added
AppInfo.edit()method to modify application settings via the Discord API - Added new fields to
AppInfoincludingbot,event_webhooks_*,integration_types_config, andapproximate_user_authorization_count - Restructured TypedDict definitions in
discord/types/appinfo.pyto better reflect the Discord API structure - Added
IntegrationTypesConfighelper class for per-installation context configuration
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| discord/types/appinfo.py | Restructured TypedDict definitions, changed from User to PartialUser, moved many fields to NotRequired, and added new type aliases for application integration types |
| discord/http.py | Added edit_current_application() HTTP method to support the new edit functionality |
| discord/client.py | Removed workaround for missing rpc_origins field and cleaned up unused imports |
| discord/appinfo.py | Added new edit() method, new fields and properties, IntegrationTypesConfig class, and to_payload() method for AppInstallParams |
| CHANGELOG.md | Documented the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
Updated the AppInfo class to only accept bytes or None for the icon and cover_image parameters, removing support for str. This change clarifies the expected types and may prevent type-related errors.
| "approximate_user_authorization_count" | ||
| ) | ||
| raw_flags = data.get("flags") | ||
| self._flags: int | None = raw_flags if isinstance(raw_flags, int) else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the instance check for?
| .. versionadded:: 2.7 | ||
| flags: Optional[:class:`ApplicationFlags`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a property, which means it's self-documented AFAIK.
| ) | ||
|
|
||
| @property | ||
| def flags(self) -> ApplicationFlags | None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing versionadded string
| return None | ||
| return ApplicationFlags._from_value(self._flags) | ||
|
|
||
| async def edit( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing versionadded string
| Edit the current application's settings. | ||
| This method wraps the Edit Current Application endpoint and returns the updated application info. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary?
| Parameters | ||
| ---------- | ||
| description: Optional[:class:`str`] | ||
| The new application description. Pass ``None`` to clear. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"The new ... or ``None`` to clear" would be better wording, I think?
| owner_data = data.get("owner") | ||
| self.owner: User | None = ( | ||
| state.create_user(owner_data) if owner_data is not None else None | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is inconsistent with how it's done for the bot attribute below
| self.tags: list[str] | None = data.get("tags", []) | ||
| self.tags: list[str] = data.get("tags", []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it was None because it could have a value of null? Should it maybe do or [] to be sure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was any of this done?
| self.integration_types_config: dict[int, dict[str, object] | None] | None = ( | ||
| data.get("integration_types_config") | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason the IntegrationTypesConfig object below isn't used here?
Introduces the AppInfo.edit coroutine to allow editing application settings. Updates AppInfo and related types to support new fields such as bot, flags, event webhooks, integration_types_config, and approximate_user_authorization_count. Also refactors type hints and improves handling of optional fields for better API compatibility.
Summary
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.