Skip to content

feat: slash ping pong command#86

Merged
miyakoshi-3854 merged 5 commits into
mainfrom
feat/slash-ping-pong-api
Mar 12, 2026
Merged

feat: slash ping pong command#86
miyakoshi-3854 merged 5 commits into
mainfrom
feat/slash-ping-pong-api

Conversation

@miyakoshi-3854

@miyakoshi-3854 miyakoshi-3854 commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

close #62

Summary

タイトル通り

Changes

既存の ping pong apislash command 化した。

Notes

正しく動きます。
image

@miyakoshi-3854 miyakoshi-3854 self-assigned this Mar 9, 2026
@miyakoshi-3854 miyakoshi-3854 requested a review from a team as a code owner March 9, 2026 14:09
@coderabbitai

coderabbitai Bot commented Mar 9, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 38fe63d9-0d14-4a93-b212-28d918d2c0e0

📥 Commits

Reviewing files that changed from the base of the PR and between 37b310f and b9ea52d.

📒 Files selected for processing (1)
  • .mise.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .mise.toml

📝 Walkthrough

Walkthrough

Discord ボットをメッセージベースのハンドラから app_commands ベースのスラッシュコマンドへ移行。MeshibanClientCommandTree を導入し、/ping スラッシュコマンドと --sync-only による同期フローを追加した。

Changes

Cohort / File(s) Summary
Discord クライアント & コマンド
src/main.py
MeshibanClient(discord.Client) を追加し self.tree = app_commands.CommandTree(self) を初期化。@tree.command(name="ping")/ping スラッシュコマンドを実装。on_message ベースの処理を削除。setup_hook で条件付きのコマンド同期(--sync-only)と早期終了を追加。tree = client.tree をモジュールで公開。sys を使用して argv を判定。
タスク設定追加
.mise.toml
新規タスク tasks.sync を追加(説明と uv run src/main.py --sync-only 実行コマンド)。

Sequence Diagram(s)

sequenceDiagram
    participant User as "User"
    participant Discord as "Discord API"
    participant Client as "MeshibanClient"
    participant Tree as "CommandTree"

    User->>Discord: /ping (interaction)
    Discord->>Client: Deliver Interaction
    Client->>Tree: dispatch(interaction)
    Tree->>Client: invoke ping handler
    Client->>Discord: respond("pong!")
    Note over Discord,User: User sees "pong!"
Loading
sequenceDiagram
    participant CLI as "CLI (--sync-only)"
    participant Client as "MeshibanClient"
    participant Discord as "Discord API"

    CLI->>Client: start with --sync-only
    Client->>Discord: tree.sync()
    Discord-->>Client: ack sync
    Client->>CLI: exit process
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Feat: ping pong api #70: 同じ src/main.py の ping 実装に関する別アプローチ(on_message ベース) — コード上の重複や統合点があり得る。

Suggested reviewers

  • nkoji21

Poem

🐰🌿
スラッシュの道で跳ねる声、
ぽん、と返す小さな合図。
コマンド揃えて朝が来る、
ふわり走る僕のコード。

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed タイトルは pull request の主な変更内容「既存の ping pong API をスラッシュコマンド化」を正確に反映しており、簡潔で明確です。
Description check ✅ Passed Description は必須テンプレートセクション(close, Summary, Changes, Notes)をすべて含んでおり、日本語で目的と実装内容を説明しています。
Linked Issues check ✅ Passed Issue #62 の要件(/ping スラッシュコマンド実装、テキストチャンネルでの「pong」応答)は、src/main.py の slash command 実装と .mise.toml の sync タスク追加により完全に満たされています。
Out of Scope Changes check ✅ Passed すべての変更(slash command 実装、CommandTree 追加、sync タスク)は Issue #62/ping コマンド実装という定義済みスコープ内であり、無関連な変更はありません。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/slash-ping-pong-api

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nkoji21 nkoji21 changed the title Feat: slash ping pong command feat: slash ping pong command Mar 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main.py`:
- Around line 13-16: 現在 on_ready() 内で await tree.sync()
を呼んでいますが、再接続時にも実行されてしまいレート制限を誘発するため、tree.sync() を on_ready から削除して、Bot クラスの
setup_hook メソッド(例: async def setup_hook(self): await
tree.sync())に移動して起動時に一度だけ実行されるようにしてください。また on_ready の中から tree.sync()
呼び出しを削除し、もし既存のカスタム Bot クラスがあればそのクラスで setup_hook をオーバーライドして同期を行うようにしてください。

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4d87d74a-78be-4509-9509-8d4b71dc9701

📥 Commits

Reviewing files that changed from the base of the PR and between 5af46f3 and d10573c.

📒 Files selected for processing (1)
  • src/main.py

Comment thread src/main.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/main.py`:
- Around line 34-36: The ping command handler returns "pong!" but Issue `#62`
expects an exact "pong" response; update the string passed to
interaction.response.send_message in the ping function to "pong" (change the
literal in the async def ping handler where interaction.response.send_message is
called) so the response matches the required exact text.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6be945da-224b-4afd-8edc-4cdd64391b70

📥 Commits

Reviewing files that changed from the base of the PR and between d10573c and 37b310f.

📒 Files selected for processing (2)
  • .mise.toml
  • src/main.py

Comment thread src/main.py

@nkoji21 nkoji21 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

@miyakoshi-3854 miyakoshi-3854 merged commit 5dc7ad9 into main Mar 12, 2026
2 checks passed
@miyakoshi-3854 miyakoshi-3854 deleted the feat/slash-ping-pong-api branch March 12, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/ping を実装してDiscord上で応答できるようにする

2 participants