Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Audio = command.Category{ Name: "audio", Emoji: "🎵", Commands: []*command.Command{ &LyricCommand, &RadioCommand, &PlayingCommand, &StopCommand, &play.PlayCommand, &SkipCommand, &PauseCommand, &ResumeCommand, &ShuffleCommand, &VolumeCommand, }, }
View Source
var LyricCommand = command.Command{ Name: "lyric", Aliases: []string{"ly", "lyrics"}, Parameters: []*command.Parameter{ {Name: "song", Type: parameters.ParameterText, Required: false}, }, Handler: func(ctx *command.Context) command.Result { t := ctx.T.(*i18n.CommandLyric) var searchTerms string if len(ctx.Args) != 0 { searchTerms = ctx.Args[0].(string) } else { vc := voicer.GetExistingVoicerForGuild(ctx.GuildID) if vc == nil { return ctx.Error(t.NotConnected.Str()) } entry := vc.Playing() if entry == nil { return ctx.Error(t.NothingPlaying.Str()) } playable := entry.Playable title, artist := playable.GetFullTitle() searchTerms = fmt.Sprintf("%s %s", title, artist) } result, err := lyric.SearchDDG(searchTerms) if err != nil { return ctx.Error(t.NoResults.Str(searchTerms)) } return ctx.ReplyRaw(result) }, }
View Source
var PauseCommand = command.Command{ Name: "pause", Validations: []*command.Validation{validations.MustBePlaying}, Handler: func(ctx *command.Context) command.Result { t := ctx.T.(*i18n.CommandPause) vc := ctx.Locals["vc"].(*voicer.Voicer) playing := ctx.Locals["playing"].(playable.Playable) if !playing.CanPause() { return ctx.Error(t.CannotPause.Str()) } if vc.IsPaused() { return ctx.Error(t.AlreadyPaused.Str(command.Prefix)) } vc.Pause() return ctx.Successf(t.Paused.Str(command.Prefix)) }, }
View Source
var PlayingCommand = command.Command{ Name: "playing", Aliases: []string{"np"}, Deferred: true, Validations: []*command.Validation{validations.MustBePlaying}, Handler: func(ctx *command.Context) command.Result { t := ctx.T.(*i18n.CommandPlaying) vc := ctx.Locals["vc"].(*voicer.Voicer) playing := ctx.Locals["playing"].(playable.Playable) requesterID := ctx.Locals["requesterID"].(string) embed := play.BuildPlayableInfoEmbed( play.PlayableInfo{ Playable: playing, Voicer: vc, RequesterID: requesterID, T: t.PlayingInfo, Common: t.Common, }, ). WithTitle(t.Title.Str(playing.GetName())) if vc.Queue.Size() > 1 { sb := strings.Builder{} next := vc.Queue.All()[1:] limit := len(next) if len(next) > maxNextItems { limit = maxNextItems } for _, item := range next[:limit] { var etaStr string playable := item.Playable eta := play.CalcETA(playable, vc) if eta == -1 { etaStr = t.PlayingInfo.ETANever.Str() } else { etaStr = f.DurationAsDetailedDiffText(eta, t.Common) } title, artist := playable.GetFullTitle() requester := discord.AsMention(item.Requester) var fullTitle string if artist == "" { fullTitle = title } else { fullTitle = fmt.Sprintf("%s - %s", artist, title) } sb.WriteString(t.Entry.Str(fullTitle, requester, etaStr) + "\n") } if len(next) > maxNextItems { sb.WriteString(t.AndMore.Str()) } var queueDuration time.Duration for _, item := range next { duration, err := item.Playable.GetDuration() if err != nil { continue } queueDuration += duration } embed.WithField(t.ComingNext.Str(len(next), f.Pluralize(len(next), t.Song.Str(), t.Songs.Str()), f.ShortDuration(queueDuration)), sb.String()) } return ctx.SuccessEmbed(embed) }, }
View Source
var RadioCommand = command.Command{ Name: "radio", Deferred: true, Parameters: []*command.Parameter{ { Name: "radio", Required: false, Type: parameters.ParameterString, ValidValuesFunc: func() []any { ids := []any{} for _, radio := range radio.GetRadioList() { ids = append(ids, radio.GetID()) } return ids }, }, }, Handler: func(ctx *command.Context) command.Result { t := ctx.T.(*i18n.CommandRadio) if len(ctx.Args) == 0 { return listRadios(ctx, t.ListTitle.Str()) } if ok, msg := command.RunValidation(ctx, validations.MustBeOnAValidVoiceChannel); !ok { return ctx.Error(msg) } vc := ctx.Locals["vc"].(*voicer.Voicer) radioID := ctx.Args[0].(string) channel := radio.GetRadioByID(radioID) if !vc.IsConnected() { if err := vc.Connect(); err != nil { slog.Error("Cannot connect", tint.Err(err)) return ctx.Error(t.CannotConnect.Str()) } } else { ok, msg := validations.MustBeOnSameVoiceChannel.Checker(ctx) if !ok { slog.Error("Validation failed", "msg", msg) return ctx.Error(msg) } } embed := play.BuildPlayableInfoEmbed( play.PlayableInfo{ Playable: channel, RequesterID: ctx.AuthorID, T: t.PlayingInfo, Common: t.Common, }, ).WithTitle(t.AddedToQueue.Str(channel.GetName())) vc.AppendToQueue(ctx.AuthorID, channel) return ctx.SuccessEmbed(embed) }, }
View Source
var ResumeCommand = command.Command{ Name: "resume", Aliases: []string{"unpause"}, Validations: []*command.Validation{validations.MustBePlaying}, Handler: func(ctx *command.Context) command.Result { t := ctx.T.(*i18n.CommandResume) vc := ctx.Locals["vc"].(*voicer.Voicer) if !vc.IsPaused() { return ctx.Error(t.NotPaused.Str()) } vc.Resume() return ctx.Success(t.Resumed.Str()) }, }
View Source
var ShuffleCommand = command.Command{ Name: "shuffle", Aliases: []string{"sh"}, Validations: []*command.Validation{validations.MustBePlaying}, Handler: func(ctx *command.Context) command.Result { t := ctx.T.(*i18n.CommandShuffle) vc := ctx.Locals["vc"].(*voicer.Voicer) vc.Queue.Shuffle() return ctx.Success(t.Shuffled.Str(":wink:")) }, }
View Source
var SkipCommand = command.Command{ Name: "skip", Aliases: []string{"s"}, Validations: []*command.Validation{validations.MustBePlaying}, Handler: func(ctx *command.Context) command.Result { t := ctx.T.(*i18n.CommandSkip) vc := ctx.Locals["vc"].(*voicer.Voicer) vc.Skip() return ctx.Success(t.Skipped.Str()) }, }
View Source
var StopCommand = command.Command{ Name: "stop", Validations: []*command.Validation{validations.MustHaveVoicerOnGuild}, Handler: func(ctx *command.Context) command.Result { t := ctx.T.(*i18n.CommandStop) vc := ctx.Locals["vc"].(*voicer.Voicer) err := vc.Disconnect() if err != nil { slog.Error("Cannot disconnect", tint.Err(err)) return ctx.Error(t.SomethingWentWrong.Str()) } return ctx.Success(t.Stopped.Str()) }, }
View Source
var VolumeCommand = command.Command{ Name: "volume", Aliases: []string{"v", "vol"}, Validations: []*command.Validation{validations.MustBePlaying}, Handler: func(ctx *command.Context) command.Result { return ctx.ReplyRaw("https://i.imgur.com/K7v2ue7.png") }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.