Documentation
¶
Index ¶
- Variables
- func ByteCountSI(b int64) string
- func CmdsKill(cmds []*exec.Cmd)
- func CmdsStart(cmds []*exec.Cmd) []error
- func CmdsWait(cmds []*exec.Cmd) []error
- func DeleteInteraction(client *bot.Client, i discord.Interaction, c <-chan struct{})
- func FilterPlaylist(link string) (string, error)
- func FindUserVoiceState(s *bot.Client, guildID, userID snowflake.ID) *discord.VoiceState
- func FolderStats(path string) (size int64, i int)
- func FormatDuration(duration float64) string
- func HasRole(roles []snowflake.ID, role snowflake.ID) bool
- func IsCommandNotAvailable(name string) bool
- func IsValidURL(toTest string) bool
- func JoinVC(e *events.ApplicationCommandInteractionCreate, channelID snowflake.ID, ...) bool
- func Stream(link string) (io.ReadCloser, []*exec.Cmd)
- func StringifyErrors(errs ...error) string
- 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(member discord.Member, owner map[snowflake.ID]struct{}) bool
- func (server *Server) IsPlaying() bool
- func (server *Server) Play(p PlayEvent)
- func (server *Server) PlayCommand(clients *Clients, e *events.ApplicationCommandInteractionCreate, 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) BotName string )
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(client *bot.Client, i discord.Interaction, c <-chan struct{})
func FilterPlaylist ¶
FilterPlaylist checks if the link is from YouTube: if yes, it removes the playlist parameter. And if it doesn't contain an ID for the video, it returns an error.
func FindUserVoiceState ¶
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
func JoinVC ¶
func JoinVC(e *events.ApplicationCommandInteractionCreate, channelID snowflake.ID, server *Server, isDeferred chan struct{}) bool
JoinVC joins the voice channel if not already joined, returns true if joined successfully
func Stream ¶
func Stream(link string) (io.ReadCloser, []*exec.Cmd)
Stream substitutes the old scripts for streaming directly to discord from a given source
func StringifyErrors ¶
StringifyErrors returns a single error string from an array of possible errors
Types ¶
type Clients ¶
type Clients struct {
Spotify *spotify.Spotify
Youtube *youtube.YouTube
Discord *bot.Client
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
Event *events.ApplicationCommandInteractionCreate
Random bool
Loop bool
Priority bool
IsDeferred chan struct{}
TextChannel snowflake.ID
}
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 snowflake.ID
// 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 snowflake.ID
// 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, e *events.ApplicationCommandInteractionCreate, playlist bool, owner map[snowflake.ID]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