Documentation
¶
Index ¶
Constants ¶
const ( TrialStateOpen = "open" TrialStateClosed = "closed" )
State Constants
Variables ¶
var ErrBadSetting = errors.New("bad setting")
ErrBadSetting is the error returned if an unknown setting is accessed
var ErrGuildNotExist = errors.New("guild does not exist")
ErrGuildNotExist is the error returned if a guild does not exist
var ErrTrialNotExist = errors.New("trial does not exist")
ErrTrialNotExist is the error returned if a trial does not exist
Functions ¶
This section is empty.
Types ¶
type Guild ¶
type Guild interface { GetName(ctx context.Context) string GetSettings(ctx context.Context) GuildSettings SetName(ctx context.Context, name string) SetSettings(ctx context.Context, s GuildSettings) Serialize(ctx context.Context) ([]byte, error) }
Guild is the api for managing guild settings for a particular guild
type GuildAPI ¶
type GuildAPI interface { NewTransaction(ctx context.Context, writable bool) (GuildAPITx, error) AllGuilds(ctx context.Context) ([]string, error) }
GuildAPI is the api for managing guild settings transactions
type GuildAPITx ¶
type GuildAPITx interface { Commit(ctx context.Context) error Rollback(ctx context.Context) error GetGuild(ctx context.Context, name string) (Guild, error) AddGuild(ctx context.Context, name string) (Guild, error) SaveGuild(ctx context.Context, guild Guild) error }
GuildAPITx is the api for managing guild settings within a transaction
type GuildSettings ¶
type GuildSettings struct { ControlSequence string AnnounceChannel string SignupChannel string AdminChannel string AnnounceTo string ShowAfterSignup string ShowAfterWithdraw string AdminRole string // contains filtered or unexported fields }
GuildSettings is the set of configuration settings for a guild
func GetSettings ¶ added in v0.1.3
func GetSettings(ctx context.Context, gapi GuildAPI, gid snowflake.Snowflake) (GuildSettings, error)
GetSettings is a wrapper to get the configuration settings for a guild
NOTE: this cannot be called after another transaction has been started
func (*GuildSettings) GetSettingString ¶
GetSettingString gets the value of a setting
func (*GuildSettings) PrettyString ¶
func (s *GuildSettings) PrettyString(ctx context.Context) string
PrettyString returns a multi-line string describing the settings
func (*GuildSettings) SetSettingString ¶
func (s *GuildSettings) SetSettingString(ctx context.Context, name, val string) error
SetSettingString sets the value of a setting
type RoleCount ¶
type RoleCount interface { GetRole(ctx context.Context) string GetCount(ctx context.Context) uint64 GetEmoji(ctx context.Context) string }
RoleCount is the api for managing a role in a trial
type Trial ¶
type Trial interface { GetName(ctx context.Context) string GetDescription(ctx context.Context) string GetAnnounceTo(ctx context.Context) string GetAnnounceChannel(ctx context.Context) string GetSignupChannel(ctx context.Context) string GetState(ctx context.Context) TrialState GetSignups(ctx context.Context) []TrialSignup GetRoleCounts(ctx context.Context) []RoleCount PrettySettings(ctx context.Context) string SetName(ctx context.Context, name string) SetDescription(ctx context.Context, d string) SetAnnounceTo(ctx context.Context, val string) SetAnnounceChannel(ctx context.Context, val string) SetSignupChannel(ctx context.Context, val string) SetState(ctx context.Context, state TrialState) AddSignup(ctx context.Context, name, role string) RemoveSignup(ctx context.Context, name string) SetRoleCount(ctx context.Context, name, emoji string, ct uint64) RemoveRole(ctx context.Context, name string) ClearSignups(ctx context.Context) Serialize(ctx context.Context) ([]byte, error) }
Trial is the api for managing a particular trial
type TrialAPI ¶
type TrialAPI interface {
NewTransaction(ctx context.Context, guild string, writable bool) (TrialAPITx, error)
}
TrialAPI is the API for managing trials transactions
type TrialAPITx ¶
type TrialAPITx interface { Commit(ctx context.Context) error Rollback(ctx context.Context) error GetTrial(ctx context.Context, name string) (Trial, error) AddTrial(ctx context.Context, name string) (Trial, error) SaveTrial(ctx context.Context, trial Trial) error DeleteTrial(ctx context.Context, name string) error GetTrials(ctx context.Context) []Trial }
TrialAPITx is the api for managing trials within a transaction