fix: Discord でbotのセリフを content に表示する (#95)#98
Conversation
Discord モードでは embed に pretext 相当の欄が無く、セリフ(pretext)を embed の description に埋め込んでいたため、Slack のように「botの発言」として 表示されず消えたように見えていた。さらにメンション時は content に @everyone しか出ず、セリフが出なかった。 - pretext を Post の content に出力し、Slack 同様「botの発言行」として表示 - メンション時は content 先頭に @everyone を添える - チャンク内で重複するセリフは uniq でまとめ、CONTENT_LIMIT(2000)で truncate - 二重表示を避けるため description からは pretext を外しコメント本文のみに - 送信ペイロードを print_log で出力し表示の切り分けをしやすくする - spec/discord/models_spec.cr を更新 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request refactors Discord post formatting by moving the bot's serif (pretext) from the embed's description into the post's main content to prevent double-display issues. It also adds logic to prepend channel-wide mentions, de-duplicate repeated pretexts, truncate content to Discord's limit, and log the outgoing payload for debugging. I have no feedback to provide as there are no review comments.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
概要
issue #95 を解決する。Discord 投稿時に botのセリフ(
[Issue] 更新があったみたいです。確認してみましょう!等の pretext)が「消えている」ように見える問題を修正する。原因
pretextとして カードの外=botの発言行 に表示される。description(コメント本文)に結合して入れていた。つまりセリフは embed カードの中 にしか出ず、botの発言として表示されない。content(botの発言行)は@everyoneのみを出力しており、MENTION_REASONSが広く実通知はほぼメンション扱いとなるため、発言行には@everyoneしか出ずセリフが消えたように見えていた。修正内容 (
src/discord/models.cr)contentに出力 し、Slack と同様「botの発言行」として embed の外に表示するcontent先頭に@everyoneを添える(@everyone\n<セリフ>)uniq(順序保持)して結合contentの 2000 文字上限(CONTENT_LIMIT)で truncatedescriptionからは pretext を外し、コメント本文のみとするPost#to_json)をprint_logで出力し、表示の切り分け(description / footer が意図通りか)を CloudWatch で確認できるようにする表示イメージ(実ペイロード)
{"content":"@everyone\n[Issue] 更新があったみたいです。確認してみましょう!","embeds":[{"title":"Spurious failure","description":"コメント本文です","color":11129077,"footer":{"text":"octocat/Hello-World"}},{"title":"Another","description":"別コメント"}]}セリフが
content(botの発言行)に出て、embed のdescriptionはコメント本文のみになった。同一チャンク内の同じセリフは1行にまとめられる。フッターについて
Discord embed の
footer.textは仕様上プレーンテキストのみ(リンク・markdown 不可)で、現実装もリポジトリ名を文字列として送っており、そもそもリンクは設定していない。表示欠落は Discord クライアント側の描画の可能性があり、実害があれば別 issue に切り出す方針(本 PR のスコープ外)。テスト
spec/discord/models_spec.crを更新(content へのセリフ出力 / mention 併記 / description から pretext 除外 / uniq / truncate)crystal spec37 examples 0 failures /ameba0 failures /crystal build src/main.cr成功Closes #95
🤖 Generated with Claude Code