rule

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChannelFormat

type ChannelFormat int
const (
	ChannelFormatDisplay ChannelFormat = iota
	ChannelFormatMention
)

func ParseChannelFormat

func ParseChannelFormat(s string) ChannelFormat

func (ChannelFormat) Format

func (f ChannelFormat) Format(channel discord.Channel) string

func (ChannelFormat) String

func (f ChannelFormat) String() string

type History

type History int
const (
	HistoryNone History = iota
	HistoryNameOnly
	HistoryNameWithDuration
	HistoryNameWithDurationAndTimeline
)

func ParseHistory

func ParseHistory(s string) History

func (History) ShouldDisplayDuration

func (m History) ShouldDisplayDuration() bool

func (History) ShouldDisplayName

func (m History) ShouldDisplayName() bool

func (History) ShouldDisplayTimeline

func (m History) ShouldDisplayTimeline() bool

func (History) String

func (m History) String() string

type Repository

type Repository interface {
	// UpdateRule updates the rule for the given guild, category or channel
	SaveRule(scope Scope, id snowflake.ID, rule Rule)
	DeleteRule(scope Scope, id snowflake.ID)

	// ScopedEffectiveRule returns the rule for the specifier, and the kind of scope it was found in
	ScopedEffectiveRule(guildID snowflake.ID, categoryID *snowflake.ID, channelID snowflake.ID) (Rule, Scope)
	// EffectiveRule returns the rule for the given specifier.
	EffectiveRule(guildID snowflake.ID, categoryID *snowflake.ID, channelID snowflake.ID) Rule

	FindRule(scope Scope, id snowflake.ID) (Rule, bool)
	FindGuildRule(guildID snowflake.ID) (Rule, bool)
	FindCategoryRule(categoryID snowflake.ID) (Rule, bool)
	FindChannelRule(channelID snowflake.ID) (Rule, bool)
}

func CreateRepository

func CreateRepository(db *gorm.DB) Repository

type Rule

type Rule struct {
	Enabled             bool
	NotificationChannel snowflake.ID
	History             History
	UserFormat          UserFormat
	ChannelFormat       ChannelFormat
}

type RuleModel

type RuleModel struct {
	gorm.Model
	Scope               int    `gorm:"primary_key"`
	Identifier          uint64 `gorm:"primary_key"`
	Enabled             bool
	NotificationChannel uint64
	History             string
	UserFormat          string
	ChannelFormat       string
}

type Scope

type Scope int
const (
	ScopeGuild Scope = iota
	ScopeCategory
	ScopeChannel
)

never change the order of the constants

func (Scope) String

func (s Scope) String() string

type UserFormat

type UserFormat int
const (
	UserFormatUsername UserFormat = iota
	UserFormatDisplay
	UserFormatMention
)

func ParseUserFormat

func ParseUserFormat(s string) UserFormat

func (UserFormat) Format

func (f UserFormat) Format(member *discord.Member) string

func (UserFormat) String

func (f UserFormat) String() string

Jump to

Keyboard shortcuts

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