inventory

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotAuthorized = errors.New("you are not an admin role")
)

errors that can occur

Functions

func Fetch

func Fetch(ctx ken.SubCommandContext, m data.Models, adminOnly bool) (inv *data.Inventory, err error)

Helper to attempt to fetch given user's inventory from user command option

func FetchHandler

func FetchHandler(ctx ken.SubCommandContext, m data.Models, adminOnly bool) (handler *inventory.InventoryHandler, err error)

Middleware for inventory commands to fetch inventory and ensure user is authorized

func InventoryAuthorized

func InventoryAuthorized(
	ctx ken.SubCommandContext,
	inv *data.Inventory,
	wl []*data.Whitelist,
) bool

Helper to determine if user is authorized to use inventory command based on: 1. In their confessional (and owner of inventory) 2. In a whitelisted channel (and an admin)

func InventoryEmbedBuilder

func InventoryEmbedBuilder(
	inv *data.Inventory,
	host bool,
) *discordgo.MessageEmbed

Helper to build inventory embed message based off if user is host or not

func ParseAbilityString

func ParseAbilityString(raw string) (name string, charges int, err error)

Ability strings follow the format of 'Name [#]'

func UpdateInventoryMessage

func UpdateInventoryMessage(sesh *discordgo.Session, i *data.Inventory) (err error)

func UpsertAA

func UpsertAA(inv *data.Inventory, aa *data.AnyAbility, charges ...int)

Will attempt to upate the given any ability in the inventory and if not present will add it

func UpsertAbility

func UpsertAbility(inv *data.Inventory, aa *data.Ability, charges ...int)

Will attempt to upate the given ability in the inventory and if not present will add it

Types

type Inventory

type Inventory struct {
	// contains filtered or unexported fields
}

func (*Inventory) Components

func (*Inventory) Components() []*discordgo.MessageComponent

Components implements main.BetrayalCommand.

func (*Inventory) Description

func (*Inventory) Description() string

Description implements ken.SlashCommand.

func (*Inventory) Initialize

func (i *Inventory) Initialize(m data.Models, s *scheduler.BetrayalScheduler)

func (*Inventory) Name

func (*Inventory) Name() string

Name implements ken.SlashCommand.

func (*Inventory) Options

func (*Inventory) Run

func (i *Inventory) Run(ctx ken.Context) (err error)

Run implements ken.SlashCommand.

func (*Inventory) Type

func (*Inventory) Version

func (*Inventory) Version() string

Version implements ken.SlashCommand.

Jump to

Keyboard shortcuts

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