TypeScript commands
- tsc - compile everything to .js
- tsc src/index.ts - compile index.ts to .js
- tsc -w - compile watch mode
- node out/index.js - run the project
tsconfig.json
- outDir: "out", - compile directory
- "resolveJsonModule": true", - for importing jsons
Typescript 2.9.0 has a bug with this JSON feature, it was fixed with 2.9.2
- "esModuleInterop": true - for importing jsons
The esModuleInterop is only necessary for the default import of the colorsJson. If you leave it set to false then you have to import it with import * as colorsJson from '../colors.json'
Note: Option "resolveJsonModule" cannot be specified without "node" module resolution strategy, so you also need to put "moduleResolution": "node" into your tsconfig.json. It also comes with the downside, that the *.json files you want to import need to be inside of "rootDir".
Source: https://stackoverflow.com/questions/49996456/importing-json-file-in-typescript
Node Modules:
npm install discord.js
Big Notes:
- For OAUTH2 URL generation, make sure to check "bot" and "applications.commands" in the scopes tab.
- See
command.ts
for an interface example.
Google Cloud:
- Compute Engine > VM instances > Create new Instance
- Use lowest CPU
- Keep everything default
- *maybe enble HTTPS firewall checkboxes (2)
sudo apt install npm
1. install node package managersudo apt install git
2. install gitpython3 --version
3. check python versionnpm --version
4. check npm versiongit --version
5. check git versionsudo apt -y update && sudo apt -y upgrade
6. Get Node 17curl -sL https://deb.nodesource.com/setup_17.x | sudo bash -
sudo apt-get install -y nodejs
node -v
7. Check node versiongit clone <url>
8. Clone git hub repo ORgcloud init
9. Initialize google cloud, login, enter project details, etc. (only needed if using buckets)sudo nano out/index.js
- edit out/index.js and insert token (Ctrl X to exit and save)node out/index.js
to runnohup node out/index.js &>> activity.log &
- NO hang up command, runs bot 24/7 without SSH window open, then put terminal logs in activity.log
todo automatic delete- todo leaderboard todo count command