repository

package
v0.0.0-...-2e419a0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NameVisibilityShow          = NameVisibilitySetting(iota) // SHOW
	NameVisibilityShowInDMsOnly                               // SHOW_IN_DMS_ONLY
	NameVisibilityHide                                        // HIDE
)
View Source
const (
	OperationAdd
	OperationSubtract
	OperationMultiply
	OperationDivide
	OperationSet
)

Variables

View Source
var ErrDuplicate = errors.New("the object already exists")
View Source
var ErrInvalidOperation = errors.New("invalid math operation")
View Source
var ErrNoResults = errors.New("not found")

Functions

func ToDiscordEmbedFields

func ToDiscordEmbedFields(fields []*MessageEmbedField) []*discordgo.MessageEmbedField

Types

type APIKey

type APIKey struct {
	ID      int64
	Key     string
	GuildID string
}

type AdvertiserPrivileges

type AdvertiserPrivileges struct {
	ID      int64
	GuildID string
	RoleID  string
	Weight  float64
	// Delay in seconds
	Delay int
	// AutoSignupDuration in seconds
	AutoSignupDuration int
}

type AdvertiserPrivilegesRepository

type AdvertiserPrivilegesRepository interface {
	// GetAdvertiserPrivilegesForGuild Returns advertiser privileges for all roles in a guild.
	GetAdvertiserPrivilegesForGuild(guildID string) ([]*AdvertiserPrivileges, error)
	// GetAdvertiserPrivilegesForRole Returns advertiser privileges for a particular role in a guild or ErrNoResults.
	GetAdvertiserPrivilegesForRole(guildID, roleID string) (*AdvertiserPrivileges, error)
	// InsertAdvertiserPrivileges Creates advertiser privileges or updates privileges if the role already has privileges set.
	InsertAdvertiserPrivileges(privileges *AdvertiserPrivileges) error
	// DeleteAdvertiserPrivileges Deletes specific advertiser privileges.
	DeleteAdvertiserPrivileges(privileges *AdvertiserPrivileges) error
}

type ApiKeyRepository

type ApiKeyRepository interface {
	// GetAPIKey Returns either the API key or ErrNoResults.
	GetAPIKey(key string) (*APIKey, error)
	// NewAPIKey Creates a new api key for the specified guild and returns it.
	NewAPIKey(guildID string) (*APIKey, error)
}

type AutoSignupSession

type AutoSignupSession struct {
	ID           int64
	GuildID      string
	AdvertiserID string
	ExpiresAt    time.Time
}

type AutoSignupSessionRepository

type AutoSignupSessionRepository interface {
	IsAutoSignupEnabled(guildID, advertiserID string) (bool, error)
	EnableAutoSignup(guildID, advertiserID string, expiresAt time.Time) (*AutoSignupSession, error)
	CancelAutoSignup(guildID, advertiserID string) error
	GetEnabledAutoSignups() ([]*AutoSignupSession, error)
	GetEnabledAutoSignupsInGuild(guildID string) ([]*AutoSignupSession, error)
	InsertAutoSignupDelayedMessages(autoSignup *AutoSignupSession, delayedMessages []*DelayedMessage) error
	GetAutoSignupDelayedMessageIDs(guildID, advertiserID string) ([]int64, error)
}

type BoostRequest

type BoostRequest struct {
	ID int64
	// TODO generate uuids for all nulls and make the column not null
	ExternalID             *uuid.UUID
	Channel                *BoostRequestChannel
	GuildID                string
	BackendChannelID       string
	RequesterID            string
	AdvertiserID           string
	BackendMessages        []*BoostRequestBackendMessage
	Message                string
	EmbedFields            []*MessageEmbedField
	Price                  int64
	PreferredAdvertiserIDs map[string]struct{}
	CreatedAt              time.Time
	IsResolved             bool
	ResolvedAt             time.Time
	NameVisibility         NameVisibilitySetting
	CollectUsersOnly       bool
}

type BoostRequestBackendMessage

type BoostRequestBackendMessage struct {
	ChannelID string
	MessageID string
}

type BoostRequestChannel

type BoostRequestChannel struct {
	ID                int64
	GuildID           string
	FrontendChannelID string
	BackendChannelID  string
	UsesBuyerMessage  bool
	SkipsBuyerDM      bool
}

type BoostRequestChannelRepository

type BoostRequestChannelRepository interface {
	// GetBoostRequestChannelByFrontendChannelID Returns the boost request channel with the specified frontend channel. Frontend channels are unique.
	// Returns ErrNoResults if the channel does not exist.
	GetBoostRequestChannelByFrontendChannelID(guildID string, frontendChannelID string) (*BoostRequestChannel, error)
	// GetBoostRequestChannels Returns all boost request channels in a guild.
	GetBoostRequestChannels(guildID string) ([]*BoostRequestChannel, error)
	// InsertBoostRequestChannel Creates a new boost request channel. If the channel already exists, it will be updated.
	// brc will have its ID field updated to match the newly inserted row's id.
	InsertBoostRequestChannel(brc *BoostRequestChannel) error
	// DeleteBoostRequestChannel Deletes a specific boost request channel.
	DeleteBoostRequestChannel(brc *BoostRequestChannel) error
	// DeleteBoostRequestChannelsInGuild Deletes all boost request channels in a guild.
	DeleteBoostRequestChannelsInGuild(guildID string) error
}

type BoostRequestRepository

