inspire

package
v2.37.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &commands.YAGCommand{
	CmdCategory:         commands.CategoryFun,
	Name:                "Inspire",
	Aliases:             []string{"insp"},
	Description:         "Shows 'inspirational' quotes from inspirobot.me",
	RunInDM:             false,
	DefaultEnabled:      true,
	SlashCommandEnabled: true,
	Cooldown:            3,
	Arguments: []*dcmd.ArgDef{
		{Name: "Season", Type: dcmd.String, Default: ""},
	},
	ArgSwitches: []*dcmd.ArgDef{
		{Name: "mindfulness", Help: "Generates Mindful Quotes!"},
	},
	RunFunc: func(data *dcmd.Data) (interface{}, error) {
		available := map[string]bool{"xmas": true}
		inspireArray := []string{}
		var paginatedView bool
		season := strings.ToLower(data.Args[0].Str())
		if len(season) > 0 && !available[season] {
			return "Available seasons: `xmas`", nil
		}
		paginatedView = false
		if data.Switches["mindfulness"].Value != nil && data.Switches["mindfulness"].Value.(bool) {
			paginatedView = true
		}
		if paginatedView {
			result, err := inspireFromAPI(true, season)
			if err != nil {
				return nil, err
			}
			inspireArray = arrayMaker(inspireArray, result)
			_, err = paginatedmessages.CreatePaginatedMessage(
				data.GuildData.GS.ID, data.ChannelID, 1, 15, func(p *paginatedmessages.PaginatedMessage, page int) (*discordgo.MessageEmbed, error) {
					if page-1 == len(inspireArray) {
						result, err := inspireFromAPI(true, season)
						if err != nil {
							return nil, err
						}
						inspireArray = arrayMaker(inspireArray, result)
					}
					return createInspireEmbed(inspireArray[page-1], true), nil
				})
			if err != nil {
				return nil, err
			}
			return nil, nil
		}
		inspData, err := inspireFromAPI(false, season)
		if err != nil {
			return fmt.Sprintf("%s\nInspiroBot wonky... sad times :/", err), err
		}
		embed := createInspireEmbed(inspData, false)
		return embed, nil
	},
}

Functions

This section is empty.

Types

type MindfulnessMode added in v2.9.0

type MindfulnessMode struct {
	Data []struct {
		Duration *float64 `json:"duration,omitempty"`
		Image    *string  `json:"image,omitempty"`
		Type     *string  `json:"type"`
		Time     *float64 `json:"time"`
		Text     string   `json:"text,omitempty"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL