ProgrammingPhilippines / progphil-bot

Programming Philippines Discord Bot
MIT License
23 stars 6 forks source link

[CHORE] codebase cleanup #237

Closed mystique09 closed 2 months ago

mystique09 commented 2 months ago

Description

The proposed project structure has been implemented, bot/, cogs/, ui/, and utils/ has been moved inside src/. The database/ has been renamed to data/ and moved inside src/. Also, files in each directory has been group by related feature.

The cogs/ no longer uses GuildInfo like a constant as it has been passed as a dependency in the Progphil class in the main.py file.

Decorators now don't depend on GuildInfo to get the staff_roles, instead it fetches the staff_roles via interaction.client.config.guild or ctx.client.config.guild since config was passed as dependency in the Progphil instance from the start.

Config class from config.py has been refactored to use pydantic module to parse config file instead of using a metaclass.

Database pool creation, and database migration has been moved to main().

Lint workflow has been updated to crawl the src/ directory.

Github deploy workflow has been for the new project structure.

Dockerfile has been updated to properly build the project.

Project config file(pyproject.toml) has been updated to include the src directory during packaging, I also added a script poetry run progphil which invokes the run() function in the main file.

Testing

An attempt on testing the discord API has failed, there are limitations to the dpytest library, prefix command can be tested but struggles on embed response. Also struggles when the command depends on a third-party library, I hit the monthly limit of currency API and after that the bot won't start(because the Converter cog calls the currency api at init to get currency data and crashes because reponse is 403) lmao.

Dependency updates:

Resolves #162

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Test Configuration:

Checklist:

mystique09 commented 2 months ago

Testing commands on dev server.

Prefix commands

pph-help image

pph-define <word> image

pph-exchange <amount> <from> <to> image

pph-currencies image

Slash commands

/anon forums <commands> image

/announce image

/shout image

/welcomer image

/help-solver image

/responder add image

/forum-assist new image

/forum-assis list image

/forum-cleanup schedule image

/trivia channel setup image