@onebots/adapter-discord 1.0.0

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.
@@ -0,0 +1,305 @@
1
+ /**
2
+ * Discord Lite Bot 客户端
3
+ * 轻量版实现,不依赖 discord.js,支持 Cloudflare Workers
4
+ */
5
+ import { EventEmitter } from 'events';
6
+ import { DiscordLite } from './index.js';
7
+ import type { DiscordREST } from './rest.js';
8
+ export interface DiscordLiteBotConfig {
9
+ /** 账号标识 */
10
+ account_id: string;
11
+ /** Discord Bot Token */
12
+ token: string;
13
+ /** Application ID (用于 Interactions 模式) */
14
+ application_id?: string;
15
+ /** Public Key (用于 Interactions 验证) */
16
+ public_key?: string;
17
+ /** 代理配置 */
18
+ proxy?: {
19
+ url: string;
20
+ username?: string;
21
+ password?: string;
22
+ };
23
+ /** 运行模式: gateway (Node.js) 或 interactions (Serverless) */
24
+ mode?: 'gateway' | 'interactions' | 'auto';
25
+ /** Gateway Intents (数值或字符串数组) */
26
+ intents?: number | string[];
27
+ }
28
+ export interface DiscordUser {
29
+ id: string;
30
+ username: string;
31
+ discriminator: string;
32
+ global_name?: string | null;
33
+ avatar: string | null;
34
+ bot?: boolean;
35
+ }
36
+ export interface DiscordMessage {
37
+ id: string;
38
+ channel_id: string;
39
+ guild_id?: string;
40
+ author: DiscordUser;
41
+ content: string;
42
+ timestamp: string;
43
+ edited_timestamp?: string | null;
44
+ tts: boolean;
45
+ mention_everyone: boolean;
46
+ mentions: DiscordUser[];
47
+ attachments: DiscordAttachment[];
48
+ embeds: any[];
49
+ pinned: boolean;
50
+ type: number;
51
+ }
52
+ export interface DiscordAttachment {
53
+ id: string;
54
+ filename: string;
55
+ size: number;
56
+ url: string;
57
+ proxy_url: string;
58
+ height?: number;
59
+ width?: number;
60
+ content_type?: string;
61
+ }
62
+ export interface DiscordGuild {
63
+ id: string;
64
+ name: string;
65
+ icon: string | null;
66
+ owner_id: string;
67
+ member_count?: number;
68
+ }
69
+ export interface DiscordChannel {
70
+ id: string;
71
+ type: number;
72
+ guild_id?: string;
73
+ name?: string;
74
+ topic?: string | null;
75
+ nsfw?: boolean;
76
+ parent_id?: string | null;
77
+ }
78
+ export interface DiscordMember {
79
+ user: DiscordUser;
80
+ nick?: string | null;
81
+ roles: string[];
82
+ joined_at: string;
83
+ premium_since?: string | null;
84
+ pending?: boolean;
85
+ communication_disabled_until?: string | null;
86
+ }
87
+ /**
88
+ * Discord Lite Bot
89
+ * 基于轻量客户端实现,兼容 Node.js 和 Cloudflare Workers
90
+ */
91
+ export declare class DiscordLiteBot extends EventEmitter {
92
+ private client;
93
+ private config;
94
+ private ready;
95
+ private user;
96
+ private guilds;
97
+ constructor(config: DiscordLiteBotConfig);
98
+ /**
99
+ * 解析 intents 配置
100
+ */
101
+ private parseIntents;
102
+ /**
103
+ * 设置事件监听器
104
+ */
105
+ private setupEventListeners;
106
+ /**
107
+ * 启动 Bot (Gateway 模式)
108
+ */
109
+ start(): Promise<void>;
110
+ /**
111
+ * 停止 Bot
112
+ */
113
+ stop(): Promise<void>;
114
+ /**
115
+ * 处理 HTTP 请求 (Interactions 模式)
116
+ */
117
+ handleRequest(request: Request): Promise<Response>;
118
+ /**
119
+ * 获取 Bot 是否就绪
120
+ */
121
+ isReady(): boolean;
122
+ /**
123
+ * 发送消息到频道
124
+ */
125
+ sendMessage(channelId: string, content: string | {
126
+ content?: string;
127
+ embeds?: any[];
128
+ files?: any[];
129
+ }): Promise<DiscordMessage>;
130
+ /**
131
+ * 发送私信
132
+ */
133
+ sendDM(userId: string, content: string | {
134
+ content?: string;
135
+ embeds?: any[];
136
+ files?: any[];
137
+ }): Promise<DiscordMessage>;
138
+ /**
139
+ * 发送 Embed 消息
140
+ */
141
+ sendEmbed(channelId: string, embeds: any[]): Promise<DiscordMessage>;
142
+ /**
143
+ * 发送带附件的消息
144
+ */
145
+ sendWithAttachments(channelId: string, content: string, _attachments: any[]): Promise<DiscordMessage>;
146
+ /**
147
+ * 编辑消息
148
+ */
149
+ editMessage(channelId: string, messageId: string, content: string): Promise<DiscordMessage>;
150
+ /**
151
+ * 删除消息
152
+ */
153
+ deleteMessage(channelId: string, messageId: string): Promise<void>;
154
+ /**
155
+ * 获取消息
156
+ */
157
+ getMessage(channelId: string, messageId: string): Promise<DiscordMessage>;
158
+ /**
159
+ * 获取消息历史
160
+ */
161
+ getMessageHistory(channelId: string, limit?: number, before?: string): Promise<Map<string, DiscordMessage>>;
162
+ /**
163
+ * 添加消息反应
164
+ */
165
+ addReaction(channelId: string, messageId: string, emoji: string): Promise<void>;
166
+ /**
167
+ * 移除消息反应
168
+ */
169
+ removeReaction(channelId: string, messageId: string, emoji: string, userId?: string): Promise<void>;
170
+ /**
171
+ * 获取机器人信息
172
+ */
173
+ getBotUser(): DiscordUser | null;
174
+ /**
175
+ * 获取用户信息
176
+ */
177
+ getUser(userId: string): Promise<DiscordUser>;
178
+ /**
179
+ * 获取成员信息
180
+ */
181
+ getMember(guildId: string, userId: string): Promise<DiscordMember>;
182
+ /**
183
+ * 获取服务器列表
184
+ */
185
+ getGuilds(): Map<string, DiscordGuild>;
186
+ /**
187
+ * 获取服务器信息
188
+ */
189
+ getGuild(guildId: string): Promise<DiscordGuild>;
190
+ /**
191
+ * 获取服务器成员列表
192
+ */
193
+ getGuildMembers(guildId: string, limit?: number): Promise<Map<string, DiscordMember>>;
194
+ /**
195
+ * 获取服务器成员信息
196
+ */
197
+ getGuildMember(guildId: string, userId: string): Promise<DiscordMember>;
198
+ /**
199
+ * 踢出成员
200
+ */
201
+ kickMember(guildId: string, userId: string, _reason?: string): Promise<void>;
202
+ /**
203
+ * 封禁成员
204
+ */
205
+ banMember(guildId: string, userId: string, options?: {
206
+ reason?: string;
207
+ deleteMessageSeconds?: number;
208
+ }): Promise<void>;
209
+ /**
210
+ * 解除封禁
211
+ */
212
+ unbanMember(guildId: string, userId: string, _reason?: string): Promise<void>;
213
+ /**
214
+ * 禁言成员(超时)
215
+ */
216
+ timeoutMember(guildId: string, userId: string, duration: number, _reason?: string): Promise<DiscordMember>;
217
+ /**
218
+ * 解除禁言
219
+ */
220
+ removeTimeout(guildId: string, userId: string, _reason?: string): Promise<DiscordMember>;
221
+ /**
222
+ * 修改成员昵称
223
+ */
224
+ setMemberNickname(guildId: string, userId: string, nickname: string | null, _reason?: string): Promise<DiscordMember>;
225
+ /**
226
+ * 添加角色
227
+ */
228
+ addRole(guildId: string, userId: string, roleId: string, _reason?: string): Promise<DiscordMember>;
229
+ /**
230
+ * 移除角色
231
+ */
232
+ removeRole(guildId: string, userId: string, roleId: string, _reason?: string): Promise<DiscordMember>;
233
+ /**
234
+ * 获取频道
235
+ */
236
+ getChannel(channelId: string): Promise<DiscordChannel | null>;
237
+ /**
238
+ * 获取服务器频道列表
239
+ */
240
+ getGuildChannels(guildId: string): Promise<Map<string, DiscordChannel>>;
241
+ /**
242
+ * 创建文本频道
243
+ */
244
+ createTextChannel(guildId: string, name: string, options?: {
245
+ topic?: string;
246
+ parent?: string;
247
+ nsfw?: boolean;
248
+ }): Promise<DiscordChannel>;
249
+ /**
250
+ * 删除频道
251
+ */
252
+ deleteChannel(channelId: string): Promise<void>;
253
+ /**
254
+ * 更新频道
255
+ */
256
+ updateChannel(channelId: string, options: {
257
+ name?: string;
258
+ topic?: string;
259
+ nsfw?: boolean;
260
+ parent?: string;
261
+ }): Promise<DiscordChannel>;
262
+ /**
263
+ * 获取服务器角色列表
264
+ */
265
+ getGuildRoles(guildId: string): Promise<Map<string, any>>;
266
+ /**
267
+ * 获取角色信息
268
+ */
269
+ getRole(guildId: string, roleId: string): Promise<any | null>;
270
+ /**
271
+ * 创建角色
272
+ */
273
+ createRole(guildId: string, options: {
274
+ name: string;
275
+ color?: number;
276
+ hoist?: boolean;
277
+ mentionable?: boolean;
278
+ permissions?: bigint;
279
+ }): Promise<any>;
280
+ /**
281
+ * 删除角色
282
+ */
283
+ deleteRole(guildId: string, roleId: string): Promise<void>;
284
+ /**
285
+ * 获取 REST 客户端
286
+ */
287
+ getREST(): DiscordREST;
288
+ /**
289
+ * 获取原始 Discord Lite 客户端
290
+ */
291
+ getClient(): DiscordLite;
292
+ /**
293
+ * 获取当前运行模式
294
+ */
295
+ getMode(): 'gateway' | 'interactions';
296
+ /**
297
+ * 包装用户对象(添加辅助方法)
298
+ */
299
+ private wrapUser;
300
+ /**
301
+ * 包装消息对象
302
+ */
303
+ private wrapMessage;
304
+ }
305
+ //# sourceMappingURL=bot.d.ts.map