components

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultCommands []Command
)

Functions

This section is empty.

Types

type Command

type Command interface {
	Name() string

	Create() []discord.ApplicationCommandCreate
	IsPrivate() bool
	CommandHandler() func(event *events.ApplicationCommandInteractionCreate) error
	ComponentHandler() func(event *events.ComponentInteractionCreate) error
	ModalHandler() func(event *events.ModalSubmitInteractionCreate) error
	AutocompleteHandler() func(event *events.AutocompleteInteractionCreate) error
	OnEvent() func(event bot.Event) error
	Scheduler() []Scheduler
}

type Components

type Components struct {
	Version string
	// contains filtered or unexported fields
}

func New

func New(db *ent.Client, conf Config) *Components

func (*Components) AddCommand

func (c *Components) AddCommand(cmd Command)

func (*Components) AddCommands

func (c *Components) AddCommands(cmds ...Command)

func (*Components) Config

func (c *Components) Config() Config

func (*Components) DB

func (c *Components) DB() *ent.Client

func (*Components) GetLock

func (c *Components) GetLock(namespace string) *Mu

func (*Components) GuildCreate

func (c *Components) GuildCreate(ctx context.Context, ownerID snowflake.ID, g *events.GenericGuild) (*ent.Guild, error)

func (*Components) GuildCreateID

func (c *Components) GuildCreateID(ctx context.Context, gid snowflake.ID) (*ent.Guild, error)

func (*Components) GuildRequest

func (c *Components) GuildRequest(client bot.Client, gid snowflake.ID) (*discord.Guild, error)

func (*Components) Initialize

func (c *Components) Initialize(client bot.Client) error

func (*Components) MemberCreate

func (c *Components) MemberCreate(ctx context.Context, u discord.User, gid snowflake.ID) (*ent.Member, error)

func (*Components) OnEvent

func (c *Components) OnEvent() func(bot bot.Event)

func (*Components) OnGuildJoin

func (c *Components) OnGuildJoin() func(event *events.GuildJoin)

func (*Components) OnGuildLeave

func (c *Components) OnGuildLeave() func(event *events.GuildLeave)

func (*Components) UserCreate

func (c *Components) UserCreate(ctx context.Context, u discord.User) (*ent.User, error)

type Config

type Config struct {
	TranslateDir string        `yaml:"translate_dir"`
	Debug        ConfigDebug   `yaml:"debug"`
	Message      ConfigMessage `yaml:"message"`

	MySQL string   `yaml:"mysql"`
	Redis []string `yaml:"redis"`

	BumpUserID snowflake.ID `yaml:"bump_user"`
	BumpImage  string       `yaml:"bump_image"`
	UpUserID   snowflake.ID `yaml:"up_user"`
	UpColor    int          `yaml:"up_color"`
}

func Load

func Load(path string) (config *Config, err error)

type ConfigDebug

type ConfigDebug struct {
	DebugUsers  []snowflake.ID `yaml:"users"`
	DebugGuilds []snowflake.ID `yaml:"guilds"`
}

type ConfigMessage

type ConfigMessage struct {
	PinIconImage string `yaml:"pin_icon_image"`
}

type Mu

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

func (*Mu) Mutex

func (m *Mu) Mutex(id snowflake.ID) *sync.Mutex

type Scheduler

type Scheduler struct {
	Duration time.Duration
	Worker   SchedulerFunc
}

type SchedulerFunc

type SchedulerFunc func(c *Components, client bot.Client) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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