type BoostRequestRepository interface {
	// GetUnresolvedBoostRequests Returns all unresolved boost requests for any guild.
	GetUnresolvedBoostRequests() ([]*BoostRequest, error)
	// GetBoostRequestByBackendMessageID Returns the boost request associated with a backend message or ErrNoResults.
	GetBoostRequestByBackendMessageID(backendChannelID, backendMessageID string) (*BoostRequest, error)
	// GetBoostRequestById Returns a boost request in the specified guild with the specified id
	GetBoostRequestById(guildID string, boostRequestID uuid.UUID) (*BoostRequest, error)
	// InsertBoostRequest Stores a boost request. Boost requests are unique by backend message id, so this will error if a boost request already exists.
	// br will have its ID field updated to match the newly inserted row'd id.
	InsertBoostRequest(br *BoostRequest) error
	// ResolveBoostRequest Updates fields necessary to flag a boost request as resolved.
	ResolveBoostRequest(br *BoostRequest) error
	// DeleteBoostRequest Deletes a boost request
	DeleteBoostRequest(br *BoostRequest) error
	InsertBoostRequestDelayedMessage(br *BoostRequest, delayedMessage *DelayedMessage) error
	GetBoostRequestDelayedMessageIDs(br *BoostRequest) ([]int64, error)
}

type DelayedMessage

type DelayedMessage struct {
	ID                int64
	DestinationID     string
	DestinationType   DestinationType
	FallbackChannelID string
	Message           *discordgo.MessageSend
	SendAt            time.Time
}

type DelayedMessageRepository

type DelayedMessageRepository interface {
	GetDelayedMessages() ([]*DelayedMessage, error)
	InsertDelayedMessage(delayedMessage *DelayedMessage) error
	DeleteDelayedMessage(id int64) error
	FlagDelayedMessageAsSent(message *DelayedMessage) error
}

type DestinationType

type DestinationType string
var (
	DestinationTypeChannel DestinationType = "CHANNEL"
	DestinationTypeUser    DestinationType = "USER"
)

type LogChannelRepository

type LogChannelRepository interface {
	// GetLogChannel Returns a guild's log channel or ErrNoResults.
	GetLogChannel(guildID string) (channelID string, err error)
	// InsertLogChannel Creates a log channel for a guild or updates it if it already exists.
	InsertLogChannel(guildID, channelID string) error
	// DeleteLogChannel Deletes a guild's log channel.
	DeleteLogChannel(guildID string) error
}

type MessageEmbedField

type MessageEmbedField struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Inline bool   `json:"inline"`
}

func FromDiscordEmbedFields

func FromDiscordEmbedFields(fields []*discordgo.MessageEmbedField) []*MessageEmbedField

type NameVisibilitySetting

type NameVisibilitySetting int

func NameVisibilitySettingFromString

func NameVisibilitySettingFromString(s string) NameVisibilitySetting

func (NameVisibilitySetting) String

func (i NameVisibilitySetting) String() string

type Operation

type Operation int

func OperationFromString

func OperationFromString(op string) (operation Operation, ok bool)

type QueuedWebhookRequest

type QueuedWebhookRequest struct {
	ID            int64
	Webhook       Webhook
	Body          string
	CreatedAt     time.Time
	LatestAttempt *time.Time
}

type Repository

Repository All methods are thread safe. All method that interact with a database may return database errors in addition to the specified ones.

type RollChannelRepository

type RollChannelRepository interface {
	// GetRollChannel Returns the channel ID that boost request RNG rolls should be posted to
	// or ErrNoResults if rolls should not be posted
	GetRollChannel(guildID string) (channelID string, err error)
	// InsertRollChannel Sets the channel that boost request RNG rolls should be posted to
	InsertRollChannel(guildID, channelID string) error
	// DeleteRollChannel Stops posting boost request RNG rolls
	DeleteRollChannel(guildID string) error
}

type StealCreditRepository

type StealCreditRepository interface {
	// GetStealCreditsForUser Returns the number of boost request steal credits avilable to a user.
	GetStealCreditsForUser(guildID, userID string) (int, error)
	// GetGlobalStealCreditsForUser Returns the number of boost request steal credits available to a user across all guilds.
	GetGlobalStealCreditsForUser(userID string) (map[string]int, error)
	// AdjustStealCreditsForUser Performs a math operation on the number of boost request steal credits in a user's possession.
	// If a valid operation is not specified, ErrInvalidOperation will be returned.
	AdjustStealCreditsForUser(guildID, userID string, operation Operation, amount int) error
	// UpdateStealCreditsForUser Short version of AdjustStealCreditsForUser with OperationSet
	UpdateStealCreditsForUser(guildID, userID string, amount int) error
}

type Webhook

type Webhook struct {
	ID      int64
	GuildID string
	URL     string
}

type WebhookAttempt

type WebhookAttempt struct {
	QueuedWebhookRequest QueuedWebhookRequest
	StatusCode           int
	CreatedAt            time.Time
}

type WebhookRepository

type WebhookRepository interface {
	GetWebhook(guildId string) (Webhook, error)
	InsertWebhook(webhook Webhook) error
	DeleteWebhook(Webhook Webhook) error
	InsertQueuedWebhook(webhook Webhook, body string) error
	GetQueuedWebhooks() ([]*QueuedWebhookRequest, error)
	InsertWebhookAttempt(attempt WebhookAttempt) error
}

Directories

Path Synopsis
Package mock_repository is a generated GoMock package.
Package mock_repository is a generated GoMock package.

Jump to

Keyboard shortcuts

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