๐ค Discord.py ร OMP Plugin Cheat Sheet
Bridge a discord.py bot (Python) with the OMP coding agent extension system (Bun/TS) โ from zero to full bidirectional integration.
๐ง Core Concept
OMP extensions = TypeScript/Bun. discord.py = Python. They’re separate runtimes. You bridge them via one of three tiers:
|
๐ช Tier 1: Webhook |
๐ง Tier 2: MCP Server |
๐ Tier 3: Extension + Bot |
| Direction |
OMP โ Discord only |
Both (LLM invokes tools) |
Both (event-driven) |
| Needs Python? |
โ No |
โ
Yes |
โ
Yes |
| Needs Bot Token? |
โ No (webhook URL) |
โ
Yes |
โ
Yes |
| Discord โ OMP? |
โ |
โ |
โ
|
| Auto-notify events? |
โ
|
โ |
โ
|
| LLM calls Discord? |
โ |
โ
|
โ
|
| Setup time |
~5 min |
~15 min |
~30โ60 min |
| Deps |
None |
discord.py, mcp |
discord.py, aiohttp |
โก OMP Extension Contract (All Tiers)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
// ~/.omp/agent/extensions/my-ext/index.ts
import type { ExtensionAPI } from "@oh-my-pi/pi-coding-agent";
export default function myExt(pi: ExtensionAPI) {
// โโ Registration Phase (sync) โโ
pi.setLabel("My Extension");
pi.on("agent_end", async (event, ctx) => { /* ... */ });
pi.on("session_start", async (event, ctx) => { /* ... */ });
pi.registerTool({ name: "my_tool", /* ... */ });
pi.registerCommand("my-cmd", { /* ... */ });
// โ ๏ธ CANNOT call pi.sendMessage() during load โ only in handlers
}
|
๐ก Key Lifecycle Events
1
2
3
|
session_start โ input โ agent_start โ turn_start
โ tool_call โ tool_execution_start โ tool_execution_end โ tool_result
โ turn_end โ agent_end โ session_shutdown
|
| Event |
Use Case |
Return |
agent_end |
“Done” notification to Discord |
โ |
tool_call |
Audit / block dangerous ops |
{ block, reason } |
tool_result |
Redact secrets before logging |
{ content } |
session_start |
Init bot connection |
โ |
session_shutdown |
Cleanup / final flush |
โ |
๐ช Tier 1 โ Webhook (Zero-Dep, 5 min)
No bot. No Python. Just fetch(). OMP โ Discord one-way.