@zhin.js/adapter-discord 1.0.63 → 1.0.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/lib/adapter.d.ts +0 -1
- package/lib/adapter.d.ts.map +1 -1
- package/lib/adapter.js +1 -226
- package/lib/adapter.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +193 -2
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/skills/discord/SKILL.md +55 -3
- package/src/adapter.ts +0 -215
- package/src/index.ts +201 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @zhin.js/adapter-discord
|
|
2
2
|
|
|
3
|
+
## 1.0.66
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- zhin.js@1.0.61
|
|
8
|
+
- @zhin.js/http@1.0.56
|
|
9
|
+
|
|
10
|
+
## 1.0.65
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 5073d4c: chore: chore: update TypeScript version to ^5.9.3 across all plugins and packages
|
|
15
|
+
feat: enhance ai-text-as-image output registration with off handler for cleanup
|
|
16
|
+
fix: remove unnecessary logging in ensureBuiltinFontsCached function
|
|
17
|
+
refactor: simplify action handlers in html-renderer tools
|
|
18
|
+
chore: add README files for queue-sandbox-poc and event-delivery packages
|
|
19
|
+
chore: adjust pnpm workspace configuration to exclude games directory
|
|
20
|
+
chore: update tsconfig to include plugins directory for TypeScript compilation
|
|
21
|
+
- Updated dependencies [5073d4c]
|
|
22
|
+
- zhin.js@1.0.60
|
|
23
|
+
- @zhin.js/http@1.0.55
|
|
24
|
+
|
|
25
|
+
## 1.0.64
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- c212bf7: fix: 适配器优化
|
|
30
|
+
- Updated dependencies [c212bf7]
|
|
31
|
+
- zhin.js@1.0.59
|
|
32
|
+
- @zhin.js/http@1.0.54
|
|
33
|
+
|
|
3
34
|
## 1.0.63
|
|
4
35
|
|
|
5
36
|
### Patch Changes
|
package/lib/adapter.d.ts
CHANGED
|
@@ -15,6 +15,5 @@ export declare class DiscordAdapter extends Adapter<DiscordBotLike> {
|
|
|
15
15
|
listMembers(botId: string, sceneId: string): Promise<any[]>;
|
|
16
16
|
getGroupInfo(botId: string, sceneId: string): Promise<any>;
|
|
17
17
|
start(): Promise<void>;
|
|
18
|
-
private registerDiscordPlatformTools;
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=adapter.d.ts.map
|
package/lib/adapter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,MAAM,
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,OAAO,EACP,MAAM,EACP,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,KAAK,EACV,gBAAgB,EAGjB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,cAAc,GAAG,UAAU,GAAG,sBAAsB,CAAC;AAMjE,qBAAa,cAAe,SAAQ,OAAO,CAAC,cAAc,CAAC;;gBAG7C,MAAM,EAAE,MAAM;IAI1B,SAAS,CAAC,MAAM,EAAE,gBAAgB,GAAG,cAAc;IAiB7C,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAOzD,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;IAOzE,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAO1D,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,SAAM;IAOzE,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOlF,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAO1C,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAO3C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAW7B"}
|
package/lib/adapter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adapter,
|
|
1
|
+
import { Adapter, } from "zhin.js";
|
|
2
2
|
import { DiscordBot } from "./bot.js";
|
|
3
3
|
import { DiscordInteractionsBot } from "./bot-interactions.js";
|
|
4
4
|
function isGatewayBot(bot) {
|
|
@@ -84,232 +84,7 @@ export class DiscordAdapter extends Adapter {
|
|
|
84
84
|
this.plugin.useContext("router", (router) => {
|
|
85
85
|
this.#router = router;
|
|
86
86
|
});
|
|
87
|
-
this.registerDiscordPlatformTools();
|
|
88
|
-
const groupTools = createGroupManagementTools(this, this.name);
|
|
89
|
-
groupTools.forEach((t) => this.addTool(t));
|
|
90
87
|
await super.start();
|
|
91
88
|
}
|
|
92
|
-
registerDiscordPlatformTools() {
|
|
93
|
-
this.addTool({
|
|
94
|
-
name: "discord_add_role",
|
|
95
|
-
description: "给成员添加 Discord 角色",
|
|
96
|
-
parameters: {
|
|
97
|
-
type: "object",
|
|
98
|
-
properties: {
|
|
99
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
100
|
-
guild_id: { type: "string", description: "服务器 ID" },
|
|
101
|
-
user_id: { type: "string", description: "用户 ID" },
|
|
102
|
-
role_id: { type: "string", description: "角色 ID" },
|
|
103
|
-
},
|
|
104
|
-
required: ["bot", "guild_id", "user_id", "role_id"],
|
|
105
|
-
},
|
|
106
|
-
platforms: ["discord"],
|
|
107
|
-
scopes: ["channel"],
|
|
108
|
-
permissionLevel: "group_admin",
|
|
109
|
-
execute: async (args) => {
|
|
110
|
-
const { bot: botId, guild_id, user_id, role_id } = args;
|
|
111
|
-
const bot = this.bots.get(botId);
|
|
112
|
-
if (!bot)
|
|
113
|
-
throw new Error(`Bot ${botId} 不存在`);
|
|
114
|
-
if (!isGatewayBot(bot))
|
|
115
|
-
throw new Error("此工具仅支持 connection: gateway");
|
|
116
|
-
const success = await bot.addRole(guild_id, user_id, role_id);
|
|
117
|
-
return { success, message: success ? `已给用户 ${user_id} 添加角色` : "操作失败" };
|
|
118
|
-
},
|
|
119
|
-
});
|
|
120
|
-
this.addTool({
|
|
121
|
-
name: "discord_remove_role",
|
|
122
|
-
description: "移除成员的 Discord 角色",
|
|
123
|
-
parameters: {
|
|
124
|
-
type: "object",
|
|
125
|
-
properties: {
|
|
126
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
127
|
-
guild_id: { type: "string", description: "服务器 ID" },
|
|
128
|
-
user_id: { type: "string", description: "用户 ID" },
|
|
129
|
-
role_id: { type: "string", description: "角色 ID" },
|
|
130
|
-
},
|
|
131
|
-
required: ["bot", "guild_id", "user_id", "role_id"],
|
|
132
|
-
},
|
|
133
|
-
platforms: ["discord"],
|
|
134
|
-
scopes: ["channel"],
|
|
135
|
-
permissionLevel: "group_admin",
|
|
136
|
-
execute: async (args) => {
|
|
137
|
-
const { bot: botId, guild_id, user_id, role_id } = args;
|
|
138
|
-
const bot = this.bots.get(botId);
|
|
139
|
-
if (!bot)
|
|
140
|
-
throw new Error(`Bot ${botId} 不存在`);
|
|
141
|
-
if (!isGatewayBot(bot))
|
|
142
|
-
throw new Error("此工具仅支持 connection: gateway");
|
|
143
|
-
const success = await bot.removeRole(guild_id, user_id, role_id);
|
|
144
|
-
return { success, message: success ? `已移除用户 ${user_id} 的角色` : "操作失败" };
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
this.addTool({
|
|
148
|
-
name: "discord_list_roles",
|
|
149
|
-
description: "获取 Discord 服务器角色列表",
|
|
150
|
-
parameters: {
|
|
151
|
-
type: "object",
|
|
152
|
-
properties: {
|
|
153
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
154
|
-
guild_id: { type: "string", description: "服务器 ID" },
|
|
155
|
-
},
|
|
156
|
-
required: ["bot", "guild_id"],
|
|
157
|
-
},
|
|
158
|
-
platforms: ["discord"],
|
|
159
|
-
scopes: ["channel"],
|
|
160
|
-
permissionLevel: "user",
|
|
161
|
-
execute: async (args) => {
|
|
162
|
-
const { bot: botId, guild_id } = args;
|
|
163
|
-
const bot = this.bots.get(botId);
|
|
164
|
-
if (!bot)
|
|
165
|
-
throw new Error(`Bot ${botId} 不存在`);
|
|
166
|
-
if (!isGatewayBot(bot))
|
|
167
|
-
throw new Error("此工具仅支持 connection: gateway");
|
|
168
|
-
const roles = await bot.getRoles(guild_id);
|
|
169
|
-
return { roles, count: roles.length };
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
this.addTool({
|
|
173
|
-
name: "discord_create_thread",
|
|
174
|
-
description: "在 Discord 频道中创建帖子/子线程",
|
|
175
|
-
parameters: {
|
|
176
|
-
type: "object",
|
|
177
|
-
properties: {
|
|
178
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
179
|
-
channel_id: { type: "string", description: "频道 ID" },
|
|
180
|
-
name: { type: "string", description: "帖子标题" },
|
|
181
|
-
message_id: { type: "string", description: "基于某条消息创建(可选)" },
|
|
182
|
-
auto_archive_duration: {
|
|
183
|
-
type: "number",
|
|
184
|
-
description: "自动归档时间(分钟:60/1440/4320/10080)",
|
|
185
|
-
},
|
|
186
|
-
},
|
|
187
|
-
required: ["bot", "channel_id", "name"],
|
|
188
|
-
},
|
|
189
|
-
platforms: ["discord"],
|
|
190
|
-
scopes: ["channel"],
|
|
191
|
-
permissionLevel: "user",
|
|
192
|
-
execute: async (args) => {
|
|
193
|
-
const { bot: botId, channel_id, name, message_id, auto_archive_duration } = args;
|
|
194
|
-
const bot = this.bots.get(botId);
|
|
195
|
-
if (!bot)
|
|
196
|
-
throw new Error(`Bot ${botId} 不存在`);
|
|
197
|
-
if (!isGatewayBot(bot))
|
|
198
|
-
throw new Error("此工具仅支持 connection: gateway");
|
|
199
|
-
const thread = await bot.createThread(channel_id, name, message_id, auto_archive_duration);
|
|
200
|
-
return { success: true, thread_id: thread.id, message: `帖子 "${name}" 已创建` };
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
this.addTool({
|
|
204
|
-
name: "discord_react",
|
|
205
|
-
description: "对 Discord 消息添加表情反应",
|
|
206
|
-
parameters: {
|
|
207
|
-
type: "object",
|
|
208
|
-
properties: {
|
|
209
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
210
|
-
channel_id: { type: "string", description: "频道 ID" },
|
|
211
|
-
message_id: { type: "string", description: "消息 ID" },
|
|
212
|
-
emoji: {
|
|
213
|
-
type: "string",
|
|
214
|
-
description: "表情(Unicode 表情或自定义表情如 <:name:id>)",
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
required: ["bot", "channel_id", "message_id", "emoji"],
|
|
218
|
-
},
|
|
219
|
-
platforms: ["discord"],
|
|
220
|
-
scopes: ["channel", "private"],
|
|
221
|
-
permissionLevel: "user",
|
|
222
|
-
execute: async (args) => {
|
|
223
|
-
const { bot: botId, channel_id, message_id, emoji } = args;
|
|
224
|
-
const bot = this.bots.get(botId);
|
|
225
|
-
if (!bot)
|
|
226
|
-
throw new Error(`Bot ${botId} 不存在`);
|
|
227
|
-
if (!isGatewayBot(bot))
|
|
228
|
-
throw new Error("此工具仅支持 connection: gateway");
|
|
229
|
-
await bot.addReaction(channel_id, message_id, emoji);
|
|
230
|
-
return { success: true, message: `已添加反应 ${emoji}` };
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
this.addTool({
|
|
234
|
-
name: "discord_send_embed",
|
|
235
|
-
description: "发送 Discord 富文本嵌入消息(Embed)",
|
|
236
|
-
parameters: {
|
|
237
|
-
type: "object",
|
|
238
|
-
properties: {
|
|
239
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
240
|
-
channel_id: { type: "string", description: "频道 ID" },
|
|
241
|
-
title: { type: "string", description: "Embed 标题" },
|
|
242
|
-
description: { type: "string", description: "Embed 描述" },
|
|
243
|
-
color: { type: "number", description: "颜色值(十进制,如 0x00ff00 = 65280)" },
|
|
244
|
-
url: { type: "string", description: "标题链接(可选)" },
|
|
245
|
-
fields: {
|
|
246
|
-
type: "string",
|
|
247
|
-
description: '字段,JSON 格式: [{"name":"k","value":"v","inline":false}]',
|
|
248
|
-
},
|
|
249
|
-
},
|
|
250
|
-
required: ["bot", "channel_id"],
|
|
251
|
-
},
|
|
252
|
-
platforms: ["discord"],
|
|
253
|
-
scopes: ["channel", "private"],
|
|
254
|
-
permissionLevel: "user",
|
|
255
|
-
execute: async (args) => {
|
|
256
|
-
const { bot: botId, channel_id, title, description, color, url, fields } = args;
|
|
257
|
-
const bot = this.bots.get(botId);
|
|
258
|
-
if (!bot)
|
|
259
|
-
throw new Error(`Bot ${botId} 不存在`);
|
|
260
|
-
if (!isGatewayBot(bot))
|
|
261
|
-
throw new Error("此工具仅支持 connection: gateway");
|
|
262
|
-
const embedData = {};
|
|
263
|
-
if (title)
|
|
264
|
-
embedData.title = title;
|
|
265
|
-
if (description)
|
|
266
|
-
embedData.description = description;
|
|
267
|
-
if (color)
|
|
268
|
-
embedData.color = color;
|
|
269
|
-
if (url)
|
|
270
|
-
embedData.url = url;
|
|
271
|
-
if (fields) {
|
|
272
|
-
try {
|
|
273
|
-
embedData.fields = JSON.parse(fields);
|
|
274
|
-
}
|
|
275
|
-
catch {
|
|
276
|
-
return { success: false, message: "fields 格式错误,应为 JSON 数组" };
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
const msg = await bot.sendEmbed(channel_id, embedData);
|
|
280
|
-
return { success: true, message_id: msg.id, message: "Embed 已发送" };
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
this.addTool({
|
|
284
|
-
name: "discord_forum_post",
|
|
285
|
-
description: "在 Discord 论坛频道中创建帖子",
|
|
286
|
-
parameters: {
|
|
287
|
-
type: "object",
|
|
288
|
-
properties: {
|
|
289
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
290
|
-
channel_id: { type: "string", description: "论坛频道 ID" },
|
|
291
|
-
name: { type: "string", description: "帖子标题" },
|
|
292
|
-
content: { type: "string", description: "帖子内容" },
|
|
293
|
-
tags: { type: "string", description: "标签名,逗号分隔(可选)" },
|
|
294
|
-
},
|
|
295
|
-
required: ["bot", "channel_id", "name", "content"],
|
|
296
|
-
},
|
|
297
|
-
platforms: ["discord"],
|
|
298
|
-
scopes: ["channel"],
|
|
299
|
-
permissionLevel: "user",
|
|
300
|
-
execute: async (args) => {
|
|
301
|
-
const { bot: botId, channel_id, name, content, tags } = args;
|
|
302
|
-
const bot = this.bots.get(botId);
|
|
303
|
-
if (!bot)
|
|
304
|
-
throw new Error(`Bot ${botId} 不存在`);
|
|
305
|
-
if (!isGatewayBot(bot))
|
|
306
|
-
throw new Error("此工具仅支持 connection: gateway");
|
|
307
|
-
const tagList = tags ? tags.split(",").map((t) => t.trim()) : undefined;
|
|
308
|
-
const thread = await bot.createForumPost(channel_id, name, content, tagList);
|
|
309
|
-
return { success: true, thread_id: thread.id, message: `论坛帖 "${name}" 已创建` };
|
|
310
|
-
},
|
|
311
|
-
});
|
|
312
|
-
this.plugin.logger.debug("已注册 Discord 平台服务器管理工具");
|
|
313
|
-
}
|
|
314
89
|
}
|
|
315
90
|
//# sourceMappingURL=adapter.js.map
|
package/lib/adapter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.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","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AAEnE,OAAO,QAAQ,SAAS,CAAC;IACvB,UAAU,MAAM,CAAC;QACf,UAAU,QAAQ;YAChB,MAAM,EAAE,OAAO,eAAe,EAAE,MAAM,CAAC;SACxC;KACF;IACD,UAAU,QAAQ;QAChB,OAAO,EAAE,cAAc,CAAC;KACzB;CACF;AAED,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Discord 适配器入口:单一适配器,支持 Gateway / Interactions(connection: gateway | interactions)
|
|
3
3
|
*/
|
|
4
|
-
import { usePlugin } from "zhin.js";
|
|
4
|
+
import { usePlugin, createGroupManagementTools } from "zhin.js";
|
|
5
5
|
import { DiscordAdapter } from "./adapter.js";
|
|
6
6
|
export * from "./types.js";
|
|
7
7
|
export { DiscordBot } from "./bot.js";
|
|
8
8
|
export { DiscordInteractionsBot } from "./bot-interactions.js";
|
|
9
9
|
export { DiscordAdapter } from "./adapter.js";
|
|
10
|
-
const { provide } = usePlugin();
|
|
10
|
+
const { provide, useContext } = usePlugin();
|
|
11
11
|
provide({
|
|
12
12
|
name: "discord",
|
|
13
13
|
description: "Discord 适配器(Gateway / Interactions)",
|
|
@@ -20,4 +20,195 @@ provide({
|
|
|
20
20
|
await adapter.stop();
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
|
+
useContext('tool', 'discord', (toolService, discord) => {
|
|
24
|
+
const groupTools = createGroupManagementTools(discord, 'discord');
|
|
25
|
+
const disposers = groupTools.map(t => toolService.addTool(t, 'discord'));
|
|
26
|
+
function getGatewayBot(botId) {
|
|
27
|
+
const bot = discord.bots.get(botId);
|
|
28
|
+
if (!bot)
|
|
29
|
+
throw new Error(`Bot ${botId} 不存在`);
|
|
30
|
+
if (bot.$config.connection !== 'gateway') {
|
|
31
|
+
throw new Error('此工具仅支持 connection: gateway');
|
|
32
|
+
}
|
|
33
|
+
return bot;
|
|
34
|
+
}
|
|
35
|
+
disposers.push(toolService.addTool({
|
|
36
|
+
name: 'discord_add_role',
|
|
37
|
+
description: '给成员添加 Discord 角色',
|
|
38
|
+
parameters: {
|
|
39
|
+
type: 'object',
|
|
40
|
+
properties: {
|
|
41
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
42
|
+
guild_id: { type: 'string', description: '服务器 ID' },
|
|
43
|
+
user_id: { type: 'string', description: '用户 ID' },
|
|
44
|
+
role_id: { type: 'string', description: '角色 ID' },
|
|
45
|
+
},
|
|
46
|
+
required: ['bot', 'guild_id', 'user_id', 'role_id'],
|
|
47
|
+
},
|
|
48
|
+
platforms: ['discord'],
|
|
49
|
+
tags: ['discord'],
|
|
50
|
+
execute: async (args) => {
|
|
51
|
+
const bot = getGatewayBot(args.bot);
|
|
52
|
+
const success = await bot.addRole(args.guild_id, args.user_id, args.role_id);
|
|
53
|
+
return { success, message: success ? `已给用户 ${args.user_id} 添加角色` : '操作失败' };
|
|
54
|
+
},
|
|
55
|
+
}, 'discord'));
|
|
56
|
+
disposers.push(toolService.addTool({
|
|
57
|
+
name: 'discord_remove_role',
|
|
58
|
+
description: '移除成员的 Discord 角色',
|
|
59
|
+
parameters: {
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
63
|
+
guild_id: { type: 'string', description: '服务器 ID' },
|
|
64
|
+
user_id: { type: 'string', description: '用户 ID' },
|
|
65
|
+
role_id: { type: 'string', description: '角色 ID' },
|
|
66
|
+
},
|
|
67
|
+
required: ['bot', 'guild_id', 'user_id', 'role_id'],
|
|
68
|
+
},
|
|
69
|
+
platforms: ['discord'],
|
|
70
|
+
tags: ['discord'],
|
|
71
|
+
execute: async (args) => {
|
|
72
|
+
const bot = getGatewayBot(args.bot);
|
|
73
|
+
const success = await bot.removeRole(args.guild_id, args.user_id, args.role_id);
|
|
74
|
+
return { success, message: success ? `已移除用户 ${args.user_id} 的角色` : '操作失败' };
|
|
75
|
+
},
|
|
76
|
+
}, 'discord'));
|
|
77
|
+
disposers.push(toolService.addTool({
|
|
78
|
+
name: 'discord_list_roles',
|
|
79
|
+
description: '获取 Discord 服务器角色列表',
|
|
80
|
+
parameters: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
properties: {
|
|
83
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
84
|
+
guild_id: { type: 'string', description: '服务器 ID' },
|
|
85
|
+
},
|
|
86
|
+
required: ['bot', 'guild_id'],
|
|
87
|
+
},
|
|
88
|
+
platforms: ['discord'],
|
|
89
|
+
tags: ['discord'],
|
|
90
|
+
execute: async (args) => {
|
|
91
|
+
const bot = getGatewayBot(args.bot);
|
|
92
|
+
const roles = await bot.getRoles(args.guild_id);
|
|
93
|
+
return { roles, count: roles.length };
|
|
94
|
+
},
|
|
95
|
+
}, 'discord'));
|
|
96
|
+
disposers.push(toolService.addTool({
|
|
97
|
+
name: 'discord_create_thread',
|
|
98
|
+
description: '在 Discord 频道中创建帖子/子线程',
|
|
99
|
+
parameters: {
|
|
100
|
+
type: 'object',
|
|
101
|
+
properties: {
|
|
102
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
103
|
+
channel_id: { type: 'string', description: '频道 ID' },
|
|
104
|
+
name: { type: 'string', description: '帖子标题' },
|
|
105
|
+
message_id: { type: 'string', description: '基于某条消息创建(可选)' },
|
|
106
|
+
auto_archive_duration: {
|
|
107
|
+
type: 'number',
|
|
108
|
+
description: '自动归档时间(分钟:60/1440/4320/10080)',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
required: ['bot', 'channel_id', 'name'],
|
|
112
|
+
},
|
|
113
|
+
platforms: ['discord'],
|
|
114
|
+
tags: ['discord'],
|
|
115
|
+
execute: async (args) => {
|
|
116
|
+
const bot = getGatewayBot(args.bot);
|
|
117
|
+
const thread = await bot.createThread(args.channel_id, args.name, args.message_id, args.auto_archive_duration);
|
|
118
|
+
return { success: true, thread_id: thread.id, message: `帖子 "${args.name}" 已创建` };
|
|
119
|
+
},
|
|
120
|
+
}, 'discord'));
|
|
121
|
+
disposers.push(toolService.addTool({
|
|
122
|
+
name: 'discord_react',
|
|
123
|
+
description: '对 Discord 消息添加表情反应',
|
|
124
|
+
parameters: {
|
|
125
|
+
type: 'object',
|
|
126
|
+
properties: {
|
|
127
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
128
|
+
channel_id: { type: 'string', description: '频道 ID' },
|
|
129
|
+
message_id: { type: 'string', description: '消息 ID' },
|
|
130
|
+
emoji: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: '表情(Unicode 表情或自定义表情如 <:name:id>)',
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
required: ['bot', 'channel_id', 'message_id', 'emoji'],
|
|
136
|
+
},
|
|
137
|
+
platforms: ['discord'],
|
|
138
|
+
tags: ['discord'],
|
|
139
|
+
execute: async (args) => {
|
|
140
|
+
const bot = getGatewayBot(args.bot);
|
|
141
|
+
await bot.addReaction(args.channel_id, args.message_id, args.emoji);
|
|
142
|
+
return { success: true, message: `已添加反应 ${args.emoji}` };
|
|
143
|
+
},
|
|
144
|
+
}, 'discord'));
|
|
145
|
+
disposers.push(toolService.addTool({
|
|
146
|
+
name: 'discord_send_embed',
|
|
147
|
+
description: '发送 Discord 富文本嵌入消息(Embed)',
|
|
148
|
+
parameters: {
|
|
149
|
+
type: 'object',
|
|
150
|
+
properties: {
|
|
151
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
152
|
+
channel_id: { type: 'string', description: '频道 ID' },
|
|
153
|
+
title: { type: 'string', description: 'Embed 标题' },
|
|
154
|
+
description: { type: 'string', description: 'Embed 描述' },
|
|
155
|
+
color: { type: 'number', description: '颜色值(十进制,如 0x00ff00 = 65280)' },
|
|
156
|
+
url: { type: 'string', description: '标题链接(可选)' },
|
|
157
|
+
fields: {
|
|
158
|
+
type: 'string',
|
|
159
|
+
description: '字段,JSON 格式: [{"name":"k","value":"v","inline":false}]',
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
required: ['bot', 'channel_id'],
|
|
163
|
+
},
|
|
164
|
+
platforms: ['discord'],
|
|
165
|
+
tags: ['discord'],
|
|
166
|
+
execute: async (args) => {
|
|
167
|
+
const bot = getGatewayBot(args.bot);
|
|
168
|
+
const embedData = {};
|
|
169
|
+
if (args.title)
|
|
170
|
+
embedData.title = args.title;
|
|
171
|
+
if (args.description)
|
|
172
|
+
embedData.description = args.description;
|
|
173
|
+
if (args.color)
|
|
174
|
+
embedData.color = args.color;
|
|
175
|
+
if (args.url)
|
|
176
|
+
embedData.url = args.url;
|
|
177
|
+
if (args.fields) {
|
|
178
|
+
try {
|
|
179
|
+
embedData.fields = JSON.parse(args.fields);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return { success: false, message: 'fields 格式错误,应为 JSON 数组' };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
const msg = await bot.sendEmbed(args.channel_id, embedData);
|
|
186
|
+
return { success: true, message_id: msg.id, message: 'Embed 已发送' };
|
|
187
|
+
},
|
|
188
|
+
}, 'discord'));
|
|
189
|
+
disposers.push(toolService.addTool({
|
|
190
|
+
name: 'discord_forum_post',
|
|
191
|
+
description: '在 Discord 论坛频道中创建帖子',
|
|
192
|
+
parameters: {
|
|
193
|
+
type: 'object',
|
|
194
|
+
properties: {
|
|
195
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
196
|
+
channel_id: { type: 'string', description: '论坛频道 ID' },
|
|
197
|
+
name: { type: 'string', description: '帖子标题' },
|
|
198
|
+
content: { type: 'string', description: '帖子内容' },
|
|
199
|
+
tags: { type: 'string', description: '标签名,逗号分隔(可选)' },
|
|
200
|
+
},
|
|
201
|
+
required: ['bot', 'channel_id', 'name', 'content'],
|
|
202
|
+
},
|
|
203
|
+
platforms: ['discord'],
|
|
204
|
+
tags: ['discord'],
|
|
205
|
+
execute: async (args) => {
|
|
206
|
+
const bot = getGatewayBot(args.bot);
|
|
207
|
+
const tagList = args.tags ? args.tags.split(',').map((t) => t.trim()) : undefined;
|
|
208
|
+
const thread = await bot.createForumPost(args.channel_id, args.name, args.content, tagList);
|
|
209
|
+
return { success: true, thread_id: thread.id, message: `论坛帖 "${args.name}" 已创建` };
|
|
210
|
+
},
|
|
211
|
+
}, 'discord'));
|
|
212
|
+
return () => disposers.forEach(d => d());
|
|
213
|
+
});
|
|
23
214
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAoD,0BAA0B,EAAoB,MAAM,SAAS,CAAC;AAEpI,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AAanE,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAuB,MAAM,cAAc,CAAC;AAEnE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,GAAG,SAAS,EAAE,CAAC;AAC5C,OAAO,CAAC;IACN,IAAI,EAAE,SAAS;IACf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E;YAC3C,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,GAAG,CAAQ,CAAC;YAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC1F,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC5F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,QAAQ,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;QACpF,CAAC;KACF,EAAE,SAAS,CAAC,CAAC,CAAC;IAEf,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AAC3C,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/adapter-discord",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.66",
|
|
4
4
|
"description": "Zhin.js adapter for Discord",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/koa": "^3.0.0",
|
|
40
40
|
"@types/node": "^22.9.0",
|
|
41
|
-
"typescript": "^5.3
|
|
42
|
-
"zhin.js": "1.0.
|
|
41
|
+
"typescript": "^5.9.3",
|
|
42
|
+
"zhin.js": "1.0.61"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"
|
|
46
|
-
"zhin.js": "1.0.
|
|
45
|
+
"zhin.js": "1.0.61",
|
|
46
|
+
"@zhin.js/http": "1.0.56"
|
|
47
47
|
},
|
|
48
48
|
"files": [
|
|
49
49
|
"src",
|
package/skills/discord/SKILL.md
CHANGED
|
@@ -1,20 +1,72 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: discord
|
|
3
|
-
|
|
3
|
+
platforms:
|
|
4
|
+
- discord
|
|
5
|
+
description: Discord 服务器管理:群管(踢人、封禁、解封、禁言、改昵称、查成员)、角色管理、帖子/论坛、表情反应、Embed 消息、线程创建。需先 list_members 获取用户 ID。
|
|
4
6
|
keywords:
|
|
5
7
|
- discord
|
|
6
8
|
- adapter:discord
|
|
7
9
|
- 群管理
|
|
8
10
|
- 踢人
|
|
9
11
|
- 禁言
|
|
12
|
+
- 封禁
|
|
13
|
+
- 角色
|
|
14
|
+
- 线程
|
|
15
|
+
- embed
|
|
16
|
+
- 反应
|
|
10
17
|
- list_members
|
|
11
18
|
tags:
|
|
12
19
|
- group
|
|
13
20
|
- management
|
|
14
21
|
- im
|
|
15
|
-
tools:
|
|
22
|
+
tools:
|
|
23
|
+
# 平台特有工具
|
|
24
|
+
- discord_add_role
|
|
25
|
+
- discord_remove_role
|
|
26
|
+
- discord_list_roles
|
|
27
|
+
- discord_create_thread
|
|
28
|
+
- discord_react
|
|
29
|
+
- discord_send_embed
|
|
30
|
+
- discord_forum_post
|
|
31
|
+
# 通用群管工具
|
|
32
|
+
- discord_kick_member
|
|
33
|
+
- discord_ban_member
|
|
34
|
+
- discord_unban_member
|
|
35
|
+
- discord_mute_member
|
|
36
|
+
- discord_set_nickname
|
|
37
|
+
- discord_list_members
|
|
38
|
+
- discord_get_group_info
|
|
16
39
|
---
|
|
17
40
|
|
|
41
|
+
## 工具概览
|
|
42
|
+
|
|
43
|
+
### 平台特有
|
|
44
|
+
|
|
45
|
+
| 工具 | 说明 | 权限 |
|
|
46
|
+
|------|------|------|
|
|
47
|
+
| `discord_add_role` | 为成员添加角色 | group_admin |
|
|
48
|
+
| `discord_remove_role` | 移除成员角色 | group_admin |
|
|
49
|
+
| `discord_list_roles` | 获取服务器角色列表 | user |
|
|
50
|
+
| `discord_create_thread` | 创建线程 | user |
|
|
51
|
+
| `discord_react` | 对消息添加表情反应 | user |
|
|
52
|
+
| `discord_send_embed` | 发送 Embed 富文本消息 | user |
|
|
53
|
+
| `discord_forum_post` | 在论坛频道创建帖子 | user |
|
|
54
|
+
|
|
55
|
+
### 通用群管
|
|
56
|
+
|
|
57
|
+
| 工具 | 说明 | 权限 |
|
|
58
|
+
|------|------|------|
|
|
59
|
+
| `discord_kick_member` | 踢出成员 | group_admin |
|
|
60
|
+
| `discord_ban_member` | 封禁成员 | group_admin |
|
|
61
|
+
| `discord_unban_member` | 解除封禁 | group_admin |
|
|
62
|
+
| `discord_mute_member` | 禁言成员 | group_admin |
|
|
63
|
+
| `discord_set_nickname` | 修改成员昵称 | group_admin |
|
|
64
|
+
| `discord_list_members` | 获取成员列表 | user |
|
|
65
|
+
| `discord_get_group_info` | 获取服务器/频道信息 | user |
|
|
66
|
+
|
|
18
67
|
## 执行规则
|
|
19
68
|
|
|
20
|
-
|
|
69
|
+
1. 操作成员需要 Discord 用户 ID,仅有昵称时先调 `discord_list_members`
|
|
70
|
+
2. 角色操作需要角色 ID,先调 `discord_list_roles` 查询
|
|
71
|
+
3. Embed 消息支持 title/description/color/fields 等字段
|
|
72
|
+
4. 仅 Gateway 连接的 Bot 支持全部功能
|
package/src/adapter.ts
CHANGED
|
@@ -5,8 +5,6 @@ import type { Router } from "@zhin.js/http";
|
|
|
5
5
|
import {
|
|
6
6
|
Adapter,
|
|
7
7
|
Plugin,
|
|
8
|
-
createGroupManagementTools,
|
|
9
|
-
type IGroupManagement,
|
|
10
8
|
} from "zhin.js";
|
|
11
9
|
import { DiscordBot } from "./bot.js";
|
|
12
10
|
import { DiscordInteractionsBot } from "./bot-interactions.js";
|
|
@@ -103,220 +101,7 @@ export class DiscordAdapter extends Adapter<DiscordBotLike> {
|
|
|
103
101
|
this.#router = router;
|
|
104
102
|
}
|
|
105
103
|
);
|
|
106
|
-
this.registerDiscordPlatformTools();
|
|
107
|
-
const groupTools = createGroupManagementTools(this as unknown as IGroupManagement, this.name);
|
|
108
|
-
groupTools.forEach((t) => this.addTool(t));
|
|
109
104
|
await super.start();
|
|
110
105
|
}
|
|
111
106
|
|
|
112
|
-
private registerDiscordPlatformTools(): void {
|
|
113
|
-
this.addTool({
|
|
114
|
-
name: "discord_add_role",
|
|
115
|
-
description: "给成员添加 Discord 角色",
|
|
116
|
-
parameters: {
|
|
117
|
-
type: "object",
|
|
118
|
-
properties: {
|
|
119
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
120
|
-
guild_id: { type: "string", description: "服务器 ID" },
|
|
121
|
-
user_id: { type: "string", description: "用户 ID" },
|
|
122
|
-
role_id: { type: "string", description: "角色 ID" },
|
|
123
|
-
},
|
|
124
|
-
required: ["bot", "guild_id", "user_id", "role_id"],
|
|
125
|
-
},
|
|
126
|
-
platforms: ["discord"],
|
|
127
|
-
scopes: ["channel"],
|
|
128
|
-
permissionLevel: "group_admin",
|
|
129
|
-
execute: async (args) => {
|
|
130
|
-
const { bot: botId, guild_id, user_id, role_id } = args;
|
|
131
|
-
const bot = this.bots.get(botId);
|
|
132
|
-
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
133
|
-
if (!isGatewayBot(bot)) throw new Error("此工具仅支持 connection: gateway");
|
|
134
|
-
const success = await bot.addRole(guild_id, user_id, role_id);
|
|
135
|
-
return { success, message: success ? `已给用户 ${user_id} 添加角色` : "操作失败" };
|
|
136
|
-
},
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
this.addTool({
|
|
140
|
-
name: "discord_remove_role",
|
|
141
|
-
description: "移除成员的 Discord 角色",
|
|
142
|
-
parameters: {
|
|
143
|
-
type: "object",
|
|
144
|
-
properties: {
|
|
145
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
146
|
-
guild_id: { type: "string", description: "服务器 ID" },
|
|
147
|
-
user_id: { type: "string", description: "用户 ID" },
|
|
148
|
-
role_id: { type: "string", description: "角色 ID" },
|
|
149
|
-
},
|
|
150
|
-
required: ["bot", "guild_id", "user_id", "role_id"],
|
|
151
|
-
},
|
|
152
|
-
platforms: ["discord"],
|
|
153
|
-
scopes: ["channel"],
|
|
154
|
-
permissionLevel: "group_admin",
|
|
155
|
-
execute: async (args) => {
|
|
156
|
-
const { bot: botId, guild_id, user_id, role_id } = args;
|
|
157
|
-
const bot = this.bots.get(botId);
|
|
158
|
-
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
159
|
-
if (!isGatewayBot(bot)) throw new Error("此工具仅支持 connection: gateway");
|
|
160
|
-
const success = await bot.removeRole(guild_id, user_id, role_id);
|
|
161
|
-
return { success, message: success ? `已移除用户 ${user_id} 的角色` : "操作失败" };
|
|
162
|
-
},
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
this.addTool({
|
|
166
|
-
name: "discord_list_roles",
|
|
167
|
-
description: "获取 Discord 服务器角色列表",
|
|
168
|
-
parameters: {
|
|
169
|
-
type: "object",
|
|
170
|
-
properties: {
|
|
171
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
172
|
-
guild_id: { type: "string", description: "服务器 ID" },
|
|
173
|
-
},
|
|
174
|
-
required: ["bot", "guild_id"],
|
|
175
|
-
},
|
|
176
|
-
platforms: ["discord"],
|
|
177
|
-
scopes: ["channel"],
|
|
178
|
-
permissionLevel: "user",
|
|
179
|
-
execute: async (args) => {
|
|
180
|
-
const { bot: botId, guild_id } = args;
|
|
181
|
-
const bot = this.bots.get(botId);
|
|
182
|
-
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
183
|
-
if (!isGatewayBot(bot)) throw new Error("此工具仅支持 connection: gateway");
|
|
184
|
-
const roles = await bot.getRoles(guild_id);
|
|
185
|
-
return { roles, count: roles.length };
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
this.addTool({
|
|
190
|
-
name: "discord_create_thread",
|
|
191
|
-
description: "在 Discord 频道中创建帖子/子线程",
|
|
192
|
-
parameters: {
|
|
193
|
-
type: "object",
|
|
194
|
-
properties: {
|
|
195
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
196
|
-
channel_id: { type: "string", description: "频道 ID" },
|
|
197
|
-
name: { type: "string", description: "帖子标题" },
|
|
198
|
-
message_id: { type: "string", description: "基于某条消息创建(可选)" },
|
|
199
|
-
auto_archive_duration: {
|
|
200
|
-
type: "number",
|
|
201
|
-
description: "自动归档时间(分钟:60/1440/4320/10080)",
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
required: ["bot", "channel_id", "name"],
|
|
205
|
-
},
|
|
206
|
-
platforms: ["discord"],
|
|
207
|
-
scopes: ["channel"],
|
|
208
|
-
permissionLevel: "user",
|
|
209
|
-
execute: async (args) => {
|
|
210
|
-
const { bot: botId, channel_id, name, message_id, auto_archive_duration } = args;
|
|
211
|
-
const bot = this.bots.get(botId);
|
|
212
|
-
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
213
|
-
if (!isGatewayBot(bot)) throw new Error("此工具仅支持 connection: gateway");
|
|
214
|
-
const thread = await bot.createThread(channel_id, name, message_id, auto_archive_duration);
|
|
215
|
-
return { success: true, thread_id: thread.id, message: `帖子 "${name}" 已创建` };
|
|
216
|
-
},
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
this.addTool({
|
|
220
|
-
name: "discord_react",
|
|
221
|
-
description: "对 Discord 消息添加表情反应",
|
|
222
|
-
parameters: {
|
|
223
|
-
type: "object",
|
|
224
|
-
properties: {
|
|
225
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
226
|
-
channel_id: { type: "string", description: "频道 ID" },
|
|
227
|
-
message_id: { type: "string", description: "消息 ID" },
|
|
228
|
-
emoji: {
|
|
229
|
-
type: "string",
|
|
230
|
-
description: "表情(Unicode 表情或自定义表情如 <:name:id>)",
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
required: ["bot", "channel_id", "message_id", "emoji"],
|
|
234
|
-
},
|
|
235
|
-
platforms: ["discord"],
|
|
236
|
-
scopes: ["channel", "private"],
|
|
237
|
-
permissionLevel: "user",
|
|
238
|
-
execute: async (args) => {
|
|
239
|
-
const { bot: botId, channel_id, message_id, emoji } = args;
|
|
240
|
-
const bot = this.bots.get(botId);
|
|
241
|
-
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
242
|
-
if (!isGatewayBot(bot)) throw new Error("此工具仅支持 connection: gateway");
|
|
243
|
-
await bot.addReaction(channel_id, message_id, emoji);
|
|
244
|
-
return { success: true, message: `已添加反应 ${emoji}` };
|
|
245
|
-
},
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
this.addTool({
|
|
249
|
-
name: "discord_send_embed",
|
|
250
|
-
description: "发送 Discord 富文本嵌入消息(Embed)",
|
|
251
|
-
parameters: {
|
|
252
|
-
type: "object",
|
|
253
|
-
properties: {
|
|
254
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
255
|
-
channel_id: { type: "string", description: "频道 ID" },
|
|
256
|
-
title: { type: "string", description: "Embed 标题" },
|
|
257
|
-
description: { type: "string", description: "Embed 描述" },
|
|
258
|
-
color: { type: "number", description: "颜色值(十进制,如 0x00ff00 = 65280)" },
|
|
259
|
-
url: { type: "string", description: "标题链接(可选)" },
|
|
260
|
-
fields: {
|
|
261
|
-
type: "string",
|
|
262
|
-
description: '字段,JSON 格式: [{"name":"k","value":"v","inline":false}]',
|
|
263
|
-
},
|
|
264
|
-
},
|
|
265
|
-
required: ["bot", "channel_id"],
|
|
266
|
-
},
|
|
267
|
-
platforms: ["discord"],
|
|
268
|
-
scopes: ["channel", "private"],
|
|
269
|
-
permissionLevel: "user",
|
|
270
|
-
execute: async (args) => {
|
|
271
|
-
const { bot: botId, channel_id, title, description, color, url, fields } = args;
|
|
272
|
-
const bot = this.bots.get(botId);
|
|
273
|
-
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
274
|
-
if (!isGatewayBot(bot)) throw new Error("此工具仅支持 connection: gateway");
|
|
275
|
-
const embedData: any = {};
|
|
276
|
-
if (title) embedData.title = title;
|
|
277
|
-
if (description) embedData.description = description;
|
|
278
|
-
if (color) embedData.color = color;
|
|
279
|
-
if (url) embedData.url = url;
|
|
280
|
-
if (fields) {
|
|
281
|
-
try {
|
|
282
|
-
embedData.fields = JSON.parse(fields);
|
|
283
|
-
} catch {
|
|
284
|
-
return { success: false, message: "fields 格式错误,应为 JSON 数组" };
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
const msg = await bot.sendEmbed(channel_id, embedData);
|
|
288
|
-
return { success: true, message_id: msg.id, message: "Embed 已发送" };
|
|
289
|
-
},
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
this.addTool({
|
|
293
|
-
name: "discord_forum_post",
|
|
294
|
-
description: "在 Discord 论坛频道中创建帖子",
|
|
295
|
-
parameters: {
|
|
296
|
-
type: "object",
|
|
297
|
-
properties: {
|
|
298
|
-
bot: { type: "string", description: "Bot 名称" },
|
|
299
|
-
channel_id: { type: "string", description: "论坛频道 ID" },
|
|
300
|
-
name: { type: "string", description: "帖子标题" },
|
|
301
|
-
content: { type: "string", description: "帖子内容" },
|
|
302
|
-
tags: { type: "string", description: "标签名,逗号分隔(可选)" },
|
|
303
|
-
},
|
|
304
|
-
required: ["bot", "channel_id", "name", "content"],
|
|
305
|
-
},
|
|
306
|
-
platforms: ["discord"],
|
|
307
|
-
scopes: ["channel"],
|
|
308
|
-
permissionLevel: "user",
|
|
309
|
-
execute: async (args) => {
|
|
310
|
-
const { bot: botId, channel_id, name, content, tags } = args;
|
|
311
|
-
const bot = this.bots.get(botId);
|
|
312
|
-
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
313
|
-
if (!isGatewayBot(bot)) throw new Error("此工具仅支持 connection: gateway");
|
|
314
|
-
const tagList = tags ? tags.split(",").map((t: string) => t.trim()) : undefined;
|
|
315
|
-
const thread = await bot.createForumPost(channel_id, name, content, tagList);
|
|
316
|
-
return { success: true, thread_id: thread.id, message: `论坛帖 "${name}" 已创建` };
|
|
317
|
-
},
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
this.plugin.logger.debug("已注册 Discord 平台服务器管理工具");
|
|
321
|
-
}
|
|
322
107
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Discord 适配器入口:单一适配器,支持 Gateway / Interactions(connection: gateway | interactions)
|
|
3
3
|
*/
|
|
4
|
-
import { usePlugin, type Plugin, type Context } from "zhin.js";
|
|
4
|
+
import { usePlugin, type Plugin, type Context, type IGroupManagement, createGroupManagementTools, type ToolFeature } from "zhin.js";
|
|
5
5
|
import type { Router } from "@zhin.js/http";
|
|
6
|
-
import { DiscordAdapter } from "./adapter.js";
|
|
6
|
+
import { DiscordAdapter, type DiscordBotLike } from "./adapter.js";
|
|
7
7
|
|
|
8
8
|
declare module "zhin.js" {
|
|
9
9
|
namespace Plugin {
|
|
@@ -21,7 +21,7 @@ export { DiscordBot } from "./bot.js";
|
|
|
21
21
|
export { DiscordInteractionsBot } from "./bot-interactions.js";
|
|
22
22
|
export { DiscordAdapter, type DiscordBotLike } from "./adapter.js";
|
|
23
23
|
|
|
24
|
-
const { provide } = usePlugin();
|
|
24
|
+
const { provide, useContext } = usePlugin();
|
|
25
25
|
provide({
|
|
26
26
|
name: "discord",
|
|
27
27
|
description: "Discord 适配器(Gateway / Interactions)",
|
|
@@ -34,3 +34,201 @@ provide({
|
|
|
34
34
|
await adapter.stop();
|
|
35
35
|
},
|
|
36
36
|
} as unknown as Context<"discord">);
|
|
37
|
+
|
|
38
|
+
useContext('tool', 'discord', (toolService: ToolFeature, discord: DiscordAdapter) => {
|
|
39
|
+
const groupTools = createGroupManagementTools(
|
|
40
|
+
discord as unknown as IGroupManagement,
|
|
41
|
+
'discord',
|
|
42
|
+
);
|
|
43
|
+
const disposers: (() => void)[] = groupTools.map(t => toolService.addTool(t, 'discord'));
|
|
44
|
+
|
|
45
|
+
function getGatewayBot(botId: string): DiscordBotLike {
|
|
46
|
+
const bot = discord.bots.get(botId);
|
|
47
|
+
if (!bot) throw new Error(`Bot ${botId} 不存在`);
|
|
48
|
+
if ((bot.$config as { connection?: string }).connection !== 'gateway') {
|
|
49
|
+
throw new Error('此工具仅支持 connection: gateway');
|
|
50
|
+
}
|
|
51
|
+
return bot;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
disposers.push(toolService.addTool({
|
|
55
|
+
name: 'discord_add_role',
|
|
56
|
+
description: '给成员添加 Discord 角色',
|
|
57
|
+
parameters: {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
61
|
+
guild_id: { type: 'string', description: '服务器 ID' },
|
|
62
|
+
user_id: { type: 'string', description: '用户 ID' },
|
|
63
|
+
role_id: { type: 'string', description: '角色 ID' },
|
|
64
|
+
},
|
|
65
|
+
required: ['bot', 'guild_id', 'user_id', 'role_id'],
|
|
66
|
+
},
|
|
67
|
+
platforms: ['discord'],
|
|
68
|
+
tags: ['discord'],
|
|
69
|
+
execute: async (args: Record<string, any>) => {
|
|
70
|
+
const bot = getGatewayBot(args.bot) as any;
|
|
71
|
+
const success = await bot.addRole(args.guild_id, args.user_id, args.role_id);
|
|
72
|
+
return { success, message: success ? `已给用户 ${args.user_id} 添加角色` : '操作失败' };
|
|
73
|
+
},
|
|
74
|
+
}, 'discord'));
|
|
75
|
+
|
|
76
|
+
disposers.push(toolService.addTool({
|
|
77
|
+
name: 'discord_remove_role',
|
|
78
|
+
description: '移除成员的 Discord 角色',
|
|
79
|
+
parameters: {
|
|
80
|
+
type: 'object',
|
|
81
|
+
properties: {
|
|
82
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
83
|
+
guild_id: { type: 'string', description: '服务器 ID' },
|
|
84
|
+
user_id: { type: 'string', description: '用户 ID' },
|
|
85
|
+
role_id: { type: 'string', description: '角色 ID' },
|
|
86
|
+
},
|
|
87
|
+
required: ['bot', 'guild_id', 'user_id', 'role_id'],
|
|
88
|
+
},
|
|
89
|
+
platforms: ['discord'],
|
|
90
|
+
tags: ['discord'],
|
|
91
|
+
execute: async (args: Record<string, any>) => {
|
|
92
|
+
const bot = getGatewayBot(args.bot) as any;
|
|
93
|
+
const success = await bot.removeRole(args.guild_id, args.user_id, args.role_id);
|
|
94
|
+
return { success, message: success ? `已移除用户 ${args.user_id} 的角色` : '操作失败' };
|
|
95
|
+
},
|
|
96
|
+
}, 'discord'));
|
|
97
|
+
|
|
98
|
+
disposers.push(toolService.addTool({
|
|
99
|
+
name: 'discord_list_roles',
|
|
100
|
+
description: '获取 Discord 服务器角色列表',
|
|
101
|
+
parameters: {
|
|
102
|
+
type: 'object',
|
|
103
|
+
properties: {
|
|
104
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
105
|
+
guild_id: { type: 'string', description: '服务器 ID' },
|
|
106
|
+
},
|
|
107
|
+
required: ['bot', 'guild_id'],
|
|
108
|
+
},
|
|
109
|
+
platforms: ['discord'],
|
|
110
|
+
tags: ['discord'],
|
|
111
|
+
execute: async (args: Record<string, any>) => {
|
|
112
|
+
const bot = getGatewayBot(args.bot) as any;
|
|
113
|
+
const roles = await bot.getRoles(args.guild_id);
|
|
114
|
+
return { roles, count: roles.length };
|
|
115
|
+
},
|
|
116
|
+
}, 'discord'));
|
|
117
|
+
|
|
118
|
+
disposers.push(toolService.addTool({
|
|
119
|
+
name: 'discord_create_thread',
|
|
120
|
+
description: '在 Discord 频道中创建帖子/子线程',
|
|
121
|
+
parameters: {
|
|
122
|
+
type: 'object',
|
|
123
|
+
properties: {
|
|
124
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
125
|
+
channel_id: { type: 'string', description: '频道 ID' },
|
|
126
|
+
name: { type: 'string', description: '帖子标题' },
|
|
127
|
+
message_id: { type: 'string', description: '基于某条消息创建(可选)' },
|
|
128
|
+
auto_archive_duration: {
|
|
129
|
+
type: 'number',
|
|
130
|
+
description: '自动归档时间(分钟:60/1440/4320/10080)',
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
required: ['bot', 'channel_id', 'name'],
|
|
134
|
+
},
|
|
135
|
+
platforms: ['discord'],
|
|
136
|
+
tags: ['discord'],
|
|
137
|
+
execute: async (args: Record<string, any>) => {
|
|
138
|
+
const bot = getGatewayBot(args.bot) as any;
|
|
139
|
+
const thread = await bot.createThread(args.channel_id, args.name, args.message_id, args.auto_archive_duration);
|
|
140
|
+
return { success: true, thread_id: thread.id, message: `帖子 "${args.name}" 已创建` };
|
|
141
|
+
},
|
|
142
|
+
}, 'discord'));
|
|
143
|
+
|
|
144
|
+
disposers.push(toolService.addTool({
|
|
145
|
+
name: 'discord_react',
|
|
146
|
+
description: '对 Discord 消息添加表情反应',
|
|
147
|
+
parameters: {
|
|
148
|
+
type: 'object',
|
|
149
|
+
properties: {
|
|
150
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
151
|
+
channel_id: { type: 'string', description: '频道 ID' },
|
|
152
|
+
message_id: { type: 'string', description: '消息 ID' },
|
|
153
|
+
emoji: {
|
|
154
|
+
type: 'string',
|
|
155
|
+
description: '表情(Unicode 表情或自定义表情如 <:name:id>)',
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
required: ['bot', 'channel_id', 'message_id', 'emoji'],
|
|
159
|
+
},
|
|
160
|
+
platforms: ['discord'],
|
|
161
|
+
tags: ['discord'],
|
|
162
|
+
execute: async (args: Record<string, any>) => {
|
|
163
|
+
const bot = getGatewayBot(args.bot) as any;
|
|
164
|
+
await bot.addReaction(args.channel_id, args.message_id, args.emoji);
|
|
165
|
+
return { success: true, message: `已添加反应 ${args.emoji}` };
|
|
166
|
+
},
|
|
167
|
+
}, 'discord'));
|
|
168
|
+
|
|
169
|
+
disposers.push(toolService.addTool({
|
|
170
|
+
name: 'discord_send_embed',
|
|
171
|
+
description: '发送 Discord 富文本嵌入消息(Embed)',
|
|
172
|
+
parameters: {
|
|
173
|
+
type: 'object',
|
|
174
|
+
properties: {
|
|
175
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
176
|
+
channel_id: { type: 'string', description: '频道 ID' },
|
|
177
|
+
title: { type: 'string', description: 'Embed 标题' },
|
|
178
|
+
description: { type: 'string', description: 'Embed 描述' },
|
|
179
|
+
color: { type: 'number', description: '颜色值(十进制,如 0x00ff00 = 65280)' },
|
|
180
|
+
url: { type: 'string', description: '标题链接(可选)' },
|
|
181
|
+
fields: {
|
|
182
|
+
type: 'string',
|
|
183
|
+
description: '字段,JSON 格式: [{"name":"k","value":"v","inline":false}]',
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
required: ['bot', 'channel_id'],
|
|
187
|
+
},
|
|
188
|
+
platforms: ['discord'],
|
|
189
|
+
tags: ['discord'],
|
|
190
|
+
execute: async (args: Record<string, any>) => {
|
|
191
|
+
const bot = getGatewayBot(args.bot) as any;
|
|
192
|
+
const embedData: any = {};
|
|
193
|
+
if (args.title) embedData.title = args.title;
|
|
194
|
+
if (args.description) embedData.description = args.description;
|
|
195
|
+
if (args.color) embedData.color = args.color;
|
|
196
|
+
if (args.url) embedData.url = args.url;
|
|
197
|
+
if (args.fields) {
|
|
198
|
+
try {
|
|
199
|
+
embedData.fields = JSON.parse(args.fields);
|
|
200
|
+
} catch {
|
|
201
|
+
return { success: false, message: 'fields 格式错误,应为 JSON 数组' };
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const msg = await bot.sendEmbed(args.channel_id, embedData);
|
|
205
|
+
return { success: true, message_id: msg.id, message: 'Embed 已发送' };
|
|
206
|
+
},
|
|
207
|
+
}, 'discord'));
|
|
208
|
+
|
|
209
|
+
disposers.push(toolService.addTool({
|
|
210
|
+
name: 'discord_forum_post',
|
|
211
|
+
description: '在 Discord 论坛频道中创建帖子',
|
|
212
|
+
parameters: {
|
|
213
|
+
type: 'object',
|
|
214
|
+
properties: {
|
|
215
|
+
bot: { type: 'string', description: 'Bot 名称' },
|
|
216
|
+
channel_id: { type: 'string', description: '论坛频道 ID' },
|
|
217
|
+
name: { type: 'string', description: '帖子标题' },
|
|
218
|
+
content: { type: 'string', description: '帖子内容' },
|
|
219
|
+
tags: { type: 'string', description: '标签名,逗号分隔(可选)' },
|
|
220
|
+
},
|
|
221
|
+
required: ['bot', 'channel_id', 'name', 'content'],
|
|
222
|
+
},
|
|
223
|
+
platforms: ['discord'],
|
|
224
|
+
tags: ['discord'],
|
|
225
|
+
execute: async (args: Record<string, any>) => {
|
|
226
|
+
const bot = getGatewayBot(args.bot) as any;
|
|
227
|
+
const tagList = args.tags ? args.tags.split(',').map((t: string) => t.trim()) : undefined;
|
|
228
|
+
const thread = await bot.createForumPost(args.channel_id, args.name, args.content, tagList);
|
|
229
|
+
return { success: true, thread_id: thread.id, message: `论坛帖 "${args.name}" 已创建` };
|
|
230
|
+
},
|
|
231
|
+
}, 'discord'));
|
|
232
|
+
|
|
233
|
+
return () => disposers.forEach(d => d());
|
|
234
|
+
});
|