Skip to main content

Discord Bot Library - UI & Image Manipulation for Making Games

Project description

Discord Bot Library for Writing Discord Bots with in Python

A wrapper over discord.py and Pillow for bot management, image manipulation, easy data persistence, and more for making gameplay focused discord bots, but capable of making pretty much any kind of discord bot Provides:

  • Image creation with a UI system, and sprite management
  • Out-of-the-box persistent data management for players with extensibility to handle anything
  • Various utilities for testing, and debugging to assist in development

Table of Contents

  1. Installation
  2. Troubleshooting
  3. Getting Help

Installation

Requires:

  • Python 3.13+
  • discord.py
  • pillow

Installing CordForge

py -m venv .venv
<activate venv>
pip install cordforge

Or install from source:

git clone https://github.com/Robert-DeForrest-Reynolds/CordForge
cd CordForge
py -m venv .venv
<activate venv>
pip install -e .

Create Your Bot Token

First, create a Discord application and bot at Discord Developer Portal.

Set Up Your Project

Create a keys file in your project directory: key_name~your_discord_bot_token_here

dev_name=OTk3MDA...

Your "main" file must be called entry.py

Basic Bot Setup

entry.py

from CordForge import *

bot = Cord("cmd")

# Initial send of dashboard, all other functions are replys/edits of the sent message
async def entry(user_card:Card) -> Card:
    await user_card.new_image()
    panel:Panel = await user_card.panel(border=True)
    await user_card.text("Hello", Vector2(5, 5), parent=panel)
    await user_card.add_button("Some other thing", some_other_card, [])


async def some_other_card(user_card:Card, interaction) -> None:
    await user_card.new_image()
    await user_card.add_button("Home", roc.home, [])
    await roc.reply(user_card, interaction)

# any necessary setup, loading images into memory, data management, etc.
bot.launch(entry)

Launch & Use Bot

cordforge dev_name

Type cmd into the Discord server where Bot is a member.

Use stop to stop the bot completely. Use restart to restart the Discord bot, implementing any changes in scripts. Use exit to exit the launcher. The launcher will not let you exit with a running bot. Use // to emergency stop the bot. Easy to type in cases of wild loops, or other problems.

Player Data & Persistence

A players profile is created, and saved as soon as they use their first panel. You can add traits to their Player object, and they will automatically be saved and reloaded.

from CordForge import *

bot = Cord("cmd")

# Initial send of dashboard, all other functions are replys/edits of the sent message
async def entry(user_card:Card) -> Card:
    await user_card.new_image()
    await user_card.add_button(f"Money: {user_card.user.wallet}", give_money, [])


async def give_money(user_card:Card, interaction) -> None:
    user_card.user.wallet += 1
    await bot.home(user_card, interaction)


traits = [
    # [trait name, trait value]
    ["wallet", 0.00],
]
bot.user_traits = traits
bot.launch(entry)

More Information

Cord inherits from discord.py's Bot class, so you could add commands, cogs, and whatnot as you might normally.

The Card class _.image is a pillow image, and you can use all of it's variables, and functions.

Anything that CordForge can't do, can easily be implemented alongside it.

Discord channel for any help

Version Control Recommendation

Ensure your Keys file is hidden, here is a recommend .gitignore for example:

__pycache__
.venv
Keys
Data

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cordforge-0.3.16.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cordforge-0.3.16-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file cordforge-0.3.16.tar.gz.

File metadata

  • Download URL: cordforge-0.3.16.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for cordforge-0.3.16.tar.gz
Algorithm Hash digest
SHA256 17891db4a47d1525b32a21df6b61511f8a636780325115f887a4bcd5c270c7d5
MD5 9553c57e14e49aa989e85e2fc15c7f9b
BLAKE2b-256 81c7a7d5a04499e5b967bd1394d066c10f7e5ce66c85c608c98e2c09fd4a220f

See more details on using hashes here.

File details

Details for the file cordforge-0.3.16-py3-none-any.whl.

File metadata

  • Download URL: cordforge-0.3.16-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for cordforge-0.3.16-py3-none-any.whl
Algorithm Hash digest
SHA256 24771bee3857a9dbdfc741cf0352e372bb59e21bfbce40151b8a07c746f52245
MD5 6c97a540fe55bd1b93f899088e3f5570
BLAKE2b-256 e508d1431f09d8df64eea1a090f657278fd2617212be49ab4b75d05ace9978af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page