Skip to content

Commit 3dbb62a

Browse files
SaucePlumGLGDLY
andauthored
feat: 增加删除频道成员api和修复帖子api的bug (#106)
* feat: 完善ws事件中Message数据的构建 * feat: 完善ws事件中User-Member数据的构建 * feat: 完善ws事件中Reaction、Audio、DirectMessage 以及 Forum(Thread类)数据的构建 feat: 去除EmbedField的value项(实际仅有name) * feat: 完善ws事件中监听文档并优化格式 refactor: 优化forum thread的事件数据名称 * fix: forum thread的事件数据名称更变后同步数据更改到其他文件 * refactor: 优化ext下的扩展工具 * refactor: 优化ext的convert_color模块 * refactor: 优化ext下的扩展工具 * refactor: 优化ext下的扩展工具 * docs: 修改一处表述不正确的地方 * feat: 修改一处表述不正确的地方 * fix: 帖子api中route方式错误的问题 * feat: 补齐频道成员中的删除频道成员api Co-authored-by: GLGDLY <[email protected]>
1 parent c16315a commit 3dbb62a

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

botpy/api.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,37 @@ async def get_guild_member(self, guild_id: str, user_id: str) -> user.Member:
194194
)
195195
return await self._http.request(route)
196196

197+
async def get_delete_member(
198+
self,
199+
guild_id: str,
200+
user_id: str,
201+
add_blacklist: bool = False,
202+
delete_history_msg_days: int = 0
203+
) -> str:
204+
"""
205+
删除频道成员
206+
207+
Args:
208+
guild_id (str): 频道ID
209+
user_id (str): 用户ID
210+
add_blacklist (bool): 是否同时添加黑名单
211+
delete_history_msg_days (int): 用于撤回该成员的消息,可以指定撤回消息的时间范围
212+
213+
Returns:
214+
成功执行返回`None`。成功执行返回空字符串
215+
"""
216+
# 注:消息撤回时间范围仅支持固定的天数:3,7,15,30。 特殊的时间范围:-1: 撤回全部消息。默认值为0不撤回任何消息。
217+
if delete_history_msg_days not in (3, 7, 15, 30, 0, -1):
218+
delete_history_msg_days = 0
219+
params = {'add_blacklist': str(add_blacklist).lower(), 'delete_history_msg_days': delete_history_msg_days}
220+
route = Route(
221+
"DELETE",
222+
"/guilds/{guild_id}/members/{user_id}",
223+
guild_id=guild_id,
224+
user_id=user_id,
225+
)
226+
return await self._http.request(route, params=params)
227+
197228
async def get_guild_members(self, guild_id: str, after: str = "0", limit: int = 1) -> List[user.Member]:
198229
"""
199230
获取成员列表。
@@ -1233,7 +1264,7 @@ async def post_thread(self, channel_id: str, title: str, content: str, format: f
12331264
"""
12341265
route = Route(
12351266
"PUT",
1236-
"PUT /channels/{channel_id}/threads",
1267+
"/channels/{channel_id}/threads",
12371268
channel_id=channel_id,
12381269
)
12391270

@@ -1252,6 +1283,6 @@ async def delete_thread(self, channel_id: str, thread_id: str) -> str:
12521283
成功返回空字符串。
12531284
"""
12541285
route = Route(
1255-
"DELETE", "DELETE /channels/{channel_id}/threads/{thread_id}", channel_id=channel_id, thread_id=thread_id
1286+
"DELETE", "/channels/{channel_id}/threads/{thread_id}", channel_id=channel_id, thread_id=thread_id
12561287
)
12571288
return await self._http.request(route)
File renamed without changes.

botpy/interaction.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ class Interaction:
77

88
def __init__(self, api: BotAPI, ctx: gateway.WsContext, data: interaction.InteractionPayload):
99
self._api = api
10-
# self._ctx = ctx
1110

1211
self.id = data.get("id")
1312
self.type = data.get("type")

0 commit comments

Comments
 (0)