commands

package
v0.0.0-...-3a96255 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Commands = []*discordgo.ApplicationCommand{
		{
			Name:        "cat",
			Description: "Get yo-self a cat",
		},
		{
			Name:        "dog",
			Description: "Get yo-self a dog",
		},
		{
			Name:        "scatter",
			Description: "Fly! You fools!",
		},
		{
			Name:        "moms-home",
			Description: "HIDE! MOM'S HOME!",
		},
	}
	CommandHandlers = map[string]func(session *discordgo.Session, i *discordgo.InteractionCreate){
		"cat":       catsHandler,
		"dog":       dogsHandler,
		"scatter":   scatterHandler,
		"moms-home": momsHandler,
		"followups": func(session *discordgo.Session, i *discordgo.InteractionCreate) {

			session.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
				Type: discordgo.InteractionResponseChannelMessageWithSource,
				Data: &discordgo.InteractionResponseData{

					Flags:   1 << 6,
					Content: "Surprise!",
				},
			})
			msg, err := session.FollowupMessageCreate(session.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{
				Content: "Followup message has been created, after 5 seconds it will be edited",
			})
			if err != nil {
				session.FollowupMessageCreate(session.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{
					Content: "Something went wrong",
				})
				return
			}
			time.Sleep(time.Second * 5)

			session.FollowupMessageEdit(session.State.User.ID, i.Interaction, msg.ID, &discordgo.WebhookEdit{
				Content: "Now the original message is gone and after 10 seconds this message will ~~self-destruct~~ be deleted.",
			})

			time.Sleep(time.Second * 10)

			session.FollowupMessageDelete(session.State.User.ID, i.Interaction, msg.ID)

			session.FollowupMessageCreate(session.State.User.ID, i.Interaction, true, &discordgo.WebhookParams{
				Content: "For those, who didn't skip anything and followed tutorial along fairly, " +
					"take a unicorn :unicorn: as reward!\n" +
					"Also, as bonus... look at the original interaction response :D",
			})
		},
	}
)

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

Jump to

Keyboard shortcuts

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