-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathsetup.ps1
More file actions
134 lines (116 loc) · 5.23 KB
/
setup.ps1
File metadata and controls
134 lines (116 loc) · 5.23 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
# Claude Code Discord Bot - Windows PowerShell Setup Script
# One-command setup for quick deployment
# Run: .\setup.ps1
$ErrorActionPreference = "Stop"
Write-Host ""
Write-Host "============================================================" -ForegroundColor Blue
Write-Host " Claude Code Discord Bot - Setup " -ForegroundColor Blue
Write-Host "============================================================" -ForegroundColor Blue
Write-Host ""
# Function to check if command exists
function Test-Command($command) {
try {
Get-Command $command -ErrorAction Stop | Out-Null
return $true
} catch {
return $false
}
}
# Step 1: Check/Install Deno
Write-Host "[1/5] Checking Deno installation..." -ForegroundColor Yellow
if (Test-Command "deno") {
$denoVersion = deno --version | Select-Object -First 1
Write-Host "[OK] Deno is installed: $denoVersion" -ForegroundColor Green
} else {
Write-Host "Deno not found. Installing..." -ForegroundColor Yellow
# Install Deno using PowerShell installer
irm https://deno.land/install.ps1 | iex
# Refresh PATH
$env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
if (Test-Command "deno") {
Write-Host "[OK] Deno installed successfully" -ForegroundColor Green
} else {
Write-Host "[FAIL] Deno installation failed. Please install manually: https://deno.com" -ForegroundColor Red
Write-Host " After installing, restart PowerShell and run this script again." -ForegroundColor Yellow
exit 1
}
}
# Step 2: Check/Install Claude Code CLI
Write-Host "[2/5] Checking Claude Code CLI..." -ForegroundColor Yellow
if (Test-Command "claude") {
Write-Host "[OK] Claude CLI is installed" -ForegroundColor Green
} else {
Write-Host "Claude CLI not found. Installing..." -ForegroundColor Yellow
if (Test-Command "npm") {
npm install -g @anthropic-ai/claude-code
Write-Host "[OK] Claude CLI installed" -ForegroundColor Green
Write-Host "Run 'claude /login' to authenticate with Anthropic" -ForegroundColor Yellow
} else {
Write-Host "[FAIL] npm not found. Please install Node.js first: https://nodejs.org" -ForegroundColor Red
exit 1
}
}
# Step 3: Check for .env file or create one
Write-Host "[3/5] Checking environment configuration..." -ForegroundColor Yellow
$envFile = ".env"
if (Test-Path $envFile) {
Write-Host "[OK] .env file found" -ForegroundColor Green
} else {
Write-Host "Creating .env file..." -ForegroundColor Yellow
# Prompt for tokens
Write-Host "Enter your Discord Bot Token:" -ForegroundColor Cyan
$discordToken = Read-Host
Write-Host "Enter your Discord Application ID:" -ForegroundColor Cyan
$applicationId = Read-Host
# Create .env file content
$envContent = "# Claude Code Discord Bot Configuration`n"
$envContent += "# Generated by setup.ps1`n`n"
$envContent += "# Required: Discord Bot Token`n"
$envContent += "DISCORD_TOKEN=$discordToken`n`n"
$envContent += "# Required: Discord Application ID`n"
$envContent += "APPLICATION_ID=$applicationId`n`n"
$envContent += "# Optional: Working directory`n"
$envContent += "# WORK_DIR=C:/path/to/project`n`n"
$envContent += "# Optional: User ID for mentions`n"
$envContent += "# USER_ID=your_discord_user_id`n`n"
$envContent += "# Optional: Category name`n"
$envContent += "# CATEGORY_NAME=claude-code`n"
[System.IO.File]::WriteAllText("$PWD\$envFile", $envContent)
Write-Host "[OK] .env file created" -ForegroundColor Green
}
# Step 4: Initialize git if needed
Write-Host "[4/5] Checking git repository..." -ForegroundColor Yellow
if (Test-Path ".git") {
Write-Host "[OK] Git repository found" -ForegroundColor Green
} else {
if (Test-Command "git") {
Write-Host "Initializing git repository..." -ForegroundColor Yellow
git init
Write-Host "[OK] Git repository initialized" -ForegroundColor Green
} else {
Write-Host "[SKIP] Git not installed. Skipping repository initialization." -ForegroundColor Yellow
}
}
# Step 5: Verify setup
Write-Host "[5/5] Verifying setup..." -ForegroundColor Yellow
Write-Host "[OK] All dependencies installed" -ForegroundColor Green
Write-Host ""
Write-Host "============================================================" -ForegroundColor Green
Write-Host " Setup Complete! " -ForegroundColor Green
Write-Host "============================================================" -ForegroundColor Green
Write-Host ""
Write-Host "To start the bot, run:" -ForegroundColor Cyan
Write-Host " deno run --allow-all index.ts"
Write-Host ""
Write-Host "Or with hot reload (development):" -ForegroundColor Cyan
Write-Host " deno run --allow-all --watch index.ts"
Write-Host ""
Write-Host "Or use the quick start command:" -ForegroundColor Cyan
Write-Host " deno task start"
Write-Host ""
# Offer to start immediately
$startNow = Read-Host "Would you like to start the bot now? (y/n)"
if ($startNow -eq "y" -or $startNow -eq "Y") {
Write-Host "Starting Claude Code Discord Bot..." -ForegroundColor Blue
deno run --allow-all index.ts
}