discord

package
v0.0.0-...-f0a4d25 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiscordBaseURL = "https://discord.com/api"

	ErrMissingRole = "You don't have the required role to use this command!"
)

Variables

View Source
var (
	Commands = map[string]Command{
		"ping": {
			Command: discordgo.ApplicationCommand{
				Name:        "ping",
				Description: "Pong!",
			},
			Handler: ping,
			Options: nil,
		},
		"pixelmon": {
			Command: discordgo.ApplicationCommand{
				Name:        "pixelmon",
				Description: "Pixelmon command",
				Options: []*discordgo.ApplicationCommandOption{
					{
						Type:        discordgo.ApplicationCommandOptionSubCommand,
						Name:        "status",
						Description: "Get the status of the Pixelmon server",
					},
					{
						Type:        discordgo.ApplicationCommandOptionSubCommand,
						Name:        "start",
						Description: "Starts the Pixelmon server",
					},
					{
						Type:        discordgo.ApplicationCommandOptionSubCommand,
						Name:        "stop",
						Description: "Stops the Pixelmon server",
					},
					{
						Type:        discordgo.ApplicationCommandOptionSubCommand,
						Name:        "say",
						Description: "Sends a message to the Pixelmon server",
						Options: []*discordgo.ApplicationCommandOption{
							{
								Type:        discordgo.ApplicationCommandOptionString,
								Name:        "message",
								Description: "Message to send to the Pixelmon server",
								Required:    true,
							},
						},
					},
					{
						Type:        discordgo.ApplicationCommandOptionSubCommand,
						Name:        "whitelist",
						Description: "Adds a user to the whitelist of the Pixelmon server",
						Options: []*discordgo.ApplicationCommandOption{
							{
								Type:        discordgo.ApplicationCommandOptionString,
								Name:        "username",
								Description: "Minecraft username to whitelist",
								Required:    true,
							},
						},
					},
				},
			},
			Handler: nil,
			Options: map[string]func(*discordgo.Interaction, ...Option) (string, error){
				"status":    status,
				"start":     start,
				"stop":      stop,
				"say":       say,
				"whitelist": whitelist,
			},
		},
		"partyfinder": {
			Command: discordgo.ApplicationCommand{
				Name:        "partyfinder",
				Description: "Party Finder command",
				Options: []*discordgo.ApplicationCommandOption{
					{
						Type:        discordgo.ApplicationCommandOptionString,
						Name:        "description",
						Description: "Description of the event",
						Required:    true,
					},
					{
						Type:        discordgo.ApplicationCommandOptionInteger,
						Name:        "size",
						Description: "Group Size",
						Required:    false,
					},
					{
						Type:        discordgo.ApplicationCommandOptionString,
						Name:        "partycomp",
						Description: "Party Composition",
						Required:    false,
					},
					{
						Type:        discordgo.ApplicationCommandOptionString,
						Name:        "date",
						Description: "Event's start date",
						Required:    false,
					},
				},
			},
			Handler: partyfinder,
			Options: nil,
		},
	}
)
View Source
var (
	ServerURL = fmt.Sprintf("%v.%v", os.Getenv("PIXELMON_SUBDOMAIN"), os.Getenv("PIXELMON_DOMAIN"))
)

Functions

func CheckRole

func CheckRole(roles []string, requiredRole string) bool

func DeferredMessage

func DeferredMessage() (discordgo.InteractionResponse, error)

func SendDeferredMessage

func SendDeferredMessage(appID string, token string, content string, opts ...Option) error

func SendDeferredMessageWithComponents

func SendDeferredMessageWithComponents(appID string, token string, content string, opts ...Option) error

Types

type Command

type Command struct {
	Command discordgo.ApplicationCommand
	Handler func(*discordgo.Interaction, ...Option) (string, error)
	Options map[string]func(*discordgo.Interaction, ...Option) (string, error)
}

type Option

type Option func(*options)

func WithActionsRow

func WithActionsRow(actionsRow *discordgo.ActionsRow) Option

func WithClient

func WithClient(client *http.Client) Option

func WithURL

func WithURL(url string) Option

Jump to

Keyboard shortcuts

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