domain

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueuePageSize = 10
)

Variables

View Source
var (
	ErrBadFormat        = errors.New("bad format")
	ErrInOtherChannel   = errors.New("bot is in a different voice channel")
	ErrMusicNotFound    = errors.New("music not found")
	ErrNotPlaying       = errors.New("not playing in any voice channels")
	ErrQueueNotFound    = errors.New("queue not found")
	ErrQueueOutOfBounds = errors.New("queue out of bounds")
)

Functions

This section is empty.

Types

type LoopMode

type LoopMode uint
const (
	LoopModeOff LoopMode = iota
	LoopModeOne
	LoopModeAll
)

func (LoopMode) String

func (m LoopMode) String() string

type Music

type Music struct {
	ID               string
	Query            string
	QueuedAt         time.Time
	QueuedByID       string
	QueuedByUsername string

	Source         MusicSource
	SpotifyTrackID string
	YouTubeVideoID string

	Loaded    bool
	Title     string
	URL       string
	Thumbnail string
	Duration  time.Duration
}

type MusicRepository

type MusicRepository interface {
	GetSpotifyPlaylist(id string) (*spotify.FullPlaylist, []spotify.PlaylistTrack, error)
	Load(music *Music) error
	GetStreamURL(music *Music) (string, error)
}

type MusicSource added in v1.2.0

type MusicSource uint
const (
	MusicSourceSpotifyPlaylist MusicSource = iota
	MusicSourceSpotifyTrack
	MusicSourceYouTubeVideo
	MusicSourceSearch
)

func (MusicSource) String added in v1.2.0

func (s MusicSource) String() string

type MusicUseCase

type MusicUseCase interface {
	Parse(query string, user *discordgo.User) (string, []*Music, error)
}

type Player

type Player struct {
	GuildID          string
	VoiceChannel     *discordgo.Channel
	NPChannel        *discordgo.Channel
	Conn             *discordgo.VoiceConnection
	Status           PlayerStatus
	CurrentStartTime time.Time

	LastNPMessageID string
	ShowQueue       bool
}

type PlayerAction

type PlayerAction uint
const (
	PlayerActionPlay PlayerAction = iota
	PlayerActionSkip
	PlayerActionStop
	PlayerActionKick
)

type PlayerStatus

type PlayerStatus uint
const (
	PlayerStatusPlaying PlayerStatus = iota
	PlayerStatusStopped
	PlayerStatusUninitialized
)

type PlayerUseCase

type PlayerUseCase interface {
	Create(s *discordgo.Session, vch, sch *discordgo.Channel, q *Queue) (*Player, error)
	Get(guildID string) (*Player, error)
	GetAll() []*Player
	Play(p *Player) error
	Skip(p *Player) error
	Stop(p *Player) error
	UpdateNPMessage(s *discordgo.Session, p *Player, q *Queue, queuePage int, toggleQueue, keepLast bool) error
	Kick(s *discordgo.Session, p *Player, q *Queue) error
	Count() int
	TotalPlaytime() time.Duration
}

type Queue

type Queue struct {
	GuildID      string
	ActiveTracks []*Music
	CurrentPos   int
	Loop         LoopMode

	LastQueueMessageID string
	LastPage           int

	Shuffle        ShuffleMode
	OriginalTracks []*Music
}

func (*Queue) GetPageItems added in v1.7.0

func (q *Queue) GetPageItems(page int) ([]*Music, int, error)

func (*Queue) IsEmpty added in v1.6.0

func (q *Queue) IsEmpty() bool

func (*Queue) NowPlaying

func (q *Queue) NowPlaying() *Music

func (*Queue) Proceed added in v1.6.0

func (q *Queue) Proceed() *Music

type QueueRepository

type QueueRepository interface {
	Create(guildID string) (*Queue, error)
	Get(guildID string) (*Queue, error)
	Enqueue(guildID string, music *Music) (int, error)
	Jump(guildID string, pos int) error
	Move(guildID string, from, to int) error
	Remove(guildID string, pos int) error
	SetLoopMode(guildID string, mode LoopMode) error
	SetShuffleMode(guildID string, mode ShuffleMode) error
	Clear(guildID string) error
}

type QueueUseCase

type QueueUseCase interface {
	Get(guildID string) (*Queue, error)
	Enqueue(q *Queue, music *Music, pos int) (int, error)
	Jump(q *Queue, pos int) error
	Move(q *Queue, from, to int) error
	Remove(q *Queue, pos int) error
	SetLoopMode(q *Queue, mode LoopMode) error
	SetShuffleMode(q *Queue, mode ShuffleMode) error
	Clear(q *Queue) error
}

type ShuffleMode added in v1.8.0

type ShuffleMode uint
const (
	ShuffleModeOff ShuffleMode = iota
	ShuffleModeOn
)

func (ShuffleMode) String added in v1.8.0

func (m ShuffleMode) String() string

Jump to

Keyboard shortcuts

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