bostie¶
bostie は、ゲートウェイ、HTTP クライアント、ボイスエンジンを Rust で動かす Python 向けの Discord ライブラリです。Bot そのものは、型付きの非同期 Python で書きます。

プレアルファ
bostie の API はまだ変わる可能性があります。スラッシュコマンド、ユーザーコマンド、メッセージコマンド、コンポーネント、モーダル、ゲートウェイイベント、キャッシュ、REST、ウェブフック、HTTP インタラクション、OAuth2、そしてボイスの再生と受信は、現時点ですでに動作します。
import bostie
from bostie import ComponentContext, Context, ui, voice
bot = bostie.Bot()
@bot.command
async def play(ctx: Context, url: str) -> None:
"""Play a direct media URL in your voice channel."""
vc = ctx.voice.current or await ctx.voice.connect()
await vc.play(voice.Url(url))
stop = ui.button("Stop", custom_id=stop_playing.id(guild_id=vc.guild_id))
await ctx.respond(components=[ui.text(f"Playing <{url}>"), ui.row(stop)])
@bot.on_component("stop:{guild_id:int}")
async def stop_playing(ctx: ComponentContext, guild_id: int) -> None:
if (vc := bot.voice.get(guild_id)) is not None:
vc.stop()
await ctx.update(components=[ui.text("Stopped.")])
bot.run()
/play は、コマンドを実行したユーザーがいるボイスチャンネルに参加し、URL をストリーミングして、停止ボタン付きで応答します。ボタンのカスタム ID にはサーバー ID が含まれており、@bot.on_component がそれを int に解析し直すので、Bot を再起動した後もボタンは動作し続けます。bot.run() はトークンを環境変数 BOSTIE_TOKEN から読み込み、コマンドが変更されていれば Discord に送信します。
AI コーディングアシスタントをお使いですか?
bostie スキルをインストールすると、コーディングアシスタントが bostie を使う作業をより正確にこなせるようになります。プロンプトをコピーして、コーディングアシスタントに貼り付けてください。 スキルの詳細
bostie スキルをインストールする
Install the bostie skill for my coding agent so it writes correct bostie code: Discord bots with slash commands, components, events, REST calls, voice and tests.
Use the Agent Skills installer with the bostie repository, https://github.com/nicokim/bostie:
npx skills add nicokim/bostie --skill bostie --yes
If I ask for a global install instead, use:
npx skills add nicokim/bostie --skill bostie --yes --global
Detect which agent or editor I am using. If it is one of these and I prefer the plugin path, install the bostie plugin instead, as https://bostie.dev/ja/assistants/ shows:
Claude Code: /plugin marketplace add nicokim/bostie, then /plugin install bostie@bostie
Codex CLI: codex plugin marketplace add nicokim/bostie, then codex plugin add bostie@bostie
GitHub Copilot CLI: copilot plugin marketplace add nicokim/bostie, then copilot plugin install bostie@bostie
VS Code with GitHub Copilot: run "Chat: Install Plugin from Source" and enter nicokim/bostie
Devin: devin plugins install nicokim/bostie#docs
Factory Droid: droid plugin marketplace add nicokim/bostie, then droid plugin install bostie@bostie --scope user
Qwen Code: qwen extensions install nicokim/bostie:bostie
Do not invent other skill names or install URLs.
Then add this line to the instructions file you read at the start of every session (AGENTS.md at the project root, or your global one for a global install), and create the file if needed:
Before you write or change code that uses bostie, look at how the project is laid out, then load the bostie skill.
After installing, confirm that the bostie skill is available to you.
何のために作られたか¶
ボイス¶
Discord は 2026 年 3 月 1 日以降、エンドツーエンド暗号化された通話(DAVE)しか受け付けていません。bostie のボイスエンジンは GIL の外側、Rust のスレッド上で動作し、20 ms のクロック、デコード、ミキシング、Opus エンコード、トランスポート暗号化、DAVE を担います。Python 側の仕事は、各シンクのバッファー(既定では 0.2 秒分の音声)を満たしておくことだけです。bostie はファイル、URL、HLS ストリーム、独自の PCM や Opus を再生し、複数のソースをミキシングし、話者ごとに個別に受信し、通話を録音できます。
Discord の変更に耐える Bot¶
未知のフィールド、列挙値、コンポーネントの種類、インタラクションの種類があっても、デコードが失敗することはありません。すべてのイベントと、ペイロード全体からデコードされたすべてのモデルは生の JSON を保持しており、bostie がまだモデル化していないものにも bot.http と生のイベントリスナーからアクセスできます。
Discord のドキュメントどおりの型¶
Discord が必ず送るフィールドが None になることはなく、部分オブジェクトには専用のクラスがあります。たとえば、コマンドのオプションから解決されたメンバーは ResolvedMember であり、deaf や mute を持ちません。
シグネチャから作るコマンド¶
オプション、選択肢、範囲、オートコンプリートは型ヒントから作られます。名前、説明、オプションの数、選択肢は、Discord が同期を拒否した時点ではなく、デコレーターの実行時に Discord の上限と照合されます。
Discord なしでテスト¶
bostie.testing.FakeDiscord は、実際の Bot をそのまま動かせるローカルのゲートウェイと REST API です。