[go: up one dir, main page]

Skip to content

DEVUCP/EconBot

Repository files navigation

Python 3.12

icon

ECONBOT

Simple economy bot for discord.




Index




installation banner

Installation & Setup

  • Clone the repository

spray bg

git clone https://github.com/DEVUCP/EconBot
  • Make sure you have Python 3.12 or higher installed. You can check your version with :
python --version
  • Install the required dependencies:
pip install discord

Discord Application Deployment

  1. Sign into your discord account on the Discord Developer Portal

  2. Create a new application by clicking the New Application button in the top right of the page.

    new app Screenshot

    After creating your application, it will redirect you to its setting's page.

  3. Click the OAuth2 section.

    OAuth2 Screenshot
  4. Scroll down to the OAuth2 URL Generator.

  5. Tick on the Bot option.

    URL Gen Screenshot

    After that, the URL Generator panel will expand downward.

  6. Scroll down to Bot permissions and under "General permissions" tick Administrator.

    Admin perms Screenshot
  7. Scroll further down to Integration type and make sure its on Guild Install

    URL Screenshot
  8. You may use the Generated URL to invite your bot into your servers.


Token Setup & Environment Variable Setup

  1. Get your bot token from going to the Bot section in your application settings.

    Bot Screenshot
  2. Press on Reset Token to create your bot token. (NOTE: You will only be able to view it once after reseting, otherwise you'll have to reset it again)

    Reset token Screenshot
  3. Copy the token (its a bunch of random characters).

    Reset/Copy token Screenshot
  4. Set up an environment variable named econtoken and value as your token that you copied (here are some video tutorials...)

    Windows 10

    Windows 11

    Linux (Ubuntu)

Alternatively you can just directly paste the bot token into the code; however, this is not recommended.

  • To do this, go to the file main.py and on the last line you should see
singletons.client.run(os.getenv("econtoken"))
  • Replace it with this instead. (paste your token in place of the YOUR TOKEN HERE)
singletons.client.run("YOUR TOKEN HERE")

Running

  • Open up terminal
  • Make sure you're in the root directory (the folder you just cloned)

Note : You will have to run and terminate the bot process once to generate the save file so the bot will work.

  • Run the bot using
    py main.py
  • You can terminate it by pressing CTRL + C in the terminal you ran it in.

Running and terminating the first time will generate a userdata.pkl file in saveload directory which is necessary for the bot to work.

Run again after that and you should be good to go.




Player Manual

A Guide for players for how to play the game~

Earning Money

Work

You can earn money and employability with $work command. You make different amount of money depending on your occupation.

Crime

You can alternatively earn more money on average with $crime, but this will decrease your employability.

Beg

Finanlly, you can earn little money on average with $beg, this will decrease your employability, but not as much as crime.

Day-Night cycle (in-game time)

Every 1 minute that passes in real life is equal to 1 hour in game.

For now what time or day it is doesn't really affect gameplay whatsoever, but could be implemented easily using utils.py module.

Markets

Doing the market command will display the normal Market and a drop-down menu, where you could buy from the Black Market.

You can go to any page from the black market or normal market by just adding the page number in the command -> $market 3 (will display 3rd page of normal market)

Bank Cards

Your bank card determines the maximum you're allowed to deposit into your bank account.

To upgrade your card:

  1. Max out your current card by depositing to its limit
  2. Use the $balance command
  3. Click the green "Upgrade Card!" button that appears

Jobs

You can check available jobs with $jobs command.

Every in-game week avaialble jobs will change. You can only apply to those in that listing with $apply <job name>

Attributes

All they're used for at the moment is job requirements

Strength -> Can be increased with $workout

Dexterity -> Can be increased with $paint

Intelligence -> Can be increased with $study

Charisma -> Can be increased with $socalize

Creativity -> Can be increased with $paint

Employability -> Can be increased by working ($work)

Energy Bar

The main limiter with advancing in the game. You're supposed to tactically use your energy.

You gain 1 energy every in-game hour from the last time you've expended an energy slot.

You can check your bar with $profile or $energy if you want to just see your energy.

Items

Items can be bought in the markets, each can have a unique usage.

You can buy items for their selling price, but be careful- because you sell them for a loss!




Development Documentation.

UML

class structure can be found in UML claas diagrams.pdf (NOT UPDATED)

Coding conventions

spray bg

  • Folder & file names should be lowercase and flatcase.

  • Any non-const variables should be in snake_case.

  • Add comments to the code that explain the purpose of the code, not what it does.

  • All const variables should be in MACRO_CASE.

  • All Classes and Methods should be in PascalCase. Example: GetAccountID().

  • Make sure to use XML documentation with every function.

File saving

Saving ONLY occurs when bot's run is terminated. Generates a 'savedata.pkl' file in saveload/ directory.

Saving is done via python's pickle module.

See pickling documentation for more info.

Directory structure

.
├── assets/                     # Contains image files for the project
│   ├── icon.png
│   └── installation_banner.gif
│
├── commands/                   # Holds command-related modules
│   ├── apply.py
│   ├── bank.py
│   │
│   ├── display/                # Modules for displaying information
│   │   ├── balance.py
│   │   ├── clock.py
│   │   ├── help.py
│   │   │
│   │   ├── interactables/      # Interactive display components
│   │   │   └── itemlists.py
│   │   │
│   │   ├── inventory.py
│   │   ├── jobs.py
│   │   ├── markets.py
│   │   └── profile.py
│   │
│   ├── earnings.py
│   ├── inventory.py
│   └── training.py
│
├── econ/                       # Economy system modules
│   ├── attribute.py
│   ├── bank.py
│   │
│   ├── cards/
│   │   └── bankcard.py         # Bank card related modules
│   │
│   ├── energy.py
│   │
│   ├── items/                  # Item-related modules
│   │   ├── item.py
│   │   └── items.py
│   │
│   ├── jobs/                   # Job-related modules
│   │   ├── job.py
│   │   ├── jobs.py
│   │   └── listings.py
│   │
│   └── user.py
│
├── saveload/                   # Save and load functionality, also holds the generated save file.
│   └── saveload.py
│
├── constants.py
├── main.py
├── README.md
├── singletons.py
└── utils.py



Authors