scp

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2021 License: MIT Imports: 3 Imported by: 0

README

scp

Slash/Application Command router for discord.go

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegexArguments      = regexp.MustCompile("(\"[^\"]+\"|[^\\s]+)")
	RegexUserMention    = regexp.MustCompile("<@!?(\\d+)>")
	RegexRoleMention    = regexp.MustCompile("<@&(\\d+)>")
	RegexChannelMention = regexp.MustCompile("<#(\\d+)>")
	RegexSnowflakeID    = regexp.MustCompile("[\\d]{18}")
)

Functions

This section is empty.

Types

type ApplicationCommandOption

type ApplicationCommandOption struct {
	Type        discordgo.ApplicationCommandOptionType `json:"type"`
	Name        string                                 `json:"name"`
	Description string                                 `json:"description,omitempty"`
	// NOTE: This feature was on the API, but at some point developers decided to remove it.
	// So I commented it, until it will be officially on the docs.
	// Default     bool                              `json:"default"`
	Required bool                                        `json:"required"`
	Choices  []*discordgo.ApplicationCommandOptionChoice `json:"choices"`
	Options  []*ApplicationCommandOption                 `json:"options"`
	Handler  func(*Ctx)
}

type Category

type Category struct {
	Name         string
	ID           string
	Description  string
	HelpEmoji    string
	Commands     []*Command
	RegisterCmds func(c *Category)
}

func (*Category) AddCommand

func (c *Category) AddCommand(cmd *Command)

func (*Category) GetCommand

func (c *Category) GetCommand(name string) *Command

type Command

type Command struct {
	ID            string
	ApplicationID string
	Type          discordgo.ApplicationCommandType
	Name          string
	Description   string
	Version       string
	Options       []*ApplicationCommandOption
	Handler       func(*Ctx)
}

func (*Command) ToApplicationCommand

func (c *Command) ToApplicationCommand() *discordgo.ApplicationCommand

type Ctx

type Ctx struct {
	Options     []*discordgo.ApplicationCommandInteractionDataOption
	Session     *discordgo.Session
	Interaction *discordgo.InteractionCreate
	Router      *Router
	Guild       *discordgo.Guild
	Channel     *discordgo.Channel
	User        *discordgo.User
}

func (*Ctx) EditResponse

func (ctx *Ctx) EditResponse(newrsp *discordgo.WebhookEdit)

func (*Ctx) Respond

func (*Ctx) StrToID

func (ctx *Ctx) StrToID(str string, itype IDType) string

func (*Ctx) WaitForResponse

func (ctx *Ctx) WaitForResponse() *discordgo.MessageCreate

type IDType

type IDType int
const (
	UserMentionID IDType = iota
	RoleMentionID
	ChannelMentionID
)

type Router

type Router struct {
	Cateories     []*Category
	Uncategorized []*Command
	AllCommands   []*Command
	Session       *discordgo.Session
}

func Create

func Create(s *discordgo.Session) *Router

func (*Router) AddCategory

func (r *Router) AddCategory(c *Category)

func (*Router) AddCommand

func (r *Router) AddCommand(c *Command)

func (*Router) GetCategory

func (r *Router) GetCategory(name string) *Category

func (*Router) GetCommand

func (r *Router) GetCommand(name string) *Command

func (*Router) RegisterAllCommands

func (r *Router) RegisterAllCommands(guildID string)

Jump to

Keyboard shortcuts

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