Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Port this project into typescript #58

Merged
merged 7 commits into from
Apr 14, 2024

Conversation

samhwang
Copy link
Contributor

@samhwang samhwang commented Apr 13, 2024

What this is

During the initial planning phase, this project was planned to be using Python and the interactions.py library. However, due to a few hiccups with the libraries, esp. around interactions.py, we have lost a lot of morale in the project. Time was spent mostly on fixing the bugs with the tools and not creating a meaningful experience.

This is why I took the time to make a porting attempt of this project into TypeScript, using the bootstrapping template at samhwang/ts-starter-template and a similar structure to viet-aus-it/vait-discord-bot.

Why this PR was made

The decision was made on a few key points:

  • The discord.js library is more actively maintained than interactions.py
  • Documentations of discord.js is a lot more detailed in what we need to do in deploying guild-specific things vs global. This was severely lacking in interactions.py.
  • Writing tests proved difficult because of the annotations syntax being used in the library itself.

Caveats

However, this decision also comes with caveats:

  • Python is not removed completely from the project, as it is still used to run the LiteLLM Proxy. This might proven to be tricky to use devcontainers.
  • In NodeJS, there isn't a native GDrive downloader like gdown, so I had to write up a module manually.

What was done

  • Ported the project to TypeScript using the robust toolset:
    • vitest Test runner
    • tsup TypeScript Bundler
    • tsx CLI tool to run TypeScript files locally
    • biome Linter & Formatter
    • zod Schema validation
  • An attempt was made to try to keep the same project structure, however, I took the liberty to make a few changes for clarity:
    • src/discord_bot is now split up into 3:
      • src/discord for discord related utilities
      • src/slash-commands for all slash commands
      • src/autocompletes for all autocompletes
    • All tests now live in the same folder with its main module. During building and bundling, these files will be skipped.

I understand this PR maybe wieldy to look at in just the changed files. Please take a look at the branch as a whole.

@samhwang samhwang requested a review from nqngo April 13, 2024 17:01
- Remove DTS generation since we're not exporting a library
- clean output folder before building
@samhwang samhwang merged commit 92e58fd into main Apr 14, 2024
3 checks passed
@samhwang samhwang deleted the refactor/port-project-to-ts branch April 14, 2024 03:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants