Repository navigation
✨ 补全缺失的API - #74
✨ 补全缺失的API#74
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive API coverage for Discord's Soundboard, Lobby, and several other missing endpoints. The implementation follows established patterns in the codebase for API client methods, model definitions, and type handling.
Changes:
- Added 7 Soundboard API endpoints with corresponding models (SoundboardSound, create/modify/list operations)
- Added 8 Lobby API endpoints with models (Lobby, LobbyMember, CRUD operations)
- Added 6 additional non-deprecated endpoints across Guild, Invite, Application Commands, and Entitlement resources
- Introduced reusable base classes for DRY principle (_SoundboardSoundsListResponse, _LobbyMemberWriteParamsBase)
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| nonebot/adapters/discord/api/types.py | Added LobbyMemberFlags enum and exported it |
| nonebot/adapters/discord/api/model.py | Added 20+ new models for Soundboard, Lobby, Guild incidents, and Invite features; includes base classes for code reuse |
| nonebot/adapters/discord/api/handle.py | Implemented 22 new API endpoint methods following consistent patterns with proper authorization, request building, and response validation |
| nonebot/adapters/discord/api/client.pyi | Auto-generated stub file updated with all new method signatures |
| nonebot/adapters/discord/api/init.py | Updated exports to include all new models and types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async def _api_batch_edit_application_command_permissions( | ||
| self: AdapterProtocol, | ||
| *, | ||
| application_id: SnowflakeType, | ||
| guild_id: SnowflakeType, | ||
| access_token: str, | ||
| permissions: list[GuildApplicationCommandPermissions], | ||
| ) -> None: |
There was a problem hiding this comment.
_api_batch_edit_application_command_permissions already takes application_id and guild_id, but also requires each element in permissions to be a GuildApplicationCommandPermissions (which has required application_id/guild_id). This duplicates data and can result in inconsistent payloads if the per-item IDs differ from the path params. Consider accepting a request model that only includes id + permissions, or override/strip application_id/guild_id when dumping the per-item objects so they always match the method arguments.
| headers = {"Authorization": self.get_authorization(bot.bot_info)} | ||
| request = Request( | ||
| headers=headers, | ||
| method="PUT", | ||
| url=self.base_url / f"invites/{invite_code}/target-users", | ||
| files={ | ||
| "target_users_file": ( | ||
| target_users_file.filename, | ||
| target_users_file.content, | ||
| ) | ||
| }, | ||
| ) |
There was a problem hiding this comment.
New multipart upload logic in _api_update_invite_target_users (building Request(files=...) with the target_users_file field) is untested. There are already tests validating request construction for other HandleMixin methods; adding a test that asserts the correct HTTP method/URL and multipart field name/body would help prevent regressions.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| emoji_id: Snowflake | None | ||
| emoji_name: str | None |
There was a problem hiding this comment.
emoji_id/emoji_name are required-but-nullable fields (no default, unioned with None). In this file, required nullable fields are typically marked with Field(...) (e.g., Guild.icon: str | None = Field(...)). Consider using Field(...) here as well to keep the schema style consistent and make the “required but may be null” intent explicit.
| emoji_id: Snowflake | None | |
| emoji_name: str | None | |
| emoji_id: Snowflake | None = Field(...) | |
| emoji_name: str | None = Field(...) |
| """ | ||
|
|
||
| id: Snowflake | ||
| metadata: dict[str, str] | None |
There was a problem hiding this comment.
metadata is defined as required-but-nullable (dict[str, str] | None with no default). Elsewhere in model.py, required nullable fields are usually declared with Field(...) to make the requirement explicit. Consider aligning this field with that pattern for consistency.
|
|
||
| id: Snowflake | ||
| application_id: Snowflake | ||
| metadata: dict[str, str] | None |
There was a problem hiding this comment.
metadata is defined as required-but-nullable (dict[str, str] | None with no default). Elsewhere in model.py, required nullable fields are usually declared with Field(...) to make the requirement explicit. Consider aligning this field with that pattern for consistency.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
变更内容
ListDefaultSoundboardSoundsResponse_SoundboardSoundsListResponse_LobbyMemberWriteParamsBaseGET /guilds/{guild.id}/roles/member-countsPUT /guilds/{guild.id}/incident-actionsGET /invites/{invite.code}/target-usersPUT /invites/{invite.code}/target-usersGET /invites/{invite.code}/target-users/job-statusPUT /applications/{application.id}/guilds/{guild.id}/commands/permissionsGuildIncidentsDataModifyGuildIncidentActionsParamsInviteTargetUsersJobStatus验证
uv run ruff check .uv run ruff format .uv run pytest -q(59 passed)