@zhin.js/adapter-discord 5.0.1 → 5.0.3
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 +55 -0
- package/README.md +51 -76
- package/adapters/discord.ts +46 -0
- package/agent/tools/add_role.ts +24 -0
- package/agent/tools/create_thread.ts +25 -0
- package/agent/tools/forum_post.ts +24 -0
- package/agent/tools/list_roles.ts +22 -0
- package/agent/tools/react.ts +22 -0
- package/agent/tools/remove_role.ts +24 -0
- package/agent/tools/send_embed.ts +37 -0
- package/lib/discord-agent-deps.d.ts +35 -0
- package/lib/discord-agent-deps.js +32 -0
- package/lib/endpoint.d.ts +66 -119
- package/lib/endpoint.js +308 -1047
- package/lib/gateway.d.ts +122 -0
- package/lib/gateway.js +235 -0
- package/lib/index.d.ts +6 -18
- package/lib/index.js +6 -330
- package/lib/platform-permit.d.ts +1 -2
- package/lib/platform-permit.js +4 -2
- package/lib/protocol.d.ts +135 -0
- package/lib/protocol.js +234 -0
- package/lib/webhook.d.ts +13 -0
- package/lib/webhook.js +86 -0
- package/package.json +48 -31
- package/plugin.ts +13 -0
- package/schema.json +63 -0
- package/src/discord-agent-deps.ts +79 -0
- package/src/endpoint.ts +385 -1167
- package/src/gateway.ts +337 -0
- package/src/index.ts +55 -332
- package/src/platform-permit.ts +1 -2
- package/src/protocol.ts +392 -0
- package/src/webhook.ts +121 -0
- package/client/Dashboard.tsx +0 -195
- package/client/index.tsx +0 -11
- package/client/tsconfig.json +0 -7
- package/client/utils/api.ts +0 -30
- package/dist/index.js +0 -29
- package/lib/adapter.d.ts +0 -25
- package/lib/adapter.d.ts.map +0 -1
- package/lib/adapter.js +0 -96
- package/lib/adapter.js.map +0 -1
- package/lib/endpoint-interactions.d.ts +0 -34
- package/lib/endpoint-interactions.d.ts.map +0 -1
- package/lib/endpoint-interactions.js +0 -284
- package/lib/endpoint-interactions.js.map +0 -1
- package/lib/endpoint.d.ts.map +0 -1
- package/lib/endpoint.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/platform-permit.d.ts.map +0 -1
- package/lib/platform-permit.js.map +0 -1
- package/lib/segment-mapper.d.ts +0 -2
- package/lib/segment-mapper.d.ts.map +0 -1
- package/lib/segment-mapper.js +0 -2
- package/lib/segment-mapper.js.map +0 -1
- package/lib/types.d.ts +0 -49
- package/lib/types.d.ts.map +0 -1
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/plugin.yml +0 -3
- package/src/adapter.ts +0 -108
- package/src/endpoint-interactions.ts +0 -354
- package/src/segment-mapper.ts +0 -1
- package/src/types.ts +0 -60
- /package/{skills/discord → agent}/PERMITS.md +0 -0
- /package/{skills/discord/SKILL.md → agent/skills/discord.md} +0 -0
package/lib/endpoint.d.ts
CHANGED
|
@@ -1,124 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import type
|
|
7
|
-
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import type { EndpointInstance } from '@zhin.js/adapter';
|
|
2
|
+
import type { MessageGateway } from '@zhin.js/core/runtime';
|
|
3
|
+
import type { HttpHost } from '@zhin.js/host-http';
|
|
4
|
+
import type { CapabilityId } from '@zhin.js/plugin-runtime';
|
|
5
|
+
import { type CreateDiscordClient } from './gateway.js';
|
|
6
|
+
import { type DiscordButtonInbound, type DiscordInboundMessage, type ResolvedDiscordGatewayConfig, type ResolvedDiscordInteractionsConfig } from './protocol.js';
|
|
7
|
+
export type { CreateDiscordClient, DiscordClientTransport, } from './gateway.js';
|
|
8
|
+
export interface DiscordEndpointOptions {
|
|
9
|
+
readonly id: CapabilityId;
|
|
10
|
+
readonly gateway: MessageGateway;
|
|
11
|
+
readonly config: ResolvedDiscordGatewayConfig;
|
|
12
|
+
readonly createClient?: CreateDiscordClient;
|
|
13
|
+
}
|
|
14
|
+
export declare class DiscordGatewayEndpoint implements EndpointInstance {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(options: DiscordEndpointOptions);
|
|
17
|
+
start(): Promise<void>;
|
|
18
|
+
open(): void;
|
|
19
|
+
close(): void;
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
send({ target, payload }: {
|
|
22
|
+
readonly target: string;
|
|
23
|
+
readonly payload: unknown;
|
|
24
|
+
}): Promise<string>;
|
|
25
|
+
/** Test / internal: admit a message when open. */
|
|
26
|
+
admit(msg: DiscordInboundMessage): void;
|
|
27
|
+
/** Test / internal: admit a button interaction when open. */
|
|
28
|
+
admitButton(interaction: DiscordButtonInbound): void;
|
|
29
|
+
addRole(guildId: string, userId: string, roleId: string): Promise<boolean>;
|
|
30
|
+
removeRole(guildId: string, userId: string, roleId: string): Promise<boolean>;
|
|
31
|
+
getRoles(guildId: string): Promise<unknown[]>;
|
|
32
|
+
createThread(channelId: string, name: string, messageId?: string, autoArchiveDuration?: number): Promise<{
|
|
33
|
+
id: string;
|
|
34
|
+
}>;
|
|
35
|
+
addReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
|
|
36
|
+
sendEmbed(channelId: string, embedData: Record<string, unknown>): Promise<{
|
|
37
|
+
id: string;
|
|
38
|
+
}>;
|
|
39
|
+
createForumPost(channelId: string, name: string, content: string, tags?: string[]): Promise<{
|
|
40
|
+
id: string;
|
|
41
|
+
}>;
|
|
37
42
|
kickMember(guildId: string, userId: string, reason?: string): Promise<boolean>;
|
|
38
|
-
|
|
39
|
-
* 封禁成员
|
|
40
|
-
* @param guildId 服务器 ID
|
|
41
|
-
* @param userId 用户 ID
|
|
42
|
-
* @param reason 原因
|
|
43
|
-
* @param deleteMessageDays 删除消息天数
|
|
44
|
-
*/
|
|
45
|
-
banMember(guildId: string, userId: string, reason?: string, deleteMessageDays?: number): Promise<boolean>;
|
|
46
|
-
/**
|
|
47
|
-
* 解除封禁
|
|
48
|
-
* @param guildId 服务器 ID
|
|
49
|
-
* @param userId 用户 ID
|
|
50
|
-
* @param reason 原因
|
|
51
|
-
*/
|
|
43
|
+
banMember(guildId: string, userId: string, reason?: string): Promise<boolean>;
|
|
52
44
|
unbanMember(guildId: string, userId: string, reason?: string): Promise<boolean>;
|
|
53
|
-
/**
|
|
54
|
-
* 超时(禁言)成员
|
|
55
|
-
* @param guildId 服务器 ID
|
|
56
|
-
* @param userId 用户 ID
|
|
57
|
-
* @param duration 超时时长(秒),0 表示取消超时
|
|
58
|
-
* @param reason 原因
|
|
59
|
-
*/
|
|
60
45
|
timeoutMember(guildId: string, userId: string, duration?: number, reason?: string): Promise<boolean>;
|
|
61
|
-
/**
|
|
62
|
-
* 修改成员昵称
|
|
63
|
-
* @param guildId 服务器 ID
|
|
64
|
-
* @param userId 用户 ID
|
|
65
|
-
* @param nickname 新昵称
|
|
66
|
-
*/
|
|
67
46
|
setNickname(guildId: string, userId: string, nickname: string): Promise<boolean>;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
getMembers(guildId: string, limit?: number): Promise<any[]>;
|
|
93
|
-
/**
|
|
94
|
-
* 获取服务器信息
|
|
95
|
-
* @param guildId 服务器 ID
|
|
96
|
-
*/
|
|
97
|
-
getGuildInfo(guildId: string): Promise<any>;
|
|
98
|
-
createThread(channelId: string, name: string, messageId?: string, autoArchiveDuration?: number): Promise<ThreadChannel>;
|
|
99
|
-
addReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
|
|
100
|
-
private resolveDiscordMessageRef;
|
|
101
|
-
$addReaction(messageId: string, emoji: string): Promise<string | null>;
|
|
102
|
-
$removeReaction(messageId: string, reactionId: string): Promise<void>;
|
|
103
|
-
sendEmbed(channelId: string, embedData: {
|
|
104
|
-
title?: string;
|
|
105
|
-
description?: string;
|
|
106
|
-
color?: number;
|
|
107
|
-
url?: string;
|
|
108
|
-
fields?: {
|
|
109
|
-
name: string;
|
|
110
|
-
value: string;
|
|
111
|
-
inline?: boolean;
|
|
112
|
-
}[];
|
|
113
|
-
}): Promise<DiscordMessage<boolean>>;
|
|
114
|
-
createForumPost(channelId: string, name: string, content: string, tags?: string[]): Promise<ThreadChannel>;
|
|
115
|
-
handleFileSegment(data: any, files: AttachmentBuilder[], textContent: string): Promise<void>;
|
|
116
|
-
createEmbedFromData(data: any): EmbedBuilder;
|
|
117
|
-
private getActivityType;
|
|
118
|
-
private registerSlashCommands;
|
|
119
|
-
addSlashCommandHandler(commandName: string, handler: (interaction: ChatInputCommandInteraction) => Promise<void>): void;
|
|
120
|
-
removeSlashCommandHandler(commandName: string): boolean;
|
|
121
|
-
private fileExists;
|
|
122
|
-
static formatContentToText(content: SendContent): string;
|
|
47
|
+
getMembers(guildId: string, limit?: number): Promise<unknown[]>;
|
|
48
|
+
getGuildInfo(guildId: string): Promise<unknown>;
|
|
49
|
+
}
|
|
50
|
+
export interface DiscordInteractionsEndpointOptions {
|
|
51
|
+
readonly id: CapabilityId;
|
|
52
|
+
readonly gateway: MessageGateway;
|
|
53
|
+
readonly http: HttpHost;
|
|
54
|
+
readonly config: ResolvedDiscordInteractionsConfig;
|
|
55
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
56
|
+
}
|
|
57
|
+
export declare class DiscordInteractionsEndpoint implements EndpointInstance {
|
|
58
|
+
#private;
|
|
59
|
+
constructor(options: DiscordInteractionsEndpointOptions);
|
|
60
|
+
get isOpen(): boolean;
|
|
61
|
+
get config(): ResolvedDiscordInteractionsConfig;
|
|
62
|
+
start(): Promise<void>;
|
|
63
|
+
open(): void;
|
|
64
|
+
close(): void;
|
|
65
|
+
stop(): Promise<void>;
|
|
66
|
+
send({ target, payload }: {
|
|
67
|
+
readonly target: string;
|
|
68
|
+
readonly payload: unknown;
|
|
69
|
+
}): Promise<string>;
|
|
70
|
+
admit(msg: DiscordInboundMessage): void;
|
|
123
71
|
}
|
|
124
|
-
//# sourceMappingURL=endpoint.d.ts.map
|