integrations

package
v0.0.0-...-f00225b Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: OSL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var McBrokenCommand = &dgc.Command{
	Name:          "mcbroken",
	Domain:        "astral.integrations.mcbroken",
	Category:      "McBroken",
	Aliases:       []string{"mcbroken"},
	Description:   "Is the ice cream machine broken?",
	Slash:         true,
	SlashGuilds:   []string{os.Getenv("DEV_GUILD")},
	IntegrationID: McBrokenIntegrationID,
	Handler: func(ctx *dgc.Ctx) {
		httpClient := http.Client{}
		resp, err := httpClient.Get("https://mcbroken.com/stats.json")
		if err != nil {
			ctx.ReplyEmbed(utils.ErrorEmbed(*ctx, err))
			return
		}
		defer resp.Body.Close()
		var mcBroken McBroken

		err = json.NewDecoder(resp.Body).Decode(&mcBroken)
		if err != nil {
			ctx.ReplyEmbed(utils.ErrorEmbed(*ctx, err))
			return
		}

		var cities string
		for _, city := range mcBroken.Cities {
			cities += city.City + ": " + fmt.Sprintf("%g%%", city.Broken) + "\n"
		}

		ctx.ReplyEmbed(utils.GenerateEmbed(*ctx, discordgo.MessageEmbed{
			Title:       "McDonalds Ice Cream Machines Broken",
			Description: fmt.Sprintf("%f%% of the ice cream machines are broken.", mcBroken.Broken),
			Fields: []*discordgo.MessageEmbedField{
				{
					Name:  "Cities",
					Value: cities,
				},
			},
			Color: 0x00FF00,
		}))
	},
}
View Source
var McBrokenIntegrationID = "f98d0f70-c537-4fda-ad69-50cb0f1a3013"

Functions

This section is empty.

Types

type City

type City struct {
	City   string  `json:"city"`
	Broken float64 `json:"broken"`
}

type McBroken

type McBroken struct {
	Cities []City  `json:"cities"`
	Broken float64 `json:"broken"`
}

Jump to

Keyboard shortcuts

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