@elizaos/plugin-discord 1.3.7 → 2.0.0-alpha.1
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/dist/index.d.ts +2 -942
- package/package.json +29 -28
- package/LICENSE +0 -21
- package/README.md +0 -531
- package/dist/index.js +0 -11293
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,942 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { VoiceConnection, AudioPlayer } from '@discordjs/voice';
|
|
4
|
-
import { EventEmitter } from 'node:events';
|
|
5
|
-
import { Readable } from 'node:stream';
|
|
6
|
-
|
|
7
|
-
declare const DISCORD_SERVICE_NAME = "discord";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Runtime compatibility layer for old/new core.
|
|
11
|
-
*
|
|
12
|
-
* Automatically adds serverId when messageServerId is provided,
|
|
13
|
-
* making plugin code work with both core versions unchanged.
|
|
14
|
-
*
|
|
15
|
-
* Old core expects: serverId (string)
|
|
16
|
-
* New core expects: messageServerId (UUID)
|
|
17
|
-
*
|
|
18
|
-
* NOTE: UUID function usage for Discord IDs:
|
|
19
|
-
* - `stringToUuid(str)` - CONVERTS any string to a deterministic UUID by hashing.
|
|
20
|
-
* Use this for Discord snowflake IDs (always succeeds, same input = same output).
|
|
21
|
-
* - `asUUID(str)` - VALIDATES that string is already a valid UUID format.
|
|
22
|
-
* Throws if not a valid UUID. Only use when input is already a UUID.
|
|
23
|
-
*
|
|
24
|
-
* REMOVAL: Delete this file and remove createCompatRuntime() call in service.ts
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Extended types that support messageServerId for cross-core compatibility.
|
|
29
|
-
* These allow TypeScript to accept messageServerId in object literals.
|
|
30
|
-
*/
|
|
31
|
-
type WorldCompat = Omit<World, 'serverId'> & {
|
|
32
|
-
serverId?: string;
|
|
33
|
-
messageServerId?: UUID;
|
|
34
|
-
};
|
|
35
|
-
type RoomCompat = Omit<Room, 'serverId'> & {
|
|
36
|
-
serverId?: string;
|
|
37
|
-
messageServerId?: UUID;
|
|
38
|
-
};
|
|
39
|
-
interface EnsureConnectionParams {
|
|
40
|
-
entityId: UUID;
|
|
41
|
-
roomId: UUID;
|
|
42
|
-
userName?: string;
|
|
43
|
-
name?: string;
|
|
44
|
-
worldName?: string;
|
|
45
|
-
source?: string;
|
|
46
|
-
channelId?: string;
|
|
47
|
-
serverId?: string;
|
|
48
|
-
messageServerId?: UUID;
|
|
49
|
-
type?: ChannelType | string;
|
|
50
|
-
worldId: UUID;
|
|
51
|
-
userId?: UUID;
|
|
52
|
-
metadata?: Record<string, unknown>;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Extended runtime interface that accepts messageServerId in method parameters.
|
|
56
|
-
*/
|
|
57
|
-
interface ICompatRuntime extends Omit<IAgentRuntime, 'ensureWorldExists' | 'ensureRoomExists' | 'ensureConnection' | 'ensureConnections'> {
|
|
58
|
-
ensureWorldExists(world: WorldCompat): Promise<void>;
|
|
59
|
-
ensureRoomExists(room: RoomCompat): Promise<void>;
|
|
60
|
-
ensureConnection(params: EnsureConnectionParams): Promise<void>;
|
|
61
|
-
ensureConnections(entities: Entity[], rooms: RoomCompat[], source: string, world: WorldCompat): Promise<void>;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Discord-specific event types
|
|
66
|
-
*/
|
|
67
|
-
declare enum DiscordEventTypes {
|
|
68
|
-
MESSAGE_RECEIVED = "DISCORD_MESSAGE_RECEIVED",
|
|
69
|
-
MESSAGE_SENT = "DISCORD_MESSAGE_SENT",
|
|
70
|
-
SLASH_COMMAND = "DISCORD_SLASH_COMMAND",
|
|
71
|
-
MODAL_SUBMIT = "DISCORD_MODAL_SUBMIT",
|
|
72
|
-
REACTION_RECEIVED = "DISCORD_REACTION_RECEIVED",
|
|
73
|
-
REACTION_REMOVED = "DISCORD_REACTION_REMOVED",
|
|
74
|
-
WORLD_JOINED = "DISCORD_WORLD_JOINED",
|
|
75
|
-
WORLD_CONNECTED = "DISCORD_SERVER_CONNECTED",
|
|
76
|
-
ENTITY_JOINED = "DISCORD_USER_JOINED",
|
|
77
|
-
ENTITY_LEFT = "DISCORD_USER_LEFT",
|
|
78
|
-
VOICE_STATE_CHANGED = "DISCORD_VOICE_STATE_CHANGED",
|
|
79
|
-
CHANNEL_PERMISSIONS_CHANGED = "DISCORD_CHANNEL_PERMISSIONS_CHANGED",
|
|
80
|
-
ROLE_PERMISSIONS_CHANGED = "DISCORD_ROLE_PERMISSIONS_CHANGED",
|
|
81
|
-
MEMBER_ROLES_CHANGED = "DISCORD_MEMBER_ROLES_CHANGED",
|
|
82
|
-
ROLE_CREATED = "DISCORD_ROLE_CREATED",
|
|
83
|
-
ROLE_DELETED = "DISCORD_ROLE_DELETED"
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Permission state in an overwrite or role
|
|
87
|
-
*/
|
|
88
|
-
type PermissionState = "ALLOW" | "DENY" | "NEUTRAL";
|
|
89
|
-
/**
|
|
90
|
-
* A single permission change
|
|
91
|
-
*/
|
|
92
|
-
interface PermissionDiff {
|
|
93
|
-
/** The permission name (e.g., 'ManageMessages', 'Administrator') */
|
|
94
|
-
permission: string;
|
|
95
|
-
/** Previous state */
|
|
96
|
-
oldState: PermissionState;
|
|
97
|
-
/** New state */
|
|
98
|
-
newState: PermissionState;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Information about who made a change, from audit logs
|
|
102
|
-
*/
|
|
103
|
-
interface AuditInfo {
|
|
104
|
-
/** Discord user ID of the executor */
|
|
105
|
-
executorId: string;
|
|
106
|
-
/** Discord username#discriminator or username of the executor */
|
|
107
|
-
executorTag: string;
|
|
108
|
-
/** Reason provided for the action, if any */
|
|
109
|
-
reason: string | null;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Minimal runtime interface for permission payloads.
|
|
113
|
-
* Using a minimal interface avoids version mismatches across packages.
|
|
114
|
-
*/
|
|
115
|
-
interface PermissionPayloadRuntime {
|
|
116
|
-
getService(name: string): unknown;
|
|
117
|
-
getSetting(key: string): unknown;
|
|
118
|
-
logger: {
|
|
119
|
-
debug(msg: string): void;
|
|
120
|
-
info(msg: string): void;
|
|
121
|
-
warn(msg: string): void;
|
|
122
|
-
error(msg: string): void;
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Payload for DISCORD_CHANNEL_PERMISSIONS_CHANGED event
|
|
127
|
-
* Emitted when channel permission overwrites are created, updated, or deleted
|
|
128
|
-
*/
|
|
129
|
-
interface ChannelPermissionsChangedPayload {
|
|
130
|
-
/** Runtime instance */
|
|
131
|
-
runtime: PermissionPayloadRuntime;
|
|
132
|
-
/** Guild information */
|
|
133
|
-
guild: {
|
|
134
|
-
id: string;
|
|
135
|
-
name: string;
|
|
136
|
-
};
|
|
137
|
-
/** Channel where permissions changed */
|
|
138
|
-
channel: {
|
|
139
|
-
id: string;
|
|
140
|
-
name: string;
|
|
141
|
-
};
|
|
142
|
-
/** Target of the permission overwrite (role or user) */
|
|
143
|
-
target: {
|
|
144
|
-
type: "role" | "user";
|
|
145
|
-
id: string;
|
|
146
|
-
name: string;
|
|
147
|
-
};
|
|
148
|
-
/** What happened to the overwrite */
|
|
149
|
-
action: "CREATE" | "UPDATE" | "DELETE";
|
|
150
|
-
/** List of permission changes */
|
|
151
|
-
changes: PermissionDiff[];
|
|
152
|
-
/** Audit log info (null if unavailable) */
|
|
153
|
-
audit: AuditInfo | null;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* Payload for DISCORD_ROLE_PERMISSIONS_CHANGED event
|
|
157
|
-
* Emitted when a role's permissions are modified
|
|
158
|
-
*/
|
|
159
|
-
interface RolePermissionsChangedPayload {
|
|
160
|
-
/** Runtime instance */
|
|
161
|
-
runtime: PermissionPayloadRuntime;
|
|
162
|
-
/** Guild information */
|
|
163
|
-
guild: {
|
|
164
|
-
id: string;
|
|
165
|
-
name: string;
|
|
166
|
-
};
|
|
167
|
-
/** Role that was modified */
|
|
168
|
-
role: {
|
|
169
|
-
id: string;
|
|
170
|
-
name: string;
|
|
171
|
-
};
|
|
172
|
-
/** List of permission changes */
|
|
173
|
-
changes: PermissionDiff[];
|
|
174
|
-
/** Audit log info (null if unavailable) */
|
|
175
|
-
audit: AuditInfo | null;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Payload for DISCORD_MEMBER_ROLES_CHANGED event
|
|
179
|
-
* Emitted when roles are added or removed from a member
|
|
180
|
-
*/
|
|
181
|
-
interface MemberRolesChangedPayload {
|
|
182
|
-
/** Runtime instance */
|
|
183
|
-
runtime: PermissionPayloadRuntime;
|
|
184
|
-
/** Guild information */
|
|
185
|
-
guild: {
|
|
186
|
-
id: string;
|
|
187
|
-
name: string;
|
|
188
|
-
};
|
|
189
|
-
/** Member whose roles changed */
|
|
190
|
-
member: {
|
|
191
|
-
id: string;
|
|
192
|
-
tag: string;
|
|
193
|
-
};
|
|
194
|
-
/** Roles that were added */
|
|
195
|
-
added: Array<{
|
|
196
|
-
id: string;
|
|
197
|
-
name: string;
|
|
198
|
-
permissions: string[];
|
|
199
|
-
}>;
|
|
200
|
-
/** Roles that were removed */
|
|
201
|
-
removed: Array<{
|
|
202
|
-
id: string;
|
|
203
|
-
name: string;
|
|
204
|
-
permissions: string[];
|
|
205
|
-
}>;
|
|
206
|
-
/** Audit log info (null if unavailable) */
|
|
207
|
-
audit: AuditInfo | null;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Payload for DISCORD_ROLE_CREATED and DISCORD_ROLE_DELETED events
|
|
211
|
-
*/
|
|
212
|
-
interface RoleLifecyclePayload {
|
|
213
|
-
/** Runtime instance */
|
|
214
|
-
runtime: PermissionPayloadRuntime;
|
|
215
|
-
/** Guild information */
|
|
216
|
-
guild: {
|
|
217
|
-
id: string;
|
|
218
|
-
name: string;
|
|
219
|
-
};
|
|
220
|
-
/** Role that was created or deleted */
|
|
221
|
-
role: {
|
|
222
|
-
id: string;
|
|
223
|
-
name: string;
|
|
224
|
-
permissions: string[];
|
|
225
|
-
};
|
|
226
|
-
/** Audit log info (null if unavailable) */
|
|
227
|
-
audit: AuditInfo | null;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Interface representing a Discord service.
|
|
231
|
-
*
|
|
232
|
-
* @typedef {Object} IDiscordService
|
|
233
|
-
* @property {DiscordJsClient} client - The Discord client object.
|
|
234
|
-
* @property {Character} character - The character object.
|
|
235
|
-
*/
|
|
236
|
-
interface IDiscordService {
|
|
237
|
-
client: Client | null;
|
|
238
|
-
character: Character;
|
|
239
|
-
getChannelType: (channel: Channel) => Promise<ChannelType>;
|
|
240
|
-
buildMemoryFromMessage: (message: Message, options?: {
|
|
241
|
-
processedContent?: string;
|
|
242
|
-
processedAttachments?: Media[];
|
|
243
|
-
extraContent?: Record<string, any>;
|
|
244
|
-
extraMetadata?: Record<string, any>;
|
|
245
|
-
}) => Promise<Memory | null>;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Batch handler for processing messages as they arrive during history fetch
|
|
249
|
-
* @returns false to stop fetching early, void/true to continue
|
|
250
|
-
*/
|
|
251
|
-
type BatchHandler = (batch: Memory[], stats: {
|
|
252
|
-
page: number;
|
|
253
|
-
totalFetched: number;
|
|
254
|
-
totalStored: number;
|
|
255
|
-
}) => Promise<boolean | void> | boolean | void;
|
|
256
|
-
/**
|
|
257
|
-
* Options for fetching channel history
|
|
258
|
-
*/
|
|
259
|
-
interface ChannelHistoryOptions {
|
|
260
|
-
/** Maximum number of messages to fetch (default: unlimited) */
|
|
261
|
-
limit?: number;
|
|
262
|
-
/** Force re-fetch, ignoring spider state */
|
|
263
|
-
force?: boolean;
|
|
264
|
-
/** Callback to process each batch of messages as they arrive */
|
|
265
|
-
onBatch?: BatchHandler;
|
|
266
|
-
/** Start fetching before this message ID */
|
|
267
|
-
before?: string;
|
|
268
|
-
/** Start fetching after this message ID (for catching up) */
|
|
269
|
-
after?: string;
|
|
270
|
-
}
|
|
271
|
-
/**
|
|
272
|
-
* Result from fetching channel history
|
|
273
|
-
*/
|
|
274
|
-
interface ChannelHistoryResult {
|
|
275
|
-
/** Fetched messages (empty if onBatch was used) */
|
|
276
|
-
messages: Memory[];
|
|
277
|
-
/** Statistics about the fetch operation */
|
|
278
|
-
stats: {
|
|
279
|
-
/** Total messages fetched from Discord */
|
|
280
|
-
fetched: number;
|
|
281
|
-
/** Total messages stored/processed */
|
|
282
|
-
stored: number;
|
|
283
|
-
/** Number of pages fetched */
|
|
284
|
-
pages: number;
|
|
285
|
-
/** Whether the channel is now fully backfilled */
|
|
286
|
-
fullyBackfilled: boolean;
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Class representing a Message Manager for handling Discord messages.
|
|
292
|
-
*/
|
|
293
|
-
declare class MessageManager {
|
|
294
|
-
private client;
|
|
295
|
-
private runtime;
|
|
296
|
-
private attachmentManager;
|
|
297
|
-
private getChannelType;
|
|
298
|
-
private discordSettings;
|
|
299
|
-
private discordService;
|
|
300
|
-
/**
|
|
301
|
-
* Constructor for a new instance of MessageManager.
|
|
302
|
-
* @param {IDiscordService} discordService - The Discord service instance.
|
|
303
|
-
* @param {ICompatRuntime} runtime - The agent runtime instance (with cross-core compat).
|
|
304
|
-
* @throws {Error} If the Discord client is not initialized
|
|
305
|
-
*/
|
|
306
|
-
constructor(discordService: IDiscordService, runtime: ICompatRuntime);
|
|
307
|
-
/**
|
|
308
|
-
* Handles incoming Discord messages and processes them accordingly.
|
|
309
|
-
*
|
|
310
|
-
* @param {DiscordMessage} message - The Discord message to be handled
|
|
311
|
-
*/
|
|
312
|
-
handleMessage(message: Message): Promise<void>;
|
|
313
|
-
/**
|
|
314
|
-
* Processes the message content, mentions, code blocks, attachments, and URLs to generate
|
|
315
|
-
* processed content and media attachments.
|
|
316
|
-
*
|
|
317
|
-
* @param {DiscordMessage} message The message to process
|
|
318
|
-
* @returns {Promise<{ processedContent: string; attachments: Media[] }>} Processed content and media attachments
|
|
319
|
-
*/
|
|
320
|
-
processMessage(message: Message): Promise<{
|
|
321
|
-
processedContent: string;
|
|
322
|
-
attachments: Media[];
|
|
323
|
-
}>;
|
|
324
|
-
/**
|
|
325
|
-
* Asynchronously fetches the bot's username and discriminator from Discord API.
|
|
326
|
-
*
|
|
327
|
-
* @param {string} botToken The token of the bot to authenticate the request
|
|
328
|
-
* @returns {Promise<string>} A promise that resolves with the bot's username and discriminator
|
|
329
|
-
* @throws {Error} If there is an error while fetching the bot details
|
|
330
|
-
*/
|
|
331
|
-
fetchBotName(botToken: string): Promise<string>;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Class representing a VoiceManager that extends EventEmitter.
|
|
336
|
-
* @extends EventEmitter
|
|
337
|
-
*/
|
|
338
|
-
declare class VoiceManager extends EventEmitter {
|
|
339
|
-
private processingVoice;
|
|
340
|
-
private transcriptionTimeout;
|
|
341
|
-
private userStates;
|
|
342
|
-
private activeAudioPlayer;
|
|
343
|
-
private client;
|
|
344
|
-
private runtime;
|
|
345
|
-
private streams;
|
|
346
|
-
private connections;
|
|
347
|
-
private activeMonitors;
|
|
348
|
-
private ready;
|
|
349
|
-
/**
|
|
350
|
-
* Constructor for initializing a new instance of the class.
|
|
351
|
-
*
|
|
352
|
-
* @param {DiscordService} service - The Discord service to use.
|
|
353
|
-
* @param {ICompatRuntime} runtime - The runtime for the agent (with cross-core compat).
|
|
354
|
-
*/
|
|
355
|
-
constructor(service: DiscordService, runtime: ICompatRuntime);
|
|
356
|
-
/**
|
|
357
|
-
* Asynchronously retrieves the type of the channel.
|
|
358
|
-
* @param {Channel} channel - The channel to get the type for.
|
|
359
|
-
* @returns {Promise<ChannelType>} The type of the channel.
|
|
360
|
-
*/
|
|
361
|
-
getChannelType(channel: Channel): Promise<ChannelType>;
|
|
362
|
-
/**
|
|
363
|
-
* Set the ready status of the VoiceManager.
|
|
364
|
-
* @param {boolean} status - The status to set.
|
|
365
|
-
*/
|
|
366
|
-
private setReady;
|
|
367
|
-
/**
|
|
368
|
-
* Check if the object is ready.
|
|
369
|
-
*
|
|
370
|
-
* @returns {boolean} True if the object is ready, false otherwise.
|
|
371
|
-
*/
|
|
372
|
-
isReady(): boolean;
|
|
373
|
-
/**
|
|
374
|
-
* Handle voice state update event.
|
|
375
|
-
* @param {VoiceState} oldState - The old voice state of the member.
|
|
376
|
-
* @param {VoiceState} newState - The new voice state of the member.
|
|
377
|
-
* @returns {void}
|
|
378
|
-
*/
|
|
379
|
-
handleVoiceStateUpdate(oldState: VoiceState, newState: VoiceState): Promise<void>;
|
|
380
|
-
/**
|
|
381
|
-
* Joins a voice channel and sets up the necessary connection and event listeners.
|
|
382
|
-
* @param {BaseGuildVoiceChannel} channel - The voice channel to join
|
|
383
|
-
*/
|
|
384
|
-
joinChannel(channel: BaseGuildVoiceChannel): Promise<void>;
|
|
385
|
-
/**
|
|
386
|
-
* Retrieves the voice connection for a given guild ID.
|
|
387
|
-
* @param {string} guildId - The ID of the guild to get the voice connection for.
|
|
388
|
-
* @returns {VoiceConnection | undefined} The voice connection for the specified guild ID, or undefined if not found.
|
|
389
|
-
*/
|
|
390
|
-
getVoiceConnection(guildId: string): VoiceConnection | undefined;
|
|
391
|
-
/**
|
|
392
|
-
* Monitor a member's audio stream for volume activity and speaking thresholds.
|
|
393
|
-
*
|
|
394
|
-
* @param {GuildMember} member - The member whose audio stream is being monitored.
|
|
395
|
-
* @param {BaseGuildVoiceChannel} channel - The voice channel in which the member is connected.
|
|
396
|
-
*/
|
|
397
|
-
private monitorMember;
|
|
398
|
-
/**
|
|
399
|
-
* Leaves the specified voice channel and stops monitoring all members in that channel.
|
|
400
|
-
* If there is an active connection in the channel, it will be destroyed.
|
|
401
|
-
*
|
|
402
|
-
* @param {BaseGuildVoiceChannel} channel - The voice channel to leave.
|
|
403
|
-
*/
|
|
404
|
-
leaveChannel(channel: BaseGuildVoiceChannel): void;
|
|
405
|
-
/**
|
|
406
|
-
* Stop monitoring a specific member by their member ID.
|
|
407
|
-
* @param {string} memberId - The ID of the member to stop monitoring.
|
|
408
|
-
*/
|
|
409
|
-
stopMonitoringMember(memberId: string): void;
|
|
410
|
-
/**
|
|
411
|
-
* Asynchronously debounces the process transcription function to prevent rapid execution.
|
|
412
|
-
*
|
|
413
|
-
* @param {UUID} entityId - The ID of the entity related to the transcription.
|
|
414
|
-
* @param {string} name - The name of the entity for transcription.
|
|
415
|
-
* @param {string} userName - The username of the user initiating the transcription.
|
|
416
|
-
* @param {BaseGuildVoiceChannel} channel - The voice channel where the transcription is happening.
|
|
417
|
-
*/
|
|
418
|
-
debouncedProcessTranscription(entityId: UUID, name: string, userName: string, channel: BaseGuildVoiceChannel): Promise<void>;
|
|
419
|
-
/**
|
|
420
|
-
* Handle user audio stream for monitoring purposes.
|
|
421
|
-
*
|
|
422
|
-
* @param {UUID} userId - The unique identifier of the user.
|
|
423
|
-
* @param {string} name - The name of the user.
|
|
424
|
-
* @param {string} userName - The username of the user.
|
|
425
|
-
* @param {BaseGuildVoiceChannel} channel - The voice channel the user is in.
|
|
426
|
-
* @param {Readable} audioStream - The audio stream to monitor.
|
|
427
|
-
*/
|
|
428
|
-
handleUserStream(entityId: UUID, name: string, userName: string, channel: BaseGuildVoiceChannel, audioStream: Readable): Promise<void>;
|
|
429
|
-
/**
|
|
430
|
-
* Process the transcription of audio data for a user.
|
|
431
|
-
*
|
|
432
|
-
* @param {UUID} entityId - The unique ID of the user entity.
|
|
433
|
-
* @param {string} channelId - The ID of the channel where the transcription is taking place.
|
|
434
|
-
* @param {BaseGuildVoiceChannel} channel - The voice channel where the user is speaking.
|
|
435
|
-
* @param {string} name - The name of the user.
|
|
436
|
-
* @param {string} userName - The username of the user.
|
|
437
|
-
* @returns {Promise<void>}
|
|
438
|
-
*/
|
|
439
|
-
private processTranscription;
|
|
440
|
-
/**
|
|
441
|
-
* Handles a voice message received in a Discord channel.
|
|
442
|
-
*
|
|
443
|
-
* @param {string} message - The message content.
|
|
444
|
-
* @param {UUID} entityId - The entity ID associated with the message.
|
|
445
|
-
* @param {string} channelId - The ID of the Discord channel where the message was received.
|
|
446
|
-
* @param {BaseGuildVoiceChannel} channel - The Discord channel where the message was received.
|
|
447
|
-
* @param {string} name - The name associated with the message.
|
|
448
|
-
* @param {string} userName - The user name associated with the message.
|
|
449
|
-
* @returns {Promise<{text: string, actions: string[]}>} Object containing the resulting text and actions.
|
|
450
|
-
*/
|
|
451
|
-
private handleMessage;
|
|
452
|
-
/**
|
|
453
|
-
* Asynchronously converts an Opus audio Buffer to a WAV audio Buffer.
|
|
454
|
-
*
|
|
455
|
-
* @param {Buffer} pcmBuffer - The Opus audio Buffer to convert to WAV.
|
|
456
|
-
* @returns {Promise<Buffer>} A Promise that resolves with the converted WAV audio Buffer.
|
|
457
|
-
*/
|
|
458
|
-
private convertOpusToWav;
|
|
459
|
-
/**
|
|
460
|
-
* Scans the given Discord guild to select a suitable voice channel to join.
|
|
461
|
-
*
|
|
462
|
-
* @param {Guild} guild The Discord guild to scan for voice channels.
|
|
463
|
-
*/
|
|
464
|
-
scanGuild(guild: Guild): Promise<void>;
|
|
465
|
-
/**
|
|
466
|
-
* Play an audio stream for a given entity ID.
|
|
467
|
-
*
|
|
468
|
-
* @param {UUID} entityId - The ID of the entity to play the audio for.
|
|
469
|
-
* @param {Readable} audioStream - The audio stream to play.
|
|
470
|
-
* @returns {void}
|
|
471
|
-
*/
|
|
472
|
-
playAudioStream(entityId: UUID, audioStream: Readable): Promise<void>;
|
|
473
|
-
/**
|
|
474
|
-
* Cleans up the provided audio player by stopping it, removing all listeners,
|
|
475
|
-
* and resetting the active audio player if it matches the provided player.
|
|
476
|
-
*
|
|
477
|
-
* @param {AudioPlayer} audioPlayer - The audio player to be cleaned up.
|
|
478
|
-
*/
|
|
479
|
-
cleanupAudioPlayer(audioPlayer: AudioPlayer | null): void;
|
|
480
|
-
/**
|
|
481
|
-
* Asynchronously handles the join channel command in an interaction.
|
|
482
|
-
*
|
|
483
|
-
* @param {any} interaction - The interaction object representing the user's input.
|
|
484
|
-
* @returns {Promise<void>} - A promise that resolves once the join channel command is handled.
|
|
485
|
-
*/
|
|
486
|
-
handleJoinChannelCommand(interaction: any): Promise<void>;
|
|
487
|
-
/**
|
|
488
|
-
* Handles the leave channel command by destroying the voice connection if it exists.
|
|
489
|
-
*
|
|
490
|
-
* @param {any} interaction The interaction object representing the command invocation.
|
|
491
|
-
* @returns {void}
|
|
492
|
-
*/
|
|
493
|
-
handleLeaveChannelCommand(interaction: any): Promise<void>;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* DiscordService class representing a service for interacting with Discord.
|
|
498
|
-
* @extends Service
|
|
499
|
-
* @implements IDiscordService
|
|
500
|
-
* @property {string} serviceType - The type of service, set to DISCORD_SERVICE_NAME.
|
|
501
|
-
* @property {string} capabilityDescription - A description of the service's capabilities.
|
|
502
|
-
* @property {DiscordJsClient} client - The DiscordJsClient used for communication.
|
|
503
|
-
* @property {Character} character - The character associated with the service.
|
|
504
|
-
* @property {MessageManager} messageManager - The manager for handling messages.
|
|
505
|
-
* @property {VoiceManager} voiceManager - The manager for handling voice communication.
|
|
506
|
-
*/
|
|
507
|
-
declare class DiscordService extends Service implements IDiscordService {
|
|
508
|
-
protected runtime: ICompatRuntime;
|
|
509
|
-
static serviceType: string;
|
|
510
|
-
capabilityDescription: string;
|
|
511
|
-
client: Client | null;
|
|
512
|
-
character: Character;
|
|
513
|
-
messageManager?: MessageManager;
|
|
514
|
-
voiceManager?: VoiceManager;
|
|
515
|
-
private discordSettings;
|
|
516
|
-
private userSelections;
|
|
517
|
-
private timeouts;
|
|
518
|
-
clientReadyPromise: Promise<void> | null;
|
|
519
|
-
private slashCommands;
|
|
520
|
-
private commandRegistrationQueue;
|
|
521
|
-
/**
|
|
522
|
-
* Slash command names that should bypass allowed channel restrictions.
|
|
523
|
-
*/
|
|
524
|
-
private allowAllSlashCommands;
|
|
525
|
-
/**
|
|
526
|
-
* List of allowed channel IDs (parsed from CHANNEL_IDS env var).
|
|
527
|
-
* If undefined, all channels are allowed.
|
|
528
|
-
*/
|
|
529
|
-
private allowedChannelIds?;
|
|
530
|
-
/**
|
|
531
|
-
* Set of dynamically added channel IDs through joinChannel action.
|
|
532
|
-
* These are merged with allowedChannelIds for runtime channel management.
|
|
533
|
-
*/
|
|
534
|
-
private dynamicChannelIds;
|
|
535
|
-
/**
|
|
536
|
-
* Constructor for Discord client.
|
|
537
|
-
* Initializes the Discord client with specified intents and partials,
|
|
538
|
-
* sets up event listeners, and ensures all servers exist.
|
|
539
|
-
*
|
|
540
|
-
* @param {IAgentRuntime} runtime - The AgentRuntime instance
|
|
541
|
-
*/
|
|
542
|
-
constructor(runtime: IAgentRuntime);
|
|
543
|
-
static start(runtime: IAgentRuntime): Promise<DiscordService>;
|
|
544
|
-
/**
|
|
545
|
-
* The SendHandlerFunction implementation for Discord.
|
|
546
|
-
* @param {IAgentRuntime} runtime - The runtime instance.
|
|
547
|
-
* @param {TargetInfo} target - The target information for the message.
|
|
548
|
-
* @param {Content} content - The content of the message to send.
|
|
549
|
-
* @returns {Promise<void>} A promise that resolves when the message is sent or rejects on error.
|
|
550
|
-
* @throws {Error} If the client is not ready, target is invalid, or sending fails.
|
|
551
|
-
*/
|
|
552
|
-
handleSendMessage(runtime: IAgentRuntime, target: TargetInfo, content: Content): Promise<void>;
|
|
553
|
-
/**
|
|
554
|
-
* Set up event listeners for the client.
|
|
555
|
-
* @private
|
|
556
|
-
*/
|
|
557
|
-
private setupEventListeners;
|
|
558
|
-
/**
|
|
559
|
-
* Handles the event when a new member joins a guild.
|
|
560
|
-
*
|
|
561
|
-
* **Event Design Note:**
|
|
562
|
-
* We intentionally do NOT emit the standardized `EventType.ENTITY_JOINED` here.
|
|
563
|
-
* In ElizaOS's abstraction model:
|
|
564
|
-
* - A Discord "guild" maps to a "world" (the server/community)
|
|
565
|
-
* - A Discord "channel" maps to a "room" (a specific conversation space)
|
|
566
|
-
*
|
|
567
|
-
* `EventType.ENTITY_JOINED` requires a `roomId` because the bootstrap plugin's
|
|
568
|
-
* handler calls `syncSingleUser()` to sync the entity to a specific room. When
|
|
569
|
-
* a member joins a guild, they've joined the "world" but haven't joined any
|
|
570
|
-
* specific "room" yet - they're just a potential participant.
|
|
571
|
-
*
|
|
572
|
-
* The entity will be properly synced to rooms when they first interact:
|
|
573
|
-
* - First message in a channel → message handler calls `ensureConnection()`
|
|
574
|
-
* - Joining a voice channel → voice handler syncs them to that room
|
|
575
|
-
*
|
|
576
|
-
* We still emit the Discord-specific `DiscordEventTypes.ENTITY_JOINED` so that
|
|
577
|
-
* Discord-aware plugins can react to guild member joins (e.g., welcome messages,
|
|
578
|
-
* role assignment, moderation checks).
|
|
579
|
-
*
|
|
580
|
-
* @param {GuildMember} member - The GuildMember object representing the new member.
|
|
581
|
-
* @returns {Promise<void>} - A Promise that resolves once the event handling is complete.
|
|
582
|
-
* @private
|
|
583
|
-
*/
|
|
584
|
-
private handleGuildMemberAdd;
|
|
585
|
-
/**
|
|
586
|
-
* Registers slash commands with Discord.
|
|
587
|
-
*
|
|
588
|
-
* This method uses a hybrid permission system that combines:
|
|
589
|
-
* 1. Discord's native permission features (default_member_permissions, contexts)
|
|
590
|
-
* 2. ElizaOS channel whitelist bypass (bypassChannelWhitelist flag)
|
|
591
|
-
* 3. Custom validation functions (validator callback)
|
|
592
|
-
*
|
|
593
|
-
* ## Design Decisions
|
|
594
|
-
*
|
|
595
|
-
* ### Why Hybrid Approach?
|
|
596
|
-
* - Discord's native permissions are powerful but limited to role-based access
|
|
597
|
-
* - ElizaOS needs programmatic control for channel restrictions and custom logic
|
|
598
|
-
* - Combining both gives developers the best of both worlds
|
|
599
|
-
*
|
|
600
|
-
* ### Why Transform Simple Flags?
|
|
601
|
-
* - Developer experience: `guildOnly: true` is clearer than `contexts: [0]`
|
|
602
|
-
* - Abstraction: Shields developers from Discord API changes
|
|
603
|
-
* - Sensible defaults: Zero config should "just work"
|
|
604
|
-
*
|
|
605
|
-
* ### Why Three Registration Categories?
|
|
606
|
-
*
|
|
607
|
-
* Commands are categorized based on where they should be available:
|
|
608
|
-
*
|
|
609
|
-
* 1. **Global commands** (no guildOnly, no guildIds):
|
|
610
|
-
* - Registered globally via `application.commands.set()` for DM access
|
|
611
|
-
* - ALSO registered per-guild for instant availability in guilds
|
|
612
|
-
* - Guild version overrides global (no duplicates shown in Discord)
|
|
613
|
-
* - Best of both worlds: instant in guilds + works in DMs
|
|
614
|
-
*
|
|
615
|
-
* 2. **Guild-only commands** (guildOnly: true or contexts: [0]):
|
|
616
|
-
* - Registered per-guild via `application.commands.set(cmds, guildId)`
|
|
617
|
-
* - NOT available in DMs (correct behavior)
|
|
618
|
-
* - Instant availability in guilds
|
|
619
|
-
* - New guilds get commands via guildCreate event
|
|
620
|
-
*
|
|
621
|
-
* 3. **Targeted commands** (has guildIds array):
|
|
622
|
-
* - Registered only to specified guilds via `.create()` or `.edit()`
|
|
623
|
-
* - Useful for testing or server-specific features
|
|
624
|
-
* - Instant updates
|
|
625
|
-
*
|
|
626
|
-
* ### Why Register Global Commands Both Globally AND Per-Guild?
|
|
627
|
-
* - Global registration alone takes up to 1 hour to propagate (Discord limitation)
|
|
628
|
-
* - Per-guild registration gives instant availability
|
|
629
|
-
* - Guild commands override global ones in that guild (no duplicates)
|
|
630
|
-
* - Global registration still needed for DM access (no guild context in DMs)
|
|
631
|
-
*
|
|
632
|
-
* ### Why Not Register Everything Per-Guild Only?
|
|
633
|
-
* - Commands that work in DMs MUST be registered globally
|
|
634
|
-
* - There's no guild context in DMs, so per-guild commands don't appear there
|
|
635
|
-
*
|
|
636
|
-
* @param commands - Array of slash commands to register
|
|
637
|
-
* @returns Promise that resolves when registration is complete
|
|
638
|
-
* @private
|
|
639
|
-
*/
|
|
640
|
-
private registerSlashCommands;
|
|
641
|
-
/**
|
|
642
|
-
* Transforms an ElizaOS slash command to Discord API format.
|
|
643
|
-
* This bridges our developer-friendly API with Discord's native requirements.
|
|
644
|
-
* @param {DiscordSlashCommand} cmd - The ElizaOS command definition
|
|
645
|
-
* @returns {object} Discord API compatible command object
|
|
646
|
-
* @private
|
|
647
|
-
*/
|
|
648
|
-
private transformCommandToDiscordApi;
|
|
649
|
-
/**
|
|
650
|
-
* Checks if a command is guild-only (shouldn't appear in DMs).
|
|
651
|
-
*
|
|
652
|
-
* A command is considered guild-only if:
|
|
653
|
-
* - `contexts: [0]` is set (Discord's native format, where 0 = Guild only)
|
|
654
|
-
* - `guildOnly: true` is set AND no contexts override is provided
|
|
655
|
-
*
|
|
656
|
-
* Note: `contexts` takes precedence over `guildOnly` to be consistent with
|
|
657
|
-
* `transformCommandToDiscordApi`. This means { guildOnly: true, contexts: [0, 1] }
|
|
658
|
-
* will correctly enable DM access (not be treated as guild-only).
|
|
659
|
-
*
|
|
660
|
-
* @param {DiscordSlashCommand} cmd - The command to check
|
|
661
|
-
* @returns {boolean} True if the command should only be available in guilds
|
|
662
|
-
* @private
|
|
663
|
-
*/
|
|
664
|
-
private isGuildOnlyCommand;
|
|
665
|
-
/**
|
|
666
|
-
* Handles the event when the bot joins a guild. It logs the guild name, fetches additional information about the guild, scans the guild for voice data, creates standardized world data structure, generates unique IDs, and emits events to the runtime.
|
|
667
|
-
* @param {Guild} guild - The guild that the bot has joined.
|
|
668
|
-
* @returns {Promise<void>} A promise that resolves when the guild creation is handled.
|
|
669
|
-
* @private
|
|
670
|
-
*/
|
|
671
|
-
private handleGuildCreate;
|
|
672
|
-
/**
|
|
673
|
-
* Handles interactions created by the user, specifically commands and message components.
|
|
674
|
-
* @param {Interaction} interaction - The interaction object received.
|
|
675
|
-
* @returns {Promise<void>} A promise that resolves when the interaction is handled.
|
|
676
|
-
* @private
|
|
677
|
-
*/
|
|
678
|
-
private handleInteractionCreate;
|
|
679
|
-
/**
|
|
680
|
-
* Builds a standardized list of rooms from Discord guild channels.
|
|
681
|
-
*
|
|
682
|
-
* @param {Guild} guild The guild to build rooms for.
|
|
683
|
-
* @param {UUID} _worldId The ID of the world to associate with the rooms (currently unused in favor of direct channel to room mapping).
|
|
684
|
-
* @returns {Promise<any[]>} An array of standardized room objects.
|
|
685
|
-
* @private
|
|
686
|
-
*/
|
|
687
|
-
private buildStandardizedRooms;
|
|
688
|
-
/**
|
|
689
|
-
* Builds a standardized list of users (entities) from Discord guild members.
|
|
690
|
-
* Implements different strategies based on guild size for performance.
|
|
691
|
-
*
|
|
692
|
-
* @param {Guild} guild - The guild from which to build the user list.
|
|
693
|
-
* @returns {Promise<Entity[]>} A promise that resolves with an array of standardized entity objects.
|
|
694
|
-
* @private
|
|
695
|
-
*/
|
|
696
|
-
private buildStandardizedUsers;
|
|
697
|
-
/**
|
|
698
|
-
* Handles tasks to be performed once the Discord client is fully ready and connected.
|
|
699
|
-
* This includes fetching guilds, scanning for voice data, and emitting connection events.
|
|
700
|
-
* @private
|
|
701
|
-
* @returns {Promise<void>} A promise that resolves when all on-ready tasks are completed.
|
|
702
|
-
*/
|
|
703
|
-
private onReady;
|
|
704
|
-
/**
|
|
705
|
-
* Registers send handlers for the Discord service instance.
|
|
706
|
-
* This allows the runtime to correctly dispatch messages to this service.
|
|
707
|
-
* @param {IAgentRuntime} runtime - The agent runtime instance.
|
|
708
|
-
* @param {DiscordService} serviceInstance - The instance of the DiscordService.
|
|
709
|
-
* @static
|
|
710
|
-
*/
|
|
711
|
-
static registerSendHandlers(runtime: IAgentRuntime, serviceInstance: DiscordService): void;
|
|
712
|
-
/**
|
|
713
|
-
* Fetches all members who have access to a specific text channel.
|
|
714
|
-
*
|
|
715
|
-
* @param {string} channelId - The Discord ID of the text channel.
|
|
716
|
-
* @param {boolean} [useCache=true] - Whether to prioritize cached data. Defaults to true.
|
|
717
|
-
* @returns {Promise<Array<{id: string, username: string, displayName: string}>>} A promise that resolves with an array of channel member objects, each containing id, username, and displayName.
|
|
718
|
-
*/
|
|
719
|
-
getTextChannelMembers(channelId: string, useCache?: boolean): Promise<Array<{
|
|
720
|
-
id: string;
|
|
721
|
-
username: string;
|
|
722
|
-
displayName: string;
|
|
723
|
-
}>>;
|
|
724
|
-
/**
|
|
725
|
-
* Fetches the topic/description of a Discord text channel.
|
|
726
|
-
*
|
|
727
|
-
* WHY THIS METHOD EXISTS:
|
|
728
|
-
* =======================
|
|
729
|
-
* Room metadata contains topic from initial sync, but channel topics can change.
|
|
730
|
-
* This method lets plugins fetch FRESH topic data directly from Discord API.
|
|
731
|
-
*
|
|
732
|
-
* Used by plugin-content-seeder to get authoritative topic data for discussion seeding.
|
|
733
|
-
*
|
|
734
|
-
* WHY NOT JUST USE METADATA:
|
|
735
|
-
* Room.metadata.topic is set at sync time and may be stale if the Discord admin
|
|
736
|
-
* updates the channel topic. For plugins that care about freshness, this method
|
|
737
|
-
* provides a way to get current data.
|
|
738
|
-
*
|
|
739
|
-
* TRADEOFF: This makes an API call, so it's slower than reading metadata.
|
|
740
|
-
* Use metadata for most cases, this method when freshness matters.
|
|
741
|
-
*
|
|
742
|
-
* @param {string} channelId - The Discord ID of the text channel.
|
|
743
|
-
* @returns {Promise<string | null>} The channel topic, or null if not available.
|
|
744
|
-
*/
|
|
745
|
-
getChannelTopic(channelId: string): Promise<string | null>;
|
|
746
|
-
/**
|
|
747
|
-
* Generic handler for reaction events (add/remove).
|
|
748
|
-
* @private
|
|
749
|
-
*/
|
|
750
|
-
private handleReaction;
|
|
751
|
-
/**
|
|
752
|
-
* Handles reaction addition.
|
|
753
|
-
* @private
|
|
754
|
-
*/
|
|
755
|
-
private handleReactionAdd;
|
|
756
|
-
/**
|
|
757
|
-
* Handles reaction removal.
|
|
758
|
-
* @private
|
|
759
|
-
*/
|
|
760
|
-
private handleReactionRemove;
|
|
761
|
-
/**
|
|
762
|
-
* Checks if a channel ID is allowed based on both env config and dynamic additions.
|
|
763
|
-
* @param {string} channelId - The channel ID to check
|
|
764
|
-
* @returns {boolean} Whether the channel is allowed
|
|
765
|
-
*/
|
|
766
|
-
isChannelAllowed(channelId: string): boolean;
|
|
767
|
-
/**
|
|
768
|
-
* Adds a channel to the dynamic allowed list.
|
|
769
|
-
* @param {string} channelId - The channel ID to add
|
|
770
|
-
* @returns {boolean} Whether the channel was successfully added
|
|
771
|
-
*/
|
|
772
|
-
addAllowedChannel(channelId: string): boolean;
|
|
773
|
-
/**
|
|
774
|
-
* Removes a channel from the dynamic allowed list.
|
|
775
|
-
* @param {string} channelId - The channel ID to remove
|
|
776
|
-
* @returns {boolean} Whether the channel was in the list and removed
|
|
777
|
-
*/
|
|
778
|
-
removeAllowedChannel(channelId: string): boolean;
|
|
779
|
-
/**
|
|
780
|
-
* Gets the list of all allowed channels (env + dynamic).
|
|
781
|
-
* @returns {string[]} Array of allowed channel IDs
|
|
782
|
-
*/
|
|
783
|
-
getAllowedChannels(): string[];
|
|
784
|
-
/**
|
|
785
|
-
* Type guard to check if a channel is a guild text-based channel
|
|
786
|
-
* @private
|
|
787
|
-
*/
|
|
788
|
-
private isGuildTextBasedChannel;
|
|
789
|
-
/**
|
|
790
|
-
* Helper to delay execution
|
|
791
|
-
* @private
|
|
792
|
-
*/
|
|
793
|
-
private delay;
|
|
794
|
-
/**
|
|
795
|
-
* Get spider state for a channel from the database
|
|
796
|
-
* @private
|
|
797
|
-
*/
|
|
798
|
-
private getSpiderState;
|
|
799
|
-
/**
|
|
800
|
-
* Save spider state for a channel to the database
|
|
801
|
-
* @private
|
|
802
|
-
*/
|
|
803
|
-
private saveSpiderState;
|
|
804
|
-
/**
|
|
805
|
-
* Fetches and persists message history from a Discord channel.
|
|
806
|
-
* Supports pagination, state tracking, and streaming via callback.
|
|
807
|
-
*
|
|
808
|
-
* Persistence behavior:
|
|
809
|
-
* - When `onBatch` callback is NOT provided: Messages are automatically persisted
|
|
810
|
-
* to the database and accumulated in the returned `messages` array.
|
|
811
|
-
* - When `onBatch` callback IS provided: Messages are passed to the callback and
|
|
812
|
-
* the caller is responsible for persistence. This allows for custom handling.
|
|
813
|
-
*
|
|
814
|
-
* @param {string} channelId - The Discord channel ID to fetch from
|
|
815
|
-
* @param {ChannelHistoryOptions} options - Options for the fetch operation
|
|
816
|
-
* @returns {Promise<ChannelHistoryResult>} The result with messages and stats
|
|
817
|
-
*/
|
|
818
|
-
fetchChannelHistory(channelId: string, options?: ChannelHistoryOptions): Promise<ChannelHistoryResult>;
|
|
819
|
-
/**
|
|
820
|
-
* Builds a Memory object from a Discord Message.
|
|
821
|
-
* This is a reusable helper for converting Discord messages to ElizaOS Memory format.
|
|
822
|
-
*
|
|
823
|
-
* @param {Message} message - The Discord message to convert
|
|
824
|
-
* @param {Object} options - Optional parameters
|
|
825
|
-
* @param {string} options.processedContent - Pre-processed text content (if already processed, to avoid double-processing)
|
|
826
|
-
* @param {Media[]} options.processedAttachments - Pre-processed attachments (if already processed)
|
|
827
|
-
* @param {Object} options.extraContent - Additional content fields to merge into the memory content
|
|
828
|
-
* @param {Object} options.extraMetadata - Additional metadata fields to merge into the memory metadata
|
|
829
|
-
* @returns {Promise<Memory | null>} The Memory object, or null if the message is invalid
|
|
830
|
-
*/
|
|
831
|
-
buildMemoryFromMessage(message: Message, options?: {
|
|
832
|
-
processedContent?: string;
|
|
833
|
-
processedAttachments?: Media[];
|
|
834
|
-
extraContent?: Record<string, any>;
|
|
835
|
-
extraMetadata?: Record<string, any>;
|
|
836
|
-
}): Promise<Memory | null>;
|
|
837
|
-
/**
|
|
838
|
-
* Ensures entity connections exist for a batch of Discord messages using batch API.
|
|
839
|
-
* This should be called before persisting memories to avoid FK constraint failures.
|
|
840
|
-
*
|
|
841
|
-
* @param {Message[]} messages - The Discord messages to ensure connections for
|
|
842
|
-
* @param {Set<string>} ensuredEntityIds - Optional set of already-ensured entity IDs (for caching across batches)
|
|
843
|
-
* @returns {Promise<void>}
|
|
844
|
-
*/
|
|
845
|
-
private ensureConnectionsForMessages;
|
|
846
|
-
/**
|
|
847
|
-
* Stops the Discord service and cleans up resources.
|
|
848
|
-
* Implements the abstract method from the Service class.
|
|
849
|
-
*/
|
|
850
|
-
stop(): Promise<void>;
|
|
851
|
-
/**
|
|
852
|
-
* Asynchronously retrieves the type of a given channel.
|
|
853
|
-
*
|
|
854
|
-
* @param {Channel} channel - The channel for which to determine the type.
|
|
855
|
-
* @returns {Promise<ChannelType>} A Promise that resolves with the type of the channel.
|
|
856
|
-
*/
|
|
857
|
-
getChannelType(channel: Channel): Promise<ChannelType>;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
/**
|
|
861
|
-
* Permissions that indicate moderation/admin capabilities.
|
|
862
|
-
* Changes to these permissions are considered elevated and worth tracking.
|
|
863
|
-
*/
|
|
864
|
-
declare const ELEVATED_PERMISSIONS: readonly ["Administrator", "ManageGuild", "ManageChannels", "ManageRoles", "KickMembers", "BanMembers", "ModerateMembers", "ManageMessages", "ManageWebhooks", "ManageNicknames", "MuteMembers", "DeafenMembers", "MoveMembers", "ManageEvents", "ManageThreads"];
|
|
865
|
-
/**
|
|
866
|
-
* Check if a role has any elevated (moderation/admin) permissions
|
|
867
|
-
*/
|
|
868
|
-
declare function isElevatedRole(role: Role): boolean;
|
|
869
|
-
/**
|
|
870
|
-
* Check if an array of permission names contains any elevated permissions
|
|
871
|
-
*/
|
|
872
|
-
declare function hasElevatedPermissions(permissions: string[]): boolean;
|
|
873
|
-
|
|
874
|
-
/**
|
|
875
|
-
* Permission tiers as numbers for URL generation.
|
|
876
|
-
*
|
|
877
|
-
* Matrix (3x2):
|
|
878
|
-
* | | No Voice | With Voice |
|
|
879
|
-
* |------------|------------------|-----------------------|
|
|
880
|
-
* | Basic | BASIC | BASIC_VOICE |
|
|
881
|
-
* | Moderator | MODERATOR | MODERATOR_VOICE |
|
|
882
|
-
* | Admin | ADMIN | ADMIN_VOICE |
|
|
883
|
-
*
|
|
884
|
-
* Note: BigInt permissions are converted to Number for URL compatibility.
|
|
885
|
-
* This is safe while Discord permissions stay below bit position 53
|
|
886
|
-
* (Number.MAX_SAFE_INTEGER ≈ 9 quadrillion). Current max bit is ~46.
|
|
887
|
-
*/
|
|
888
|
-
declare const DiscordPermissionTiers: {
|
|
889
|
-
/** Basic text-only permissions (no moderation, no voice) */
|
|
890
|
-
readonly BASIC: number;
|
|
891
|
-
/** Basic + voice permissions (no moderation) */
|
|
892
|
-
readonly BASIC_VOICE: number;
|
|
893
|
-
/** Moderator permissions (text + moderation, no voice) */
|
|
894
|
-
readonly MODERATOR: number;
|
|
895
|
-
/** Moderator + voice permissions */
|
|
896
|
-
readonly MODERATOR_VOICE: number;
|
|
897
|
-
/** Admin permissions (text + moderation + server management, no voice) */
|
|
898
|
-
readonly ADMIN: number;
|
|
899
|
-
/** Admin + voice permissions (full permissions) */
|
|
900
|
-
readonly ADMIN_VOICE: number;
|
|
901
|
-
/** @deprecated Use MODERATOR_VOICE instead */
|
|
902
|
-
readonly FULL: number;
|
|
903
|
-
};
|
|
904
|
-
type DiscordPermissionTier = keyof typeof DiscordPermissionTiers;
|
|
905
|
-
/**
|
|
906
|
-
* Generate a Discord OAuth2 invite URL for the bot.
|
|
907
|
-
*/
|
|
908
|
-
declare function generateInviteUrl(applicationId: string, tier?: DiscordPermissionTier): string;
|
|
909
|
-
/**
|
|
910
|
-
* Permission values for all tiers (for compact display).
|
|
911
|
-
*/
|
|
912
|
-
interface DiscordPermissionValues {
|
|
913
|
-
basic: number;
|
|
914
|
-
basicVoice: number;
|
|
915
|
-
moderator: number;
|
|
916
|
-
moderatorVoice: number;
|
|
917
|
-
admin: number;
|
|
918
|
-
adminVoice: number;
|
|
919
|
-
}
|
|
920
|
-
/**
|
|
921
|
-
* Get all permission values for the 3x2 tier matrix.
|
|
922
|
-
*/
|
|
923
|
-
declare function getPermissionValues(): DiscordPermissionValues;
|
|
924
|
-
/**
|
|
925
|
-
* Invite URLs organized by tier for display.
|
|
926
|
-
*/
|
|
927
|
-
interface DiscordInviteUrls {
|
|
928
|
-
basic: string;
|
|
929
|
-
basicVoice: string;
|
|
930
|
-
moderator: string;
|
|
931
|
-
moderatorVoice: string;
|
|
932
|
-
admin: string;
|
|
933
|
-
adminVoice: string;
|
|
934
|
-
}
|
|
935
|
-
/**
|
|
936
|
-
* Generate all tier invite URLs for display.
|
|
937
|
-
*/
|
|
938
|
-
declare function generateAllInviteUrls(applicationId: string): DiscordInviteUrls;
|
|
939
|
-
|
|
940
|
-
declare const discordPlugin: Plugin;
|
|
941
|
-
|
|
942
|
-
export { type AuditInfo, type ChannelPermissionsChangedPayload, DISCORD_SERVICE_NAME, DiscordEventTypes, type DiscordPermissionTier, DiscordPermissionTiers, type DiscordPermissionValues, DiscordService, ELEVATED_PERMISSIONS, DiscordService as IDiscordService, type MemberRolesChangedPayload, type PermissionDiff, type PermissionPayloadRuntime, type PermissionState, type RoleLifecyclePayload, type RolePermissionsChangedPayload, discordPlugin as default, generateAllInviteUrls, generateInviteUrl, getPermissionValues, hasElevatedPermissions, isElevatedRole };
|
|
1
|
+
export * from "./index";
|
|
2
|
+
export { default } from "./index";
|