-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathsetup.sh
More file actions
135 lines (113 loc) · 4.6 KB
/
setup.sh
File metadata and controls
135 lines (113 loc) · 4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env bash
# Claude Code Discord Bot - Linux/macOS Setup Script
# One-command setup for quick deployment
set -e
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
echo -e "${BLUE}"
echo "╔═══════════════════════════════════════════════════════════╗"
echo "║ Claude Code Discord Bot - Setup ║"
echo "╚═══════════════════════════════════════════════════════════╝"
echo -e "${NC}"
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Step 1: Check/Install Deno
echo -e "${YELLOW}[1/5] Checking Deno installation...${NC}"
if command_exists deno; then
DENO_VERSION=$(deno --version | head -n 1)
echo -e "${GREEN}✓ Deno is installed: ${DENO_VERSION}${NC}"
else
echo -e "${YELLOW}Deno not found. Installing...${NC}"
curl -fsSL https://deno.land/install.sh | sh
# Add to PATH for current session
export DENO_INSTALL="$HOME/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
if command_exists deno; then
echo -e "${GREEN}✓ Deno installed successfully${NC}"
else
echo -e "${RED}✗ Deno installation failed. Please install manually: https://deno.com${NC}"
exit 1
fi
fi
# Step 2: Check/Install Claude Code CLI
echo -e "${YELLOW}[2/5] Checking Claude Code CLI...${NC}"
if command_exists claude; then
echo -e "${GREEN}✓ Claude CLI is installed${NC}"
else
echo -e "${YELLOW}Claude CLI not found. Installing...${NC}"
if command_exists npm; then
npm install -g @anthropic-ai/claude-code
echo -e "${GREEN}✓ Claude CLI installed${NC}"
echo -e "${YELLOW}Run 'claude /login' to authenticate with Anthropic${NC}"
else
echo -e "${RED}✗ npm not found. Please install Node.js first: https://nodejs.org${NC}"
exit 1
fi
fi
# Step 3: Check for .env file or create one
echo -e "${YELLOW}[3/5] Checking environment configuration...${NC}"
if [ -f ".env" ]; then
echo -e "${GREEN}✓ .env file found${NC}"
else
echo -e "${YELLOW}Creating .env file...${NC}"
# Prompt for tokens
echo -e "${BLUE}Enter your Discord Bot Token:${NC}"
read -r DISCORD_TOKEN
echo -e "${BLUE}Enter your Discord Application ID:${NC}"
read -r APPLICATION_ID
# Create .env file
cat > .env << EOF
# Claude Code Discord Bot Configuration
# Generated by setup.sh
# Required: Discord Bot Token (from Discord Developer Portal)
DISCORD_TOKEN=${DISCORD_TOKEN}
# Required: Discord Application ID (from Discord Developer Portal)
APPLICATION_ID=${APPLICATION_ID}
# Optional: Default working directory (defaults to current directory)
# WORK_DIR=/path/to/your/project
# Optional: User ID for mentions when Claude finishes
# USER_ID=your_discord_user_id
# Optional: Category name for organizing channels
# CATEGORY_NAME=claude-code
EOF
echo -e "${GREEN}✓ .env file created${NC}"
fi
# Step 4: Initialize git if needed
echo -e "${YELLOW}[4/5] Checking git repository...${NC}"
if [ -d ".git" ]; then
echo -e "${GREEN}✓ Git repository found${NC}"
else
echo -e "${YELLOW}Initializing git repository...${NC}"
git init
echo -e "${GREEN}✓ Git repository initialized${NC}"
fi
# Step 5: Verify setup
echo -e "${YELLOW}[5/5] Verifying setup...${NC}"
echo -e "${GREEN}✓ All dependencies installed${NC}"
echo ""
echo -e "${GREEN}╔═══════════════════════════════════════════════════════════╗"
echo -e "║ Setup Complete! 🎉 ║"
echo -e "╚═══════════════════════════════════════════════════════════╝${NC}"
echo ""
echo -e "${BLUE}To start the bot, run:${NC}"
echo " deno run --allow-all index.ts"
echo ""
echo -e "${BLUE}Or with hot reload (development):${NC}"
echo " deno run --allow-all --watch index.ts"
echo ""
echo -e "${BLUE}Or use the quick start command:${NC}"
echo " deno task start"
echo ""
# Offer to start immediately
echo -e "${YELLOW}Would you like to start the bot now? (y/n)${NC}"
read -r START_NOW
if [ "$START_NOW" = "y" ] || [ "$START_NOW" = "Y" ]; then
echo -e "${BLUE}Starting Claude Code Discord Bot...${NC}"
deno run --allow-all index.ts
fi