Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &commands.YAGCommand{ CmdCategory: commands.CategoryFun, Name: "Define", Aliases: []string{"df", "define", "urban", "urbandictionary"}, Description: "Look up an urban dictionary definition, default paginated view.", RequiredArgs: 1, SlashCommandEnabled: false, Arguments: []*dcmd.ArgDef{ {Name: "Topic", Type: dcmd.String}, }, ArgSwitches: []*dcmd.ArgDef{ {Name: "raw", Help: "Raw output"}, }, RunFunc: func(data *dcmd.Data) (interface{}, error) { var paginatedView bool paginatedView = true if data.Switches["raw"].Value != nil && data.Switches["raw"].Value.(bool) { paginatedView = false } qResp, err := urbandictionary.Query(data.Args[0].Str()) if err != nil { return "Failed querying :(", err } if len(qResp.Results) < 1 { return "No result :(", nil } if paginatedView { return paginatedmessages.NewPaginatedResponse(data.GuildData.GS.ID, data.ChannelID, 1, len(qResp.Results), func(p *paginatedmessages.PaginatedMessage, page int) (*discordgo.MessageEmbed, error) { i := page - 1 paginatedEmbed := embedCreator(qResp.Results, i) return paginatedEmbed, nil }), nil } result := qResp.Results[0] cmdResp := fmt.Sprintf("**%s**: %s\n*%s*\n*(<%s>)*", result.Word, result.Definition, result.Example, result.Permalink) if len(qResp.Results) > 1 { cmdResp += fmt.Sprintf(" *%d more results*", len(qResp.Results)-1) } return cmdResp, nil }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.