@elizaos/plugin-discord 1.0.5 → 1.0.7
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/README.md +64 -56
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +32 -2
package/README.md
CHANGED
|
@@ -4,12 +4,18 @@ A Discord plugin implementation for ElizaOS, enabling rich integration with Disc
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- Handle server join events and manage initial configurations
|
|
8
|
-
- Voice event management via the voice manager
|
|
9
|
-
- Manage and process new messages with the message manager
|
|
10
|
-
- Slash command registration and interaction handling
|
|
11
|
-
-
|
|
12
|
-
-
|
|
7
|
+
- Handle server join events and manage initial configurations
|
|
8
|
+
- Voice event management via the voice manager
|
|
9
|
+
- Manage and process new messages with the message manager
|
|
10
|
+
- Slash command registration and interaction handling
|
|
11
|
+
- Support for Discord attachments and media files
|
|
12
|
+
- Voice channel join/leave functionality
|
|
13
|
+
- Conversation summarization
|
|
14
|
+
- Media transcription capabilities
|
|
15
|
+
- Channel state and voice state providers
|
|
16
|
+
- Channel restriction support (limit bot to specific channels)
|
|
17
|
+
- Robust permissions management for bot functionality
|
|
18
|
+
- Event-driven architecture with comprehensive event handling
|
|
13
19
|
|
|
14
20
|
## Installation
|
|
15
21
|
|
|
@@ -24,7 +30,7 @@ bun install
|
|
|
24
30
|
The plugin requires the following environment variables:
|
|
25
31
|
|
|
26
32
|
```bash
|
|
27
|
-
# Discord API Credentials
|
|
33
|
+
# Discord API Credentials (Required)
|
|
28
34
|
DISCORD_APPLICATION_ID=your_application_id
|
|
29
35
|
DISCORD_API_TOKEN=your_api_token
|
|
30
36
|
|
|
@@ -36,73 +42,75 @@ CHANNEL_IDS=123456789012345678,987654321098765432
|
|
|
36
42
|
|
|
37
43
|
## Usage
|
|
38
44
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
```json
|
|
46
|
+
const character = {
|
|
47
|
+
"plugins": [
|
|
48
|
+
...otherPlugins,
|
|
49
|
+
"@elizaos/plugin-discord"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
46
52
|
```
|
|
47
53
|
|
|
48
|
-
###
|
|
54
|
+
### Available Actions
|
|
49
55
|
|
|
50
|
-
|
|
56
|
+
The plugin provides the following actions:
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
},
|
|
59
|
-
]);
|
|
60
|
-
```
|
|
58
|
+
1. **chatWithAttachments** - Handle messages with Discord attachments
|
|
59
|
+
2. **downloadMedia** - Download media files from Discord messages
|
|
60
|
+
3. **joinVoice** - Join a voice channel
|
|
61
|
+
4. **leaveVoice** - Leave a voice channel
|
|
62
|
+
5. **summarize** - Summarize conversation history
|
|
63
|
+
6. **transcribeMedia** - Transcribe audio/video media to text
|
|
61
64
|
|
|
62
|
-
###
|
|
65
|
+
### Providers
|
|
63
66
|
|
|
64
|
-
|
|
65
|
-
// Listen for new messages
|
|
66
|
-
await discordManager.message.handleNewMessage({
|
|
67
|
-
channelId: 'channel-id',
|
|
68
|
-
content: 'Hello Discord!',
|
|
69
|
-
});
|
|
70
|
-
```
|
|
67
|
+
The plugin includes two state providers:
|
|
71
68
|
|
|
72
|
-
|
|
69
|
+
1. **channelStateProvider** - Provides state information about Discord channels
|
|
70
|
+
2. **voiceStateProvider** - Provides state information about voice channels
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
// Join a voice channel
|
|
76
|
-
await discordManager.voice.joinChannel('channel-id');
|
|
72
|
+
### Event Types
|
|
77
73
|
|
|
78
|
-
|
|
79
|
-
await discordManager.voice.handleInteraction({
|
|
80
|
-
userId: 'user-id',
|
|
81
|
-
action: 'speak',
|
|
82
|
-
});
|
|
83
|
-
```
|
|
74
|
+
The plugin emits the following Discord-specific events:
|
|
84
75
|
|
|
85
|
-
|
|
76
|
+
- `GUILD_MEMBER_ADD` - When a new member joins a guild
|
|
77
|
+
- `GUILD_CREATE` - When the bot joins a guild
|
|
78
|
+
- `MESSAGE_CREATE` - When a message is created
|
|
79
|
+
- `INTERACTION_CREATE` - When an interaction is created
|
|
80
|
+
- `REACTION_RECEIVED` - When a reaction is added to a message
|
|
86
81
|
|
|
87
|
-
|
|
82
|
+
## Key Components
|
|
88
83
|
|
|
89
|
-
|
|
90
|
-
-
|
|
84
|
+
1. **DiscordService**
|
|
85
|
+
- Main service class that extends ElizaOS Service
|
|
86
|
+
- Handles authentication and session management
|
|
87
|
+
- Manages Discord client connection
|
|
88
|
+
- Processes events and interactions
|
|
91
89
|
|
|
92
90
|
2. **MessageManager**
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
- Supports message formatting and templating
|
|
91
|
+
- Processes incoming messages and responses
|
|
92
|
+
- Handles attachments and media files
|
|
93
|
+
- Supports message formatting and templating
|
|
94
|
+
- Manages conversation context
|
|
96
95
|
|
|
97
96
|
3. **VoiceManager**
|
|
97
|
+
- Manages voice channel interactions
|
|
98
|
+
- Handles joining and leaving voice channels
|
|
99
|
+
- Processes voice events and audio streams
|
|
100
|
+
- Integrates with transcription services
|
|
101
|
+
|
|
102
|
+
4. **Attachment Handler**
|
|
103
|
+
- Downloads and processes Discord attachments
|
|
104
|
+
- Supports various media types
|
|
105
|
+
- Integrates with media transcription
|
|
98
106
|
|
|
99
|
-
|
|
100
|
-
- Handles joining and leaving voice channels.
|
|
107
|
+
## Testing
|
|
101
108
|
|
|
102
|
-
|
|
103
|
-
- Registers and processes slash commands.
|
|
104
|
-
- Ensures permissions are validated.
|
|
109
|
+
The plugin includes a test suite (`DiscordTestSuite`) for validating functionality.
|
|
105
110
|
|
|
106
111
|
## Notes
|
|
107
112
|
|
|
108
|
-
Ensure that your `.env` file includes the required
|
|
113
|
+
- Ensure that your `.env` file includes the required `DISCORD_API_TOKEN` for proper functionality
|
|
114
|
+
- The bot requires appropriate Discord permissions to function correctly (send messages, connect to voice channels, etc.)
|
|
115
|
+
- If no token is provided, the plugin will load but remain non-functional with appropriate warnings
|
|
116
|
+
- The plugin uses Discord.js v14.18.0 with comprehensive intent support
|
package/dist/index.js
CHANGED
|
@@ -2456,6 +2456,10 @@ var MessageManager = class {
|
|
|
2456
2456
|
interval: null,
|
|
2457
2457
|
cleared: false
|
|
2458
2458
|
};
|
|
2459
|
+
startTyping();
|
|
2460
|
+
const typingInterval = setInterval(startTyping, 8e3);
|
|
2461
|
+
typingData.interval = typingInterval;
|
|
2462
|
+
await new Promise((resolve) => setTimeout(resolve, 200));
|
|
2459
2463
|
const newMessage = {
|
|
2460
2464
|
id: messageId,
|
|
2461
2465
|
entityId: entityId2,
|
|
@@ -2485,10 +2489,6 @@ var MessageManager = class {
|
|
|
2485
2489
|
};
|
|
2486
2490
|
const callback = async (content, files) => {
|
|
2487
2491
|
try {
|
|
2488
|
-
startTyping();
|
|
2489
|
-
const typingInterval = setInterval(startTyping, 8e3);
|
|
2490
|
-
typingData.interval = typingInterval;
|
|
2491
|
-
typingData.cleared = false;
|
|
2492
2492
|
if (message.id && !content.inReplyTo) {
|
|
2493
2493
|
content.inReplyTo = createUniqueUuid4(this.runtime, message.id);
|
|
2494
2494
|
}
|
|
@@ -2499,7 +2499,7 @@ var MessageManager = class {
|
|
|
2499
2499
|
logger4.warn("Discord - User not found", message.author.id);
|
|
2500
2500
|
return [];
|
|
2501
2501
|
}
|
|
2502
|
-
u.send(content.text);
|
|
2502
|
+
await u.send(content.text || "");
|
|
2503
2503
|
messages = [content];
|
|
2504
2504
|
} else {
|
|
2505
2505
|
messages = await sendMessageInChunks(
|
|
@@ -2558,7 +2558,7 @@ var MessageManager = class {
|
|
|
2558
2558
|
clearInterval(typingData.interval);
|
|
2559
2559
|
typingData.cleared = true;
|
|
2560
2560
|
}
|
|
2561
|
-
},
|
|
2561
|
+
}, 3e4);
|
|
2562
2562
|
} catch (error) {
|
|
2563
2563
|
console.error("Error handling message:", error);
|
|
2564
2564
|
}
|