Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &commands.YAGCommand{ CmdCategory: commands.CategoryFun, Name: "HowLongToBeat", Aliases: []string{"hltb"}, RequiredArgs: 1, Description: "Game information based on query from howlongtobeat.com.\nResults are sorted by popularity, it's their default. Without -p returns the first result.\nSwitch -p gives paginated output using the Jaro-Winkler similarity metric sorting max 20 results.", DefaultEnabled: true, SlashCommandEnabled: true, Arguments: []*dcmd.ArgDef{ {Name: "Game-Title", Type: dcmd.String}, }, ArgSwitches: []*dcmd.ArgDef{ {Name: "c", Help: "Compact output"}, {Name: "p", Help: "Paginated output"}, }, RunFunc: func(data *dcmd.Data) (interface{}, error) { var compactView, paginatedView bool gameName := data.Args[0].Str() if data.Switches["c"].Value != nil && data.Switches["c"].Value.(bool) { compactView = true } if data.Switches["p"].Value != nil && data.Switches["p"].Value.(bool) { compactView = false paginatedView = true } games, err := getGameData(gameName) if err != nil { return nil, err } if len(games) == 0 { return "No results", nil } games = parseGameData(gameName, games) if compactView { compactData := fmt.Sprintf("%s: %s | %s | %s | <%s>", normaliseTitle(games[0].GameTitle), games[0].MainStoryTimeHours, games[0].MainStoryExtraTimeHours, games[0].CompletionistTimeHours, games[0].GameURL, ) return compactData, nil } hltbEmbed := embedCreator(games, 0, paginatedView) if paginatedView { return paginatedmessages.NewPaginatedResponse( data.GuildData.GS.ID, data.ChannelID, 1, len(games), func(p *paginatedmessages.PaginatedMessage, page int) (*discordgo.MessageEmbed, error) { i := page - 1 sort.SliceStable(games, func(i, j int) bool { return games[i].JaroWinklerSimilarity > games[j].JaroWinklerSimilarity }) paginatedEmbed := embedCreator(games, i, paginatedView) return paginatedEmbed, nil }), nil } return hltbEmbed, nil }, }
Command var needs a comment for lint :)
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.