Easy config module for Discord bots
Project description
discord-config
=======
``discord-config`` is a Python library to help saving and loading configuration files.
Warning: Still in development, so use with care!
Installation
------------
discord-config is available on PyPI under ``discord_config``:
.. code-block:: bash
$ pip install -U discord_config
Or for the latest development version:
.. code-block:: bash
$ pip install -U git+https://github.com/nowakcasimir/discord-config.git#egg=discord_config
Basic Example
-------------
.. code-block:: python3
from discord_config import Settings
# (settings will be saved by default to settings.json, if it is not defined)
settings = Settings()
print (settings)
print (settings.token) #> "...yourtoken..."
print (settings.server_id) #> "123123123"
settings.clear() # Clears the settings
# You can define arbitrary settings to Settings object defaults
settings = Settings(defaults = {
"token": "...yourtoken...",
"botname": "MyDiscordBot",
"joinservers": False,
"idleTimer": 100
})
print (settings)
print (settings.token) #> "...yourtoken..."
print (settings.botname) #> "...MyDiscordBot..."
print (settings.joinservers) #> False
print (settings.idleTimer) #> 100
# Defaults were overwritten
try:
print (settings.server_id)
except Exception as e:
#> AttributeError: 'Settings' object has no attribute 'server_id'
pass
settings.set('id', 'broker')
print (settings.id) #> 100
settings.save() # outputs settings.json by default
settings = Settings() # Now it loads settings.json
print (settings)
settings.clear()
Documentation
-------------
See the documentation at https://discord-rnn.neocities.org/.
=======
``discord-config`` is a Python library to help saving and loading configuration files.
Warning: Still in development, so use with care!
Installation
------------
discord-config is available on PyPI under ``discord_config``:
.. code-block:: bash
$ pip install -U discord_config
Or for the latest development version:
.. code-block:: bash
$ pip install -U git+https://github.com/nowakcasimir/discord-config.git#egg=discord_config
Basic Example
-------------
.. code-block:: python3
from discord_config import Settings
# (settings will be saved by default to settings.json, if it is not defined)
settings = Settings()
print (settings)
print (settings.token) #> "...yourtoken..."
print (settings.server_id) #> "123123123"
settings.clear() # Clears the settings
# You can define arbitrary settings to Settings object defaults
settings = Settings(defaults = {
"token": "...yourtoken...",
"botname": "MyDiscordBot",
"joinservers": False,
"idleTimer": 100
})
print (settings)
print (settings.token) #> "...yourtoken..."
print (settings.botname) #> "...MyDiscordBot..."
print (settings.joinservers) #> False
print (settings.idleTimer) #> 100
# Defaults were overwritten
try:
print (settings.server_id)
except Exception as e:
#> AttributeError: 'Settings' object has no attribute 'server_id'
pass
settings.set('id', 'broker')
print (settings.id) #> 100
settings.save() # outputs settings.json by default
settings = Settings() # Now it loads settings.json
print (settings)
settings.clear()
Documentation
-------------
See the documentation at https://discord-rnn.neocities.org/.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
discord_config-0.0.1.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for discord_config-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21304971d1ce6856973d5f7416f37e2e2747afe53541483abed28dd56fa6d258 |
|
MD5 | 438e49b671592dfb72fd1797fc2bf1ca |
|
BLAKE2b-256 | ea2a7355aa9d5a8e9fb4656a904f5b535c73f1e30753bee21b79452782d714eb |