commands

package
v0.0.0-...-ed20651 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const CatBaseURL = "https://api.thecatapi.com/v1/images/search?api_key=%s"

Variables

View Source
var (
	Commands = []*discordgo.ApplicationCommand{
		{
			Name:        "cat",
			Description: "Get yo-self a cat",
		},
		{
			Name:        "dog",
			Description: "Get yo-self a dog",
		},
		{
			Name:        "animal",
			Description: "Get yo-self a animal",
		},
		{
			Name:        "scatter",
			Description: "Fly! You fools!",
		},
		{
			Name:        "moms-home",
			Description: "HIDE! MOM'S HOME!",
		},
		{
			Name:        "pomodoro",
			Description: "Control pomodoro sessions",
			Options: []*discordgo.ApplicationCommandOption{
				{
					Name:        "start",
					Description: "Start Pomodoro in this Channel",
					Type:        discordgo.ApplicationCommandOptionSubCommand,
					Options: []*discordgo.ApplicationCommandOption{
						{
							Type:        discordgo.ApplicationCommandOptionInteger,
							Name:        "time-work",
							Description: "Minutes to work for",
							MinValue:    &timeMinValue,
							MaxValue:    timeMaxValue,
							Required:    true,
						},
						{
							Type:        discordgo.ApplicationCommandOptionInteger,
							Name:        "time-break",
							Description: "Minutes to break in-between",
							MinValue:    &timeMinValue,
							MaxValue:    timeMaxValue,
							Required:    true,
						},
						{
							Type:        discordgo.ApplicationCommandOptionInteger,
							Name:        "rounds",
							Description: "Number of rounds",
							MinValue:    &roundsMinValue,
							MaxValue:    roundsMaxValue,
							Required:    true,
						},
					},
				},
				{
					Name:        "end",
					Description: "End Active Pomodoro in this Channel",
					Type:        discordgo.ApplicationCommandOptionSubCommand,
				},
			},
		},
	}
	CommandHandlers = map[string]func(session *discordgo.Session, i *discordgo.InteractionCreate){
		"cat":       catsHandler,
		"dog":       dogsHandler,
		"animal":    animalsHandler,
		"scatter":   scatterHandler,
		"moms-home": momsHandler,
		"pomodoro": func(s *discordgo.Session, i *discordgo.InteractionCreate) {
			subcommand := i.ApplicationCommandData().Options[0]

			switch subcommand.Name {
			case "start":
				options := subcommand.Options

				optionMap := make(map[string]*discordgo.ApplicationCommandInteractionDataOption, len(options))
				for _, opt := range options {
					optionMap[opt.Name] = opt
				}

				pomodoro := Pomodoro{
					TimeWorkM:  optionMap["time-work"].IntValue(),
					TimeBreakM: optionMap["time-break"].IntValue(),
					Rounds:     optionMap["rounds"].IntValue(),
				}
				pomodoroStartHandler(s, i, pomodoro)
			case "end":
				pomodoroEndHandler(s, i)
			}
		},
	}
)

Functions

This section is empty.

Types

type Cat

type Cat struct {
	URL string `json:"URL"`
}

Cat is the data model for thecatapi return

type Cats

type Cats []Cat

Cats is a collection of Cat structs

type Dog

type Dog struct {
	Message string `json:"Message"`
}

Dog is the data model for dog.ceo return

type Dogs

type Dogs []Dog

Dogs is a collection of Dog structs

type Pomodoro

type Pomodoro struct {
	TimeWorkM, TimeBreakM, Rounds int64
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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