Documentation
¶
Index ¶
- Variables
- func ByteCountSI(b int64) string
- func CmdsKill(cmds []*exec.Cmd)
- func CmdsStart(cmds []*exec.Cmd)
- func CmdsWait(cmds []*exec.Cmd)
- func DeleteInteraction(s *discordgo.Session, i *discordgo.Interaction, c <-chan struct{})
- func FindUserVoiceState(s *discordgo.Session, guildID, userID string) *discordgo.VoiceState
- func FolderStats(path string) (size int64, i int)
- func FormatDuration(duration float64) string
- func HasRole(roles []string, role string) bool
- func IsCommandNotAvailable(name string) bool
- func IsValidURL(toTest string) bool
- func JoinVC(i *discordgo.Interaction, channelID string, s *discordgo.Session, ...) bool
- func Stream(link string) (io.ReadCloser, []*exec.Cmd)
- type Clients
- type PlayEvent
- type PlayStatus
- type RequestedFormats
- type Server
- func (server *Server) AddSong(priority bool, el ...queue.Element)
- func (server *Server) Clean()
- func (server *Server) DjModeCheck(s *discordgo.Session, i *discordgo.InteractionCreate, ...) bool
- func (server *Server) IsPlaying() bool
- func (server *Server) Play(p PlayEvent)
- func (server *Server) PlayCommand(clients *Clients, i *discordgo.InteractionCreate, playlist bool, ...) (status PlayStatus)
- func (server *Server) QuitVC()
- type SkipReason
- type YtDLP
Constants ¶
This section is empty.
Variables ¶
var (
Notifications = make(chan notification.NotificationMessage, 1)
)
Functions ¶
func ByteCountSI ¶
ByteCountSI formats bytes into a readable format
func CmdsWait ¶
CmdsWait waits for all the exec.Cmd inside the slice to finish processing, to free up resources
func DeleteInteraction ¶
func DeleteInteraction(s *discordgo.Session, i *discordgo.Interaction, c <-chan struct{})
func FindUserVoiceState ¶
func FindUserVoiceState(s *discordgo.Session, guildID, userID string) *discordgo.VoiceState
FindUserVoiceState finds user current voice channel
func FolderStats ¶
FolderStats gets the size of a directory and the number of files in it
func FormatDuration ¶
FormatDuration Formats a string given its duration in seconds
func IsCommandNotAvailable ¶
IsCommandNotAvailable isCommandNotAvailable checks whatever a command is available
Types ¶
type Clients ¶
type Clients struct {
Spotify *spotify.Spotify
Youtube *youtube.YouTube
Discord *discordgo.Session
Database *database.Database
}
Clients holds all the clients used for interacting with the various APIs
type PlayEvent ¶
type PlayEvent struct {
Username string
Song string
Clients *Clients
Interaction *discordgo.Interaction
Random bool
Loop bool
Priority bool
IsDeferred chan struct{}
}
PlayEvent is the struct for playing songs
type RequestedFormats ¶
type RequestedFormats []struct {
Resolution string `json:"resolution"`
}
RequestedFormats is used to detect if an audio only codec is available
type Server ¶
type Server struct {
// The queue
Queue queue.Queue
// Voice connection
VC *vc.VC
// Custom commands, maps a command to a song
Custom map[string]*database.CustomCommand
// Frames
Frames atomic.Uint64
// Quit channel
Skip chan SkipReason
// Whether the job scheduler has started
Started atomic.Bool
// Whether to clear the queue
Clear atomic.Bool
// Guild ID
GuildID string
// Whether the bot is paused
Paused atomic.Bool
// Channel for pausing
Pause chan struct{}
// Channel for resuming
Resume chan struct{}
// Wait group for waiting for spotify to finish before lowering the clear flag
WG *sync.WaitGroup
// Role ID for the DJ role
DjRole string
// Whether the DJ mode is enabled
DjMode bool
// Clients used for interacting with the various APIs
Clients *Clients
// Timer used for quitting the voice channel
ChanQuitVC chan bool
}
Server holds all info about a single server
func (*Server) DjModeCheck ¶
func (*Server) PlayCommand ¶
func (server *Server) PlayCommand(clients *Clients, i *discordgo.InteractionCreate, playlist bool, owner map[string]struct{}) (status PlayStatus)
type SkipReason ¶
type SkipReason uint8
SkipReason is used to determine why playSound returned
const ( Error SkipReason = iota Finished Skip Clear )
type YtDLP ¶
type YtDLP struct {
Duration float64 `json:"duration"`
Thumbnail string `json:"thumbnail"`
Extractor string `json:"extractor"`
ID string `json:"id"`
WebpageURL string `json:"webpage_url"`
Title string `json:"title"`
RequestedFormats RequestedFormats `json:"requested_formats"`
}
YtDLP structure for holding yt-dlp data