Code Monkey home page Code Monkey logo

izuna's Introduction

Sometimes all you need is a little time to relax...

Izuna

Totally not another hobby project to explore stuffs.

This repository contains 2 main components : A web server and a Discord bot.

Why?

I want to explore stuffs. Also there is this library called fastify and really caught my attention, so yeah.

Oh yeah, I made several bots before but I realized on how messy the codes were (not that the current one ain't). I want to rewrite the bot while trying to keep up with current best practices.

Architecture(?)

Everything is composed inside src directory, including the bot and the web server. Basically anything that's going to be executed by default will have it's implementation lies inside src directory. Other things like convenience scripts would happen in scripts folder, if any.

Inside src lies the common stuff you'll see when creating web server. An index.ts file that will be the entrypoint, interfaces directory for storing types and interfaces used in the project, and probably any other additional directories if needed, such as models or lib.

The only exception is the bot directory which contains the entire implementation of the bot. Currently only Discord bot lies inside, but it is not impossible to expand to other platform, such as LINE. Anything regarding the bot should be only isolated to this directory.

Stacks

  • fastify for web backend
  • discord.js for Discord bot
  • @sapphire/framework for bot command handler

Usage

The application is containerized as Docker image where the definition lies in Dockerfile file. It only compiles everything inside src and spews out the output in build directory, then copied into the image where the "entrypoint" is index.js file. Simply build the image using docker and run with required environment variables. The list of environment variables will follow this section.

Running in development mode will not require Docker, but it's required to have .env file lies in the project root directory. Define all the required environment variables there. Start the app using the dev script defined in package.json and you're good to go.

Environment variables.

Variable Name Type Description
DISCORD_BOT_TOKEN string Token used to login to Discord bot.
DATABASE_URL string URL to Postgres Database used

Contributing

If this is the first time you want to contribute, you need the following programs installed.

  • git
  • Node.js v16 or above
  • Text editor / IDE. I prefer VSCode

If this is the first time you attempt to code, you need the following additional programs installed.

  • Github Desktop

Steps

  1. Clone the repository. If you're using git from command-line / terminal, just copy the HTTPS link and do git clone [the link] on your terminal. If you're using Github Desktop, the button is there for you.
  2. Open the project. If you're using VS Code, go to File > Open Folder... and choose the folder for this repository (should be "izuna" folder).
  3. Open the terminal/command-line. Make sure it's current location is in the project directory.
  4. Execute these commands from the terminal/command-line
yarn install
yarn build
  1. If there is nothing wrong then you're ready to go. Create a new branch where you can work in peace by using the following command
git checkout -b "[yourname]-[feature]"
  1. Make some changes. When you're done, add the changes, create commit, and push into the remote repo as new branch. In command line you can do this with.
git commit -am "insert commit message here"
git push origin "[yourname]-[feature]"
  1. Open this repository again in the web. Go to "Pull request" tab and click on green button "New pull request".
  2. Below the "Compare changes" title, there is a part about "base: master" <- compare: master" thingy. Change the latter into the recent branch name you've pushed. And then click on "Create Pull Request".
  3. Your changes will be reviewed. If things are good, then congrats! You have contributed to this project! Nice!

izuna's People

Contributors

arung-agamani avatar dzakyfattan avatar terrabalt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.