FrugalityBot
Frugality is a Discord Bot written in Ruby using discordrb and PostgreSQL. Its usage is meant to track your own finances, with monthly and/or yearly reports. Work in progress.
Features
- Commands are separated into individual files in
src/commands. This is the only place you'll need to add a new command. - Automatically loads and registers new command files on startup.
- Uses PostgreSQL to store data (User IDs, coins amount, reason, timestamps).
- Supports Discord's slash commands, and embeds for financial reports.
Prerequisites
Before running the bot, ensure you have the following installed on your system:
- Ruby 3.3
- Bundler
- PostgreSQL
- Git
Installation
-
Clone the repository:
git clone https://git.thenight.club/csxkdv/FrugalityBot.git cd FrugalityBot -
Configure Bundler locally: This ensures gems are installed inside the project folder to avoid permission issues.
bundle config set --local path 'vendor/bundle' -
Install Dependencies:
bundle install
Database Setup
The bot requires a PostgreSQL database.
-
Create a database user:
sudo -u postgres createuser -s user -
Create the database:
createdb databaseThe database name is also specified here. Ensure it's the same as the one you'll use.
Note: The bot will automatically create the necessary tables (like
walletsandtransactions) the first time it connects. If you want new tables, update the database file as desired.
Configuration
-
Create a
.envfile in the root directory:touch .env -
Add your secrets to the
.envfile:BOT_TOKEN=your_discord_bot_token_here TEST_SERVER_ID=your_discord_server_idNote: Add a Server ID only if you're planning on updating the bot frequently, and want instant changes to be seen. Otherwise, remove it from the .env file and every
server_id: ENV['TEST_SERVER_ID']line from theregister_application_commandon everysrc/commands/*.rbfile.
Usage
To start the bot, you must use bundle exec to load the local dependencies:
bundle exec ruby main.rb
Wait for the bot to connect, and that's it, you can start using it.
License
This project is licensed under the GNU General Public License v3.0.