Discord bot that does your Yi Jing reading.
- Go to Discord Developer Portal
- Click "New Application" and give it a name
- Go to the "Bot" section in the left sidebar
- Click "Add Bot"
- Under the bot's username, click "Reset Token" and copy the new token
- Keep this token secret! Don't share or commit it
- You'll need this for the
.env
file later
- In the Developer Portal, click "OAuth2" -> "URL Generator" in the left sidebar
- Select these scopes:
bot
applications.commands
- Under "Bot Permissions" select:
- Read Messages/View Channels
- Send Messages
- Use Slash Commands
- Copy the generated URL at the bottom
- Open the URL you copied in a new browser tab
- Select your server from the dropdown
- Click "Authorize"
- Complete the CAPTCHA if prompted
-
Clone this repository
-
Copy
.env.template
to.env
-
Fill in the required environment variables:
TOKEN=your_bot_token_here CLIENT_ID=your_application_id_here
- TOKEN: The bot token you got in step 1
- CLIENT_ID: Found in your application's "General Information" page
-
Install dependencies:
npm install
-
Deploy slash commands:
node deploy-commands.js
-
Start the bot:
node index.js
The bot provides several slash commands:
/read
- Quick reading showing hexagram symbols and changing lines/fullread
- Detailed reading with judgments and images/lookup
- Look up specific hexagrams and their line meanings- Can specify individual lines (e.g., "1,3,5" or "2 4 6")
- Or view entire trigrams (lines 1,2,3 or 4,5,6)
- Check that the bot is online in your server
- Verify the TOKEN in your .env file matches your bot's token
- Make sure you've run deploy-commands.js after any command changes
- Check the console for any error messages
- Ensure you've run deploy-commands.js
- Verify the CLIENT_ID in your .env matches your application ID
- Try removing and re-adding the bot to your server
- Check that the bot has the required permissions in your server
- Verify the bot's role is high enough in the server's role hierarchy
- Make sure the bot has access to the channels you're using it in
-
Install GitHub CLI:
# Add GitHub CLI repository curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null # Install gh sudo apt update sudo apt install gh
-
Authenticate with GitHub:
gh auth login
- Select "GitHub.com"
- Select "HTTPS"
- Select "Y" for authentication with your GitHub credentials
- Complete the login process in your browser
-
Clone the repository:
gh repo clone yourusername/yi-jing-bot cd yi-jing-bot
-
Install Forever globally:
sudo npm install -g forever
-
Start the bot:
forever start index.js
-
Useful Forever commands:
# List all running processes forever list # Stop the bot forever stop index.js # Restart the bot forever restart index.js # Stop all processes forever stopall # View logs forever logs index.js
-
To run on system startup, add to crontab:
# Open crontab editor crontab -e # Add this line @reboot cd /path/to/yi-jing-bot && /usr/local/bin/forever start index.js
-
Pull latest changes:
cd /path/to/yi-jing-bot gh repo sync
-
Install any new dependencies:
npm install
-
Deploy new commands if needed:
node deploy-commands.js
-
Restart the bot:
forever restart index.js
This bot uses ES Modules instead of CommonJS. This means:
"type": "module"
is set in package.json- We use
import/export
instead ofrequire()/module.exports
- File extensions (
.js
) are required in import paths - All JavaScript files use ES Module syntax:
I Ching CLI for the traditional calculations to get the hexagrams.