Skip to content

Commit

Permalink
✨ 为 Webhook 中的 source_guild 和 source_channel 添加单独的类 (#30)
Browse files Browse the repository at this point in the history
* 🐛 修复 event 文本获取错误 #19

* 🐛 修改 `Message._construct()` 的正则

* ✨ 为 Webhook 中的 source_guild 和 source_channel 添加单独的类

🐛 修正 source_guild, source_channel 的类型标注

* 🐛 为 `icon` 添加默认值

thanks, shoucandanghehe

Co-authored-by: 呵呵です <[email protected]>

---------

Co-authored-by: 呵呵です <[email protected]>
  • Loading branch information
Autuamn and shoucandanghehe authored Jun 21, 2024
1 parent d59670b commit 6200e83
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions nonebot/adapters/discord/api/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2298,6 +2298,19 @@ class VoiceRegion(BaseModel):

# Webhook
# see https://discord.com/developers/docs/resources/webhook
class SourceGuild(BaseModel):
# partial guild object
id: Snowflake
name: str
icon: Optional[str] = None


class SourceChannel(BaseModel):
# partial channel object
id: Snowflake
name: str


class Webhook(BaseModel):
"""Used to represent a webhook.
Expand All @@ -2312,9 +2325,8 @@ class Webhook(BaseModel):
avatar: Optional[str] = Field(...)
token: Missing[str] = UNSET
application_id: Optional[Snowflake] = Field(...)
source_guild: MissingOrNullable[Guild] = UNSET # partial guild object
# partial channel object
source_channel: MissingOrNullable[Channel] = UNSET
source_guild: Missing[SourceGuild] = UNSET
source_channel: Missing[SourceChannel] = UNSET
url: Missing[str] = UNSET


Expand Down

0 comments on commit 6200e83

Please sign in to comment.