Skip to content

Bot library for handling CodeTokens

License

Notifications You must be signed in to change notification settings

higgsbot/libcurrency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libcurrency

libcurrency is a Python library created to be an easy currency implementation for Discord bots.
Designed for HiggsBot.

Usage

import libcurrency
import asyncio
import discord

currency = libcurrency.Token()

@bot.event
async def on_ready():
    await currency.start() # Needs to be ran once at the start of the bot. This is the function that gives currency over time.
    bot.loop.create_task(currency.payment()) # Starts the loop that awards users CodeTokens.

@bot.listen()
async def on_member_join(member):
    currency.join(member)

currency.check_balance(user) # Returns the amount of codetokens belonging to a user.

try:        
    currency.remove_tokens(user, amount) # Removes codetokens from a user
except Exception as e:
    print(e)

currency.set_balance(user, amount) # Set codetoken balance to a specific value for a user

See test.py for further usage example.
See the Testing branch for an implementation example.

Requirements

The library relies on Async IO to be able to run the codetoken awarding function in the background.
Since Discord.py requires this as well, it doesn't add unnecessary bulk to the code.
Dataset is used to store user data.

License

MIT

About

Bot library for handling CodeTokens

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages