Quanyails / cap-discord-bot

Personal Discord bot for the Create-a-Pokemon Discord server.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

From empty directory to "Hello, World!"

  1. Set up .gitignore:

  2. Install nodenv:

    brew install nodenv
    nodenv install 14.4.0
    nodenv local 14.4.0
  3. Set up package.json:

    npm init
  4. Set up types:

    npm install --save-dev @types/node
  5. Set up and configure TypeScript:

    npm install --save-dev typescript
    npx tsc --init
    
    • Required TS config settings:
    {
      "compilerOptions": {
        "module": "ESNext"
      },
      "rules": {
        "no-unused-vars": "off",
        "@typescript-eslint/no-unused-vars": "error"
      }
    }
  6. Set up and configure ESLint:

    npm install --save-dev eslint
    npx eslint --init

    (Using Airbnb + TypeScript)

    In .eslintrc:

    {
      "import/extensions": [
        "error",
        "ignorePackages",
        {
          "js": "never",
          "jsx": "never",
          "ts": "never",
          "tsx": "never"
        }
      ]
    }
  7. Set up and configure eslint-import-resolver-typescript:

    npm install --save-dev eslint-import-resolver-typescript

    in .eslintrc:

    {
      "settings": {
        "import/resolver": {
          "typescript": {}
        }
      }
    }
  8. Set up Prettier:

    npm install --save-dev prettier
  9. Set up eslint-config-prettier:

    npm install --save-dev eslint-config-prettier
    • Extend .eslintrc with eslint-config-prettier.
  10. Set up lint-staged:

    npx mrm lint-staged
  11. Create an index.ts file:

    touch index.ts
    echo 'console.log("Hello, World!")' >> index.ts
    npx tsc
    node index.js

Debugging in WebStorm

  1. Install the JetBrains plugin for Node.js.
  2. Ensure you are on Node >= 13 for ES6 module support (StackOverflow).
  3. Enable "sourceMap": true in tsconfig.json.
  4. Set up a Run/Debug Configuration for Node.js.
    • In the "Before launch" section, add the action "Compile TypeScript".

From "Hello, World!" to bot enabled

  1. If you're using ES6 modules (experimental) instead of CommonJS modules (default):
    • Add "type": "module" to package.json.
    • Rename .eslintrc.js to .eslintrc.cjs.
  2. Follow this guide.
    npm install --save discord.js
  3. Install the Discord bot framework of your choice.
    npm install --save discordjs/Commando
  4. Create a bot user + token and save it to the CAP_DISCORD_BOT_TOKEN environmental variable.
  5. Run npm start.

About

Personal Discord bot for the Create-a-Pokemon Discord server.


Languages

Language:TypeScript 98.1%Language:JavaScript 1.9%