Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
DiscordとCloudflare
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
sugar-cat
February 14, 2025
1.4k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DiscordとCloudflare
sugar-cat
February 14, 2025
More Decks by sugar-cat
See All by sugar-cat
HonoとOpenTelemetryで実現するオブザーバービリティ構築
sugarcat7
0
620
ErrorTrackingとOrchestrion
sugarcat7
0
450
Cloudflare Workflowsを使いたい倒したい
sugarcat7
8
2.8k
tslogで実現するセキュアなメタデータ管理とロギング
sugarcat7
4
1.7k
最近個人開発が熱い ~モニタリング強化編v0.1.0~
sugarcat7
3
530
Honoで実現するバックエンド開発のイマ
sugarcat7
23
6.5k
GoとWASI~超入門~
sugarcat7
2
330
最近個人開発が熱い ~多言語対応編~
sugarcat7
2
490
ボイラープレート自動生成ツールを使わなくなった話.pdf
sugarcat7
4
810
Featured
See All Featured
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
490
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
Visualization
eitanlees
153
17k
Design in an AI World
tapps
1
350
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
550
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
350
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
730
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
790
Transcript
DiscordとCloudflare 湘.なんか #2 2025/2/15 @sugar235711
2 sugar cat(@sugar235711) 仕事: SRE(オブザーバビリティ、インフラ構築) 興味: セキュリティ、パフォーマンスチューニング 2年前の古い記事(あまり参考にならない) @sugar235711 @sugar-cat7
https://zenn.dev/king/articles/4201f4ee821a27
3 Bot or Activity(ボイスチャット上で動くWebアプリケーション) Discordの開発でできること(2025年2月15日現在) Overview of Activities https://discord.com/developers/docs/activities/overview Overview
of Interactions https://discord.com/developers/docs/interactions/overview ・Interaction(/ command) ・Events ・Gateway(WebSocket)/Webhook ・Embedded App ・iframeを通したメッセージング ・Unity(WebGLビルド)もいける(はず)
4 Bot or Activity(ボイスチャット上で動くWebアプリケーション) Discordの開発でできること(2025年15日現在) Overview of Activities https://discord.com/developers/docs/activities/overview Overview
of Interactions https://discord.com/developers/docs/interactions/overview ・Interaction(/ command) ・Events ・Gateway(WebSocket)/Webhook ・Embedded App ・iframeを通したメッセージング ・Unity(WebGLビルド)もいける(はず) Overview of Interactions https://discord.com/developers/docs/interactions/overview ・Interaction(/ command) ・Events ・Gateway(WebSocket)/Webhook
5 Bot or Activity(ボイスチャット上で動くWebアプリケーション) Discordの開発でできること(2025年15日現在) Overview of Activities https://discord.com/developers/docs/activities/overview Overview
of Interactions https://discord.com/developers/docs/interactions/overview ・Interaction(/ command) ・Events ・Gateway(WebSocket)/Webhook ・Embedded App ・iframeを通したメッセージング ・Unity(WebGLビルド)もいける(はず) Overview of Interactions https://discord.com/developers/docs/interactions/overview ・Interaction(/ command) ・Events ・Gateway(WebSocket)/Webhook /hogeでユーザーからのインタラクションを受けられる
6 • InteractionはInteractions Endpointを介してDiscordからのリクエ ストを受けられれば良いのでサーバレスの実行環境でOK • 公式からSDKが提供されているので、それを使えば基本的には全部実 装できる(Interaction以外も) Cloudflare ×
Discord Interactionの開発方法 https://github.com/discordjs
7 • InteractionはInteractions Endpointを介してDiscordからのリクエ ストを受けられれば良いのでサーバレスの実行環境でOK • 公式からSDKが提供されているのでそれを使えば基本的には全部実装 できる(Interaction以外も) Cloudflare ×
Discord Interactionの開発方法 https://github.com/discordjs 残念ながらCloudflare上ではdiscord.jsは動かない ※Node.js実行環境への依存・workerdでWeakRefが使えない等 ので、一般的にはInteractionだけ切り出したdiscord-interactions-jsが 使われる
8 ただDiscordの他APIの併用やWebFrameWorkへの統合を考えると もう少しリッチなライブラリが欲しくなる...(と思う) discord.jsを使わずに楽する DiscordHono ・Honoにinspireされたライブラリ ・Cloudflare Workersで動く ・Honoへmountが可能 ・Discord
API操作用のRESTClient の提供あり Discordeno ・Node.js/Deno/Bunで動く(使って いる限りはworkerdも) ・rest/gateway/botでパッケージ化 されている ・シンプルで拡張性に重きが置かれ ている(キャッシュを使用しない等) https://github.com/luisfun/discord-hono https://github.com/discordeno/discordeno Sapphire ・大規模向け(?) ・discord.jsに一部依存している ・pluginが超豊富(i18n/cli etc…) ・基本的Discord APIの操作は Wrapperが提供されている https://github.com/sapphiredev/framework
9 すぽじゅーる:https://www.vspo-schedule.com ぶいすぽっ! (VTuberグループ)の配信予定を確認できるサイト &Bot 個人開発しているサイト ユースケース (個人)
10 全体構成 サーバーサイドをCloudflareStackに (鋭意リプレイス中) ・外部向けのエンドポイントはAPI Gateway Workersに集約 ・内部のビジネスロジックはInternal Workerへ集約(Service Bindings)
・Read/Write用のWorkersを分けDB の書き込みスケールのためバッファリン グ ・Cronからの呼び出しはWorkflowsを 使用しステップに分け効率的に処理 ・BaselimeによるTracing強化 Discord Channelへの一斉配信とInteraction ユースケース (個人)
11 全体構成 サーバーサイドを CloudflareStackに ユースケース②(動画情報取得/翻訳タスク/Discordへ配信) Cloudflare Workflows 外部向けのエンドポイントは DiscordHonoを利用 Interactionのエンドポイントを
Honoへmountして一つの Gateway Workersとして運用
12 全体構成 サーバーサイドを CloudflareStackに ユースケース②(動画情報取得/翻訳タスク/Discordへ配信) Cloudflare Workflows 内部向けの WorkersではDiscordenoを利用し実装 (DiscordHonoのREST
Clientでも良かったが一部未実装の APIの有無 や利用実績等から Discordenoを利用)
13 Discord開発にもCloudflareを使おう! まとめ 宣伝 https://speakerdeck.com/sugarcat7