-
Notifications
You must be signed in to change notification settings - Fork 10
Add @mention notifications and stop command #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
7b2a06e
ae7b1b6
deb0e0d
9a618bb
36866d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| #!/bin/bash | ||
| # Safe restart script for Claude Code Discord Bot | ||
| # Finds and kills the running bot, then immediately starts a new one | ||
|
|
||
| set -e | ||
|
|
||
| echo "🔄 Restarting Claude Code Discord Bot..." | ||
|
|
||
| # Find the bot process | ||
| BOT_PID=$(ps aux | grep "bun run src/index.ts" | grep -v grep | awk '{print $2}') | ||
|
|
||
| if [ -n "$BOT_PID" ]; then | ||
| echo "📍 Found bot running with PID: $BOT_PID" | ||
| echo "🛑 Stopping bot..." | ||
| kill -TERM $BOT_PID | ||
|
|
||
| # Wait for process to exit (max 5 seconds) | ||
| for i in {1..50}; do | ||
| if ! kill -0 $BOT_PID 2>/dev/null; then | ||
| echo "✅ Bot stopped" | ||
| break | ||
| fi | ||
| sleep 0.1 | ||
| done | ||
|
|
||
| # Force kill if still running | ||
| if kill -0 $BOT_PID 2>/dev/null; then | ||
| echo "⚠️ Bot didn't stop gracefully, force killing..." | ||
| kill -9 $BOT_PID | ||
| fi | ||
| else | ||
| echo "ℹ️ No running bot found" | ||
| fi | ||
|
|
||
| echo "🚀 Starting bot..." | ||
| cd "$(dirname "$0")" | ||
| nohup bun run src/index.ts > bot.log 2>&1 & | ||
| NEW_PID=$! | ||
|
|
||
| echo "✅ Bot started with PID: $NEW_PID" | ||
| echo "📋 Logs available at: bot.log" | ||
| echo "" | ||
| echo "To view logs: tail -f bot.log" | ||
| echo "To stop: kill $NEW_PID" |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -97,6 +97,23 @@ export class DiscordBot { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const channelId = message.channelId; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Check if message is a stop command | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const isStopCommand = message.content.trim().toLowerCase() === 'stop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // If there's an active process and user says "stop", kill it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (isStopCommand && this.claudeManager.hasActiveProcess(channelId)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log(`Stop command received for channel ${channelId}, killing process`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.claudeManager.killActiveProcess(channelId); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const stopEmbed = new EmbedBuilder() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .setTitle("🛑 Stopped") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .setDescription("Claude Code process has been stopped") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .setColor(0xFF6B6B); // Red-ish for stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await message.channel.send({ embeds: [stopEmbed] }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+108
to
+123
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevent When no Claude process is active, a - // Check if message is a stop command
- const isStopCommand = message.content.trim().toLowerCase() === 'stop';
-
- // If there's an active process and user says "stop", kill it
- if (isStopCommand && this.claudeManager.hasActiveProcess(channelId)) {
- console.log(`Stop command received for channel ${channelId}, killing process`);
- this.claudeManager.killActiveProcess(channelId);
-
- const stopEmbed = new EmbedBuilder()
- .setTitle("🛑 Stopped")
- .setDescription("Claude Code process has been stopped")
- .setColor(0xFF6B6B); // Red-ish for stop
-
- await message.channel.send({ embeds: [stopEmbed] });
- return;
- }
+ const isStopCommand = message.content.trim().toLowerCase() === "stop";
+ if (isStopCommand) {
+ if (this.claudeManager.hasActiveProcess(channelId)) {
+ console.log(`Stop command received for channel ${channelId}, killing process`);
+ this.claudeManager.killActiveProcess(channelId);
+
+ const stopEmbed = new EmbedBuilder()
+ .setTitle("🛑 Stopped")
+ .setDescription("Claude Code process has been stopped")
+ .setColor(0xff6b6b);
+ await message.channel.send({ embeds: [stopEmbed] });
+ } else {
+ await message.channel.send("No Claude Code process is currently running.");
+ }
+ return;
+ }📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Atomic check-and-lock: if channel is already processing, skip | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (this.claudeManager.hasActiveProcess(channelId)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a blank line at the end of the file.
The dotenv-linter correctly identifies that the file should end with a blank line, which is a common convention for text files.
Apply this diff:
# MCP Server Port (optional, defaults to 3001) # Change this if port 3001 is already in use MCP_SERVER_PORT=3001 +📝 Committable suggestion
🧰 Tools
🪛 dotenv-linter (4.0.0)
[warning] 14-14: [EndingBlankLine] No blank line at the end of the file
(EndingBlankLine)
🤖 Prompt for AI Agents