economy

package
v0.0.0-...-82a33b0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ECONOMY = "economy"
)

Variables

View Source
var ErrAccountAlreadyExist = errors.New("account already exists")
View Source
var ErrInsufficintBalance = errors.New("account has insufficent funds")
View Source
var ErrNoAccount = errors.New("the account does not exist")
View Source
var ErrSameSenderAndReceiver = errors.New("the transmitter and receiver are the same account")

Functions

func GetAdminHelp

func GetAdminHelp() []string

GetAdminHelp returns help information about the heist bot commands

func GetCommands

GetCommands returns the component handlers, command handlers, and commands for the payday bot.

func GetCurrentLeaderboard

func GetCurrentLeaderboard(serverID string, limit int) []*leaderboardAccount

GetCurrentLeaderboard returns the top `limit` accounts for the server.

func GetCurrentRanking

func GetCurrentRanking(serverID string, memberID string) int

GetCurrentRanking returns the global ranking on the server for a given player.

func GetLifetimeLeaderboard

func GetLifetimeLeaderboard(serverID string, limit int) []*leaderboardAccount

GetLifetimeLeaderboard returns the top `limit` accounts for the server.

func GetLifetimeRanking

func GetLifetimeRanking(serverID string, memberID string) int

GetLifetimeRanking returns the global ranking on the server for a given player.

func GetMemberHelp

func GetMemberHelp() []string

GetHelp returns help information about the heist bot commands

func GetMonthlyLeaderboard

func GetMonthlyLeaderboard(serverID string, limit int) []*leaderboardAccount

GetMonthlyLeaderboard returns the top `limit` accounts for the server.

func GetMonthlyRanking

func GetMonthlyRanking(serverID string, memberID string) int

GetMonthlyRanking returns the global ranking on the server for a given player.

func GetRanking

func GetRanking(accounts []*Account, memberID string, sortFunc func(i, j int) bool) int

GetRanking returns the ranking for the given member for various economy leaderboards. The sortFunc passed in determines how the rankings are determined.

func LoadBanks

func LoadBanks()

LoadBanks returns all the banks for the given guilds.

func SaveBank

func SaveBank(bank *Bank)

SaveBank saves the bank.

func Start

func Start(s *discordgo.Session)

Start intializes the economy.

Types

type Account

type Account struct {
	ID              string    `json:"_id" bson:"_id"`
	MonthlyBalance  int       `json:"monthly_balance" bson:"monthly_balance"`
	CurrentBalance  int       `json:"current_balance" bson:"current_balance"`
	LifetimeBalance int       `json:"lifetime_balance" bson:"lifetime_balance"`
	CreatedAt       time.Time `json:"created_at" bson:"created_at"`
	Name            string    `json:"name" bson:"name"`
	// contains filtered or unexported fields
}

Account is the bank account for a member of the server/guild.

func (*Account) DepositCredits

func (a *Account) DepositCredits(amount int)

DepositCredits adds the amount of credits to the account at a given bank

func (*Account) WithdrawCredits

func (a *Account) WithdrawCredits(amount int) error

WithDrawCredits deducts the amount of credits from the account at the given bank

type Bank

type Bank struct {
	ID             string              `json:"_id" bson:"_id"`
	BankName       string              `json:"bank_name" bson:"bank_name"`
	Currency       string              `json:"currency" bson:"currency"`
	DefaultBalance int                 `json:"default_balance" bson:"default_balance"`
	Accounts       map[string]*Account `json:"accounts" bson:"accounts"`
	LastSeason     time.Time           `json:"last_season" bson:"last_season"`
	ChannelID      string              `json:"channel_id" bson:"channel_id"`
	// contains filtered or unexported fields
}

Bank is the repository for all accounts for a given server/guild.

func GetBank

func GetBank(serverID string) *Bank

GetBank returns the bank for the server/guild.

func (*Bank) GetAccount

func (b *Bank) GetAccount(playerID string, playerName string) *Account

GetAccount returns the bank account for the player.

type BankStore

type BankStore interface {
	// contains filtered or unexported methods
}

BankStore defines the methods required to load and save the economy state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL