echo"Found an old launchd service ($OLD_LABEL) from a previous version of this bot - switching it over to pm2 so you don't end up with two copies running."
echo"1. Go to https://discord.com/developers/applications and sign in"
echo"2. Click New Application, name it anything, create it"
echo"3. Click Bot in the left sidebar"
echo"4. IMPORTANT - scroll to Privileged Gateway Intents, turn ON both Message Content Intent and Server Members Intent, then click the Save Changes button at the bottom."
echo" The toggles by themselves do not save. If you skip Save Changes, the bot will fail to log in with a disallowed intents error."
echo"5. Click Reset Token (or Copy) and copy the token"
echo"6. Click OAuth2 > URL Generator, check bot under Scopes, then check Send Messages and Read Message History under Bot Permissions"
echo"7. IMPORTANT - a URL appears at the bottom of that page. Copy it, paste it into your web browser, press Enter, pick your server, and click Authorize."
echo" Creating the bot does NOT add it to your server. It will not show up in your server until you open that URL and authorize it there."
echo""
read -p "Paste your Discord bot token: " TOKEN_INPUT
set_env_value DISCORD_BOT_TOKEN "$TOKEN_INPUT"
fi
if[[ -z "$CURRENT_KEY"]];then
echo""
echo"Need a free IsThereAnyDeal API key:"
echo"1. Register a free user account at https://isthereanydeal.com"
echo"2. Go to https://isthereanydeal.com/apps/"
echo"3. Click Register App, name it anything, submit"
echo"4. Copy the API key it shows you"
echo""
read -p "Paste your IsThereAnyDeal API key: " KEY_INPUT
echo"Optional - only needed for !my-steam-profile and automatic Steam ownership counts on !info:"
echo"1. Go to https://steamcommunity.com/dev/apikey and sign in"
echo"2. Enter any domain name (e.g. localhost), agree to the terms, and submit"
echo"3. Copy the API key it shows you"
echo""
read -p "Paste your Steam Web API key, or press Enter to skip: " STEAM_KEY_INPUT
set_env_value STEAM_API_KEY "$STEAM_KEY_INPUT"
fi
if ! command -v ollama >/dev/null 2>&1;then
echo""
read -p "Want the bot to use AI to give smarter, in-character answers when people chat with it? This is free - it installs Ollama and runs a small AI model locally on this machine, no API key or cost involved. [y/N] " AI_ANSWER
if[["$AI_ANSWER"=="y"||"$AI_ANSWER"=="Y"]];then
ifcommand -v brew >/dev/null 2>&1;then
echo"Installing Ollama..."
brew install ollama
elif[["$OS_NAME"=="Linux"]];then
echo"Installing Ollama..."
curl -fsSL https://ollama.com/install.sh | sh
else
echo"Install it yourself from https://ollama.com/download, then run this script again to finish setting it up."
fi
else
echo"Skipping - the bot won't reply to chat mentions. Run this script again any time to set it up."
ifcommand -v brew >/dev/null 2>&1&& brew list ollama >/dev/null 2>&1;then
brew services start ollama >/dev/null 2>&1||true
sleep 2
fi
if ! ollama list 2>/dev/null | grep -q "$CURRENT_OLLAMA_MODEL";then
echo""
echo"Downloading the $CURRENT_OLLAMA_MODEL model for the bot to use (one-time, may take a few minutes)..."
ollama pull "$CURRENT_OLLAMA_MODEL"||echo"Could not download the model automatically - make sure Ollama is running, then run: ollama pull $CURRENT_OLLAMA_MODEL"
fi
fi
if ! command -v pm2 >/dev/null 2>&1;then
echo""
echo"Installing pm2 to keep the bot running in the background..."