Skip to content

✨ 补全缺失的API - #74

Merged
shoucandanghehe merged 13 commits into
masterfrom
feat/soundboard-lobby-entitlement
Feb 21, 2026
Merged

shoucandanghehe merged 13 commits into
masterfrom
feat/soundboard-lobby-entitlement

Conversation

@shoucandanghehe

@shoucandanghehe shoucandanghehe commented Feb 20, 2026 •

Copy link
Copy Markdown
Member

变更内容

  • 补全 Soundboard 7 个 API 端点
  • 补全 Lobby 8 个 API 端点
  • 补全 Entitlement Get 端点
  • 新增并导出 ListDefaultSoundboardSoundsResponse
  • 抽取模型复用基类:
    • _SoundboardSoundsListResponse
    • _LobbyMemberWriteParamsBase
  • 补全额外缺失的 6 个非 deprecated 端点:
    • Guild
      • GET /guilds/{guild.id}/roles/member-counts
      • PUT /guilds/{guild.id}/incident-actions
    • Invite
      • GET /invites/{invite.code}/target-users
      • PUT /invites/{invite.code}/target-users
      • GET /invites/{invite.code}/target-users/job-status
    • Application Commands
      • PUT /applications/{application.id}/guilds/{guild.id}/commands/permissions
  • 新增并导出相关模型:
    • GuildIncidentsData
    • ModifyGuildIncidentActionsParams
    • InviteTargetUsersJobStatus

验证

  • uv run ruff check .
  • uv run ruff format .
  • uv run pytest -q(59 passed)

@shoucandanghehe shoucandanghehe changed the title ✨ 补全 Soundboard/Lobby/Entitlement API 并抽取模型复用基类 ✨ 补全 Soundboard/Lobby/Entitlement API Feb 20, 2026
@codecov

codecov Bot commented Feb 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.00000% with 68 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.96%. Comparing base (7da0685) to head (cd7ce19).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
nonebot/adapters/discord/api/handle.py 26.08% 68 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #74      +/-   ##
==========================================
- Coverage   75.22%   74.96%   -0.27%     
==========================================
  Files          33       34       +1     
  Lines        6890     7090     +200     
  Branches      362      362              
==========================================
+ Hits         5183     5315     +132     
- Misses       1641     1709      +68     
  Partials       66       66              
Flag Coverage Δ
unittests 74.96% <66.00%> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shoucandanghehe shoucandanghehe changed the title ✨ 补全 Soundboard/Lobby/Entitlement API ✨ 补全缺失的API Feb 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread nonebot/adapters/discord/api/model.py Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread nonebot/adapters/discord/api/types.py Resolved
Comment thread nonebot/adapters/discord/api/handle.py Resolved
Comment thread nonebot/adapters/discord/api/client.pyi Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread nonebot/adapters/discord/api/handle.py Outdated
Comment on lines +796 to +803
async def _api_batch_edit_application_command_permissions(
self: AdapterProtocol,
*,
application_id: SnowflakeType,
guild_id: SnowflakeType,
access_token: str,
permissions: list[GuildApplicationCommandPermissions],
) -> None:

Copilot AI Feb 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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.

Copilot uses AI. Check for mistakes.
Comment on lines +5528 to +5539
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,
)
},
)

Copilot AI Feb 20, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread nonebot/adapters/discord/api/model.py Outdated
Comment on lines +4718 to +4719
emoji_id: Snowflake | None
emoji_name: str | None

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
emoji_id: Snowflake | None
emoji_name: str | None
emoji_id: Snowflake | None = Field(...)
emoji_name: str | None = Field(...)

Copilot uses AI. Check for mistakes.
Comment thread nonebot/adapters/discord/api/model.py Outdated
"""

id: Snowflake
metadata: dict[str, str] | None

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread nonebot/adapters/discord/api/model.py Outdated

id: Snowflake
application_id: Snowflake
metadata: dict[str, str] | None

Copilot AI Feb 21, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@shoucandanghehe
shoucandanghehe merged commit cd87e1a into master Feb 21, 2026
19 of 22 checks passed
@shoucandanghehe
shoucandanghehe deleted the feat/soundboard-lobby-entitlement branch February 21, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants