internal

package
v0.0.0-...-d5b0310 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HeaderSignature = "X-Signature-Ed25519"
	HeaderTimestamp = "X-Signature-Timestamp"
)
View Source
const (
	PermissionsDefault = 0o744
	PermissionWrite    = 0o600
)
View Source
const VERSION = "0.2.2"

VERSION follows semantic versioning.

Variables

View Source
var (
	ErrSubwayAlreadyExists = errors.New("subway already created")

	ErrInvalidRequestSignature = errors.New("invalid request signature")
	ErrInvalidPublicKey        = errors.New("invalid public key. this must be a 64 characters long and hex encoded")

	ErrReadConfigurationFailure = errors.New("failed to read configuration")
	ErrLoadConfigurationFailure = errors.New("failed to load configuration")

	ErrFetchMissingGuild     = errors.New("object requires guild ID to fetch")
	ErrFetchMissingSnowflake = errors.New("object requires snowflake to fetch")

	ErrCogAlreadyRegistered     = errors.New("cog with this name already exists")
	ErrCommandAlreadyRegistered = errors.New("command with this name already exists")
	ErrInvalidArgumentType      = errors.New("argument value is not correct type for converter used")

	ErrCommandNotFound             = errors.New("command with this name was not found")
	ErrCommandAutoCompleteNotFound = errors.New("autocomplete for command with this name was not found")
	ErrComponentListenerNotFound   = errors.New("component listener with this name was not found or has expired")

	ErrCheckFailure            = errors.New("command failed built-in checks")
	ErrMissingRequiredArgument = errors.New("command missing required arguments")
	ErrArgumentNotFound        = errors.New("command argument was not found")
	ErrConverterNotFound       = errors.New("command converter is not setup")

	ErrSnowflakeNotFound = errors.New("id does not follow a valid id or mention format")
	ErrMemberNotFound    = errors.New("member provided was not found")
	ErrUserNotFound      = errors.New("user provided was not found")
	ErrChannelNotFound   = errors.New("channel provided was not found")
	ErrGuildNotFound     = errors.New("guild provided was not found")
	ErrRoleNotFound      = errors.New("role provided was not found")
	ErrEmojiNotFound     = errors.New("emoji provided was not found")

	ErrBadInviteArgument  = errors.New("invite provided was invalid or expired")
	ErrBadColourArgument  = errors.New("colour provided was not in valid format")
	ErrBadBoolArgument    = errors.New("bool provided was not in valid format")
	ErrBadIntArgument     = errors.New("int provided was not in valid format")
	ErrBadFloatArgument   = errors.New("float provided was not in valid format")
	ErrBadWebhookArgument = errors.New("webhook url provided was not in valid format")
)
View Source
var (
	IDRegex             = regexp.MustCompile("([0-9]{15,20})$")
	GenericMentionRegex = regexp.MustCompile("<(?:@(?:!|&)?|#)([0-9]{15,20})>$")
	UserMentionRegex    = regexp.MustCompile("<@!?([0-9]{15,20})>$")
	ChannelMentionRegex = regexp.MustCompile("<#([0-9]{15,20})>")
	RoleMentionRegex    = regexp.MustCompile("<@&([0-9]{15,20})>$")
	EmojiRegex          = regexp.MustCompile("<a?:[a-zA-Z0-9_]{1,32}:([0-9]{15,20})>$")
	PartialEmojiRegex   = regexp.MustCompile("<(a?):([a-zA-Z0-9_]{1,32}):([0-9]{15,20})>$")
)
View Source
var InteractionPongResponse = []byte(`{"type":1}`)

Functions

func AddArgumentsToContext

func AddArgumentsToContext(ctx context.Context, v map[string]*Argument) context.Context

Arguments context handler.

func AddCommandBranchToContext

func AddCommandBranchToContext(ctx context.Context, v []string) context.Context

CommandBranch context handler.

func AddCommandTreeToContext

func AddCommandTreeToContext(ctx context.Context, v []string) context.Context

CommandTree context handler.

func AddComponentListenerToContext

func AddComponentListenerToContext(ctx context.Context, v *ComponentListener) context.Context

ComponentListener context handler.

func AddIdentifierToContext

func AddIdentifierToContext(ctx context.Context, v string) context.Context

Identifier context handler.

func AddInteractionCommandToContext

func AddInteractionCommandToContext(ctx context.Context, v *InteractionCommandable) context.Context

InteractionCommand context handler.

func AddRawOptionsToContext

func AddRawOptionsToContext(ctx context.Context, v map[string]*discord.InteractionDataOption) context.Context

RawOptions context handler.

func GetArgumentsFromContext

func GetArgumentsFromContext(ctx context.Context) map[string]*Argument

func GetCommandBranchFromContext

func GetCommandBranchFromContext(ctx context.Context) []string

func GetCommandTreeFromContext

func GetCommandTreeFromContext(ctx context.Context) []string

func GetIdentifierFromContext

func GetIdentifierFromContext(ctx context.Context) string

func GetRawOptionsFromContext

func GetRawOptionsFromContext(ctx context.Context) map[string]*discord.InteractionDataOption

func HandleInteractionArgumentTypeBool

func HandleInteractionArgumentTypeBool(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeBool handles converting from a string argument into a Bool type. Use .Bool() within a command to get the proper type.

func HandleInteractionArgumentTypeColour

func HandleInteractionArgumentTypeColour(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeColour handles converting from a string argument into a Colour type. Use .Colour() within a command to get the proper type.

func HandleInteractionArgumentTypeEmoji

func HandleInteractionArgumentTypeEmoji(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeEmoji handles converting from a string argument into a Emoji type. Use .Emoji() within a command to get the proper type.

func HandleInteractionArgumentTypeFloat

func HandleInteractionArgumentTypeFloat(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeFloat handles converting from a string argument into a Float type. Use .Float64() within a command to get the proper type.

func HandleInteractionArgumentTypeGuild

func HandleInteractionArgumentTypeGuild(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeGuild handles converting from a string argument into a Guild type. Use .Guild() within a command to get the proper type.

func HandleInteractionArgumentTypeGuildChannel

func HandleInteractionArgumentTypeGuildChannel(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeGuildChannel handles converting from a string argument into a TextChannel type. Use .Channel() within a command to get the proper type.

func HandleInteractionArgumentTypeInt

func HandleInteractionArgumentTypeInt(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeInt handles converting from a string argument into a Int type. Use .Int64() within a command to get the proper type.

func HandleInteractionArgumentTypeMember

func HandleInteractionArgumentTypeMember(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeMember handles converting from a string argument into a Member type. Use .Member() within a command to get the proper type.

func HandleInteractionArgumentTypePartialEmoji

func HandleInteractionArgumentTypePartialEmoji(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypePartialEmoji handles converting from a string argument into a Emoji type. Use .Emoji() within a command to get the proper type.

func HandleInteractionArgumentTypeRole

func HandleInteractionArgumentTypeRole(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeRole handles converting from a string argument into a Role type. Use .Role() within a command to get the proper type.

func HandleInteractionArgumentTypeSnowflake

func HandleInteractionArgumentTypeSnowflake(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeSnowflake handles converting from a string argument into a Snowflake type. Use .Snowflake() within a command to get the proper type.

func HandleInteractionArgumentTypeString

func HandleInteractionArgumentTypeString(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeString handles converting from a string argument into a String type. Use .String() within a command to get the proper type.

func HandleInteractionArgumentTypeUser

func HandleInteractionArgumentTypeUser(ctx context.Context, sub *Subway, interaction discord.Interaction, option *discord.InteractionDataOption) (out interface{}, err error)

HandleInteractionArgumentTypeUser handles converting from a string argument into a User type. Use .User() within a command to get the proper type.

Types

type Argument

type Argument struct {
	ArgumentType ArgumentType
	// contains filtered or unexported fields
}

func GetArgument

func GetArgument(ctx context.Context, name string) (*Argument, error)

GetArgument returns an argument based on its name.

func MustGetArgument

func MustGetArgument(ctx context.Context, name string) *Argument

MustGetArgument returns an argument based on its name. Panics on error.

func (*Argument) Bool

func (a *Argument) Bool() (bool, error)

Bool returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Channel

func (a *Argument) Channel() (*discord.Channel, error)

Channel returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Colour

func (a *Argument) Colour() (*color.RGBA, error)

Colour returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Emoji

func (a *Argument) Emoji() (*discord.Emoji, error)

Emoji returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Float

func (a *Argument) Float() (float64, error)

Float returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Guild

func (a *Argument) Guild() (*discord.Guild, error)

Guild returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Int

func (a *Argument) Int() (int64, error)

Int returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Member

func (a *Argument) Member() (*discord.GuildMember, error)

Member returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) MustBool

func (a *Argument) MustBool() bool

MustBool will attempt to do Bool() and will panic if not possible.

func (*Argument) MustChannel

func (a *Argument) MustChannel() *discord.Channel

MustTextChannel will attempt to do Channel() and will panic if not possible.

func (*Argument) MustColour

func (a *Argument) MustColour() *color.RGBA

MustColour will attempt to do Colour() and will panic if not possible.

func (*Argument) MustEmoji

func (a *Argument) MustEmoji() *discord.Emoji

MustEmoji will attempt to do Emoji() and will panic if not possible.

func (*Argument) MustFloat

func (a *Argument) MustFloat() float64

MustFloat will attempt to do Float() and will panic if not possible.

func (*Argument) MustGuild

func (a *Argument) MustGuild() *discord.Guild

MustGuild will attempt to do Guild() and will panic if not possible.

func (*Argument) MustInt

func (a *Argument) MustInt() int64

MustInt will attempt to do Int() and will panic if not possible.

func (*Argument) MustMember

func (a *Argument) MustMember() *discord.GuildMember

MustMember will attempt to do Member() and will panic if not possible.

func (*Argument) MustRole

func (a *Argument) MustRole() *discord.Role

MustRole will attempt to do Role() and will panic if not possible.

func (*Argument) MustSnowflake

func (a *Argument) MustSnowflake() *discord.Snowflake

MustSnowflake will attempt to do Snowflake() and will panic if not possible.

func (*Argument) MustString

func (a *Argument) MustString() string

MustString will attempt to do String() and will panic if not possible.

func (*Argument) MustStrings

func (a *Argument) MustStrings() []string

MustStrings will attempt to do Strings() and will panic if not possible.

func (*Argument) MustUser

func (a *Argument) MustUser() *discord.User

MustUser will attempt to do User() and will panic if not possible.

func (*Argument) Role

func (a *Argument) Role() (*discord.Role, error)

Role returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Snowflake

func (a *Argument) Snowflake() (*discord.Snowflake, error)

Snowflake returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) String

func (a *Argument) String() (string, error)

String returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) Strings

func (a *Argument) Strings() ([]string, error)

Strings returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

func (*Argument) User

func (a *Argument) User() (*discord.User, error)

User returns an argument as the specified Type. If the argument is not the right type for the converter that made the argument, ErrInvalidArgumentType will be returned.

type ArgumentParameter

type ArgumentParameter struct {
	Required                 bool
	ArgumentType             ArgumentType
	Name                     string
	Description              string
	NameLocalizations        map[string]string
	DescriptionLocalizations map[string]string
	Choices                  []*discord.ApplicationCommandOptionChoice

	ChannelTypes []discord.ChannelType
	MinValue     *int32
	MaxValue     *int32
	MinLength    *int32
	MaxLength    *int32
	Autocomplete *bool
}

type ArgumentType

type ArgumentType uint16
const (
	ArgumentTypeSnowflake ArgumentType = iota + 1
	ArgumentTypeMember
	ArgumentTypeUser

	ArgumentTypeTextChannel
	ArgumentTypeGuild
	ArgumentTypeRole
	ArgumentTypeColour
	ArgumentTypeVoiceChannel
	ArgumentTypeStageChannel
	ArgumentTypeEmoji
	ArgumentTypePartialEmoji
	ArgumentTypeCategoryChannel
	ArgumentTypeStoreChannel
	ArgumentTypeThread
	ArgumentTypeGuildChannel

	ArgumentTypeString
	ArgumentTypeBool
	ArgumentTypeInt
	ArgumentTypeFloat
	ArgumentTypeStrings
)

type Cog

type Cog interface {
	CogInfo() *CogInfo
	RegisterCog(sub *Subway) error
}

Cog is the basic interface for any cog. This must provide information about the cog such as its name and description.

type CogInfo

type CogInfo struct {
	Name        string
	Description string

	Meta interface{}
}

type CogWithBotLoad

type CogWithBotLoad interface {
	BotLoad(sub *Subway)
}

CogWithBotLoad is an interface for any cog that implements methods that run when a bot loads.

type CogWithBotUnload

type CogWithBotUnload interface {
	BotUnload(sub *Subway, wg *sync.WaitGroup)
}

CogWithBotUnload is an interface for any cog that implements methods that run when a bot unloads.

type CogWithInteractionCommands

type CogWithInteractionCommands interface {
	GetInteractionCommandable() *InteractionCommandable
}

CogWithInteractionCommands is an interface for any cog that implements methods that return interaction commands.

type ComponentListener

type ComponentListener struct {
	Channel            chan *discord.Interaction
	InitialInteraction discord.Interaction
	Handler            InteractionHandler
	// contains filtered or unexported fields
}

func GetComponentListenerFromContext

func GetComponentListenerFromContext(ctx context.Context) *ComponentListener

func (*ComponentListener) Cancel

func (listener *ComponentListener) Cancel()

Cancel stops listening for a component and closes the channel, if one is present.

type InteractionArgumentConverterType

type InteractionArgumentConverterType func(ctx context.Context, sub *Subway, interaction discord.Interaction, argument *discord.InteractionDataOption) (out interface{}, err error)

type InteractionAutocompleteHandler

type InteractionAutocompleteHandler func(ctx context.Context, sub *Subway, interaction discord.Interaction) ([]*discord.ApplicationCommandOptionChoice, error)

type InteractionCheckFuncType

type InteractionCheckFuncType func(ctx context.Context, sub *Subway, interaction discord.Interaction) (canRun bool, err error)

Func Type used for command checks.

type InteractionCommandable

type InteractionCommandable struct {
	Name        string
	Description string

	NameLocalizations        map[string]string
	DescriptionLocalizations map[string]string

	Type        InteractionCommandableType
	CommandType *discord.ApplicationCommandType

	Checks            []InteractionCheckFuncType
	ArgumentParameter []ArgumentParameter

	Handler      InteractionHandler
	ErrorHandler InteractionErrorHandler

	DefaultMemberPermission *discord.Int64
	DMPermission            *bool

	AutocompleteHandler InteractionAutocompleteHandler
	// contains filtered or unexported fields
}

func GetInteractionCommandFromContext

func GetInteractionCommandFromContext(ctx context.Context) *InteractionCommandable

func NewSubcommandGroup

func NewSubcommandGroup(name string, description string) *InteractionCommandable

Accelerator to create a subcommand group.

func SetupInteractionCommandable

func SetupInteractionCommandable(commandable *InteractionCommandable) *InteractionCommandable

SetupInteractionCommandable ensures all nullable variables are properly constructed.

func (*InteractionCommandable) AddInteractionCommand

func (ic *InteractionCommandable) AddInteractionCommand(interactionCommandable *InteractionCommandable) (icc *InteractionCommandable, err error)

func (*InteractionCommandable) CanRun

func (ic *InteractionCommandable) CanRun(ctx context.Context, sub *Subway, interaction discord.Interaction) (bool, error)

CanRun checks interactionCommandable checks and returns if the interaction passes them all. If an error occurs, the message will be treated as not being able to run.

func (*InteractionCommandable) GetAllCommands

func (ic *InteractionCommandable) GetAllCommands() []*InteractionCommandable

GetAllCommands returns all commands.

func (*InteractionCommandable) GetCommand

func (*InteractionCommandable) Invoke

Invoke handles the execution of a command or a group.

func (*InteractionCommandable) IsGroup

func (ic *InteractionCommandable) IsGroup() bool

IsGroup returns true if the command contains other commands.

func (*InteractionCommandable) MapApplicationCommands

func (ic *InteractionCommandable) MapApplicationCommands() []*discord.ApplicationCommand

func (*InteractionCommandable) MapApplicationOptions

func (ic *InteractionCommandable) MapApplicationOptions() (applicationOptions []*discord.ApplicationCommandOption)

func (*InteractionCommandable) MustAddInteractionCommand

func (ic *InteractionCommandable) MustAddInteractionCommand(interactionCommandable *InteractionCommandable) (icc *InteractionCommandable)

func (*InteractionCommandable) RecursivelyRemoveAllCommands

func (ic *InteractionCommandable) RecursivelyRemoveAllCommands()

func (*InteractionCommandable) RemoveCommand

func (ic *InteractionCommandable) RemoveCommand(name string) *InteractionCommandable

type InteractionCommandableType

type InteractionCommandableType uint8
const (
	InteractionCommandableTypeCommand InteractionCommandableType = iota
	InteractionCommandableTypeSubcommandGroup
	InteractionCommandableTypeSubcommand
)

type InteractionConverter

type InteractionConverter struct {
	// contains filtered or unexported fields
}

type InteractionConverters

type InteractionConverters struct {
	Converters map[ArgumentType]*InteractionConverter
	// contains filtered or unexported fields
}

func NewInteractionConverters

func NewInteractionConverters() *InteractionConverters

func (*InteractionConverters) GetConverter

func (co *InteractionConverters) GetConverter(converterType ArgumentType) *InteractionConverter

GetConverter returns a converter based on the converterType passed.

func (*InteractionConverters) RegisterConverter

func (co *InteractionConverters) RegisterConverter(converterName ArgumentType, converter InteractionArgumentConverterType, defaultValue interface{})

RegisterConverter adds a new converter. If there is already a converter registered with its name, it will be overridden.

type InteractionErrorHandler

type InteractionErrorHandler func(ctx context.Context, sub *Subway, interaction discord.Interaction, err error) (*discord.InteractionResponse, error)

type InteractionHandler

type InteractionHandler func(ctx context.Context, sub *Subway, interaction discord.Interaction) (*discord.InteractionResponse, error)

type InteractionRequestHandler

type InteractionRequestHandler func(ctx context.Context, sub *Subway, interaction discord.Interaction) error

type InteractionResponseHandler

type InteractionResponseHandler func(ctx context.Context, sub *Subway, interaction discord.Interaction, resp *discord.InteractionResponse, err error) error

type PanicError

type PanicError struct {
	Recover interface{}
}

func (PanicError) Error

func (cp PanicError) Error() string

type Subway

type Subway struct {
	context.Context

	Logger    zerolog.Logger `json:"-"`
	StartTime time.Time      `json:"start_time" yaml:"start_time"`

	Commands   *InteractionCommandable `json:"-"`
	Converters *InteractionConverters  `json:"-"`

	Cogs map[string]Cog `json:"-"`

	SandwichClient protobuf.SandwichClient `json:"-"`
	GRPCInterface  sandwich.GRPC           `json:"-"`
	RESTInterface  discord.RESTInterface   `json:"-"`
	EmptySession   *discord.Session        `json:"-"`

	ComponentListenersMu sync.RWMutex
	ComponentListeners   map[string]*ComponentListener

	OnBeforeInteraction InteractionRequestHandler
	OnAfterInteraction  InteractionResponseHandler
	// contains filtered or unexported fields
}

func NewSubway

func NewSubway(ctx context.Context, options SubwayOptions) (*Subway, error)

func (*Subway) CanRun

func (sub *Subway) CanRun(ctx context.Context, interaction discord.Interaction) (bool, error)

CanRun checks all global bot checks and returns if the message passes them all. If an error occurs, the message will be treated as not being able to run.

func (*Subway) HandleComponent

func (sub *Subway) HandleComponent(interaction discord.Interaction, customID string, timeout time.Duration, handler InteractionHandler) *ComponentListener

WaitForComponent allows you to wait for a specific component interaction. You can either use a callback function which is automatically handled or use a channel.

func (*Subway) HandleSubwayRequest

func (sub *Subway) HandleSubwayRequest(w http.ResponseWriter, r *http.Request)

func (*Subway) InteractionCleanupJob

func (sub *Subway) InteractionCleanupJob(ctx context.Context, maximumAge time.Duration)

func (*Subway) ListenAndServe

func (sub *Subway) ListenAndServe(route, host string) error

Listen handles starting up the webserver and services for you.

func (*Subway) MustRegisterCog

func (sub *Subway) MustRegisterCog(cog Cog)

func (*Subway) NewGRPCContext

func (sub *Subway) NewGRPCContext(ctx context.Context) *sandwich.GRPCContext

func (*Subway) ProcessApplicationCommandInteraction

func (sub *Subway) ProcessApplicationCommandInteraction(ctx context.Context, interaction discord.Interaction) (*discord.InteractionResponse, error)

ProcessApplicationCommandInteraction processes the application command that has been received.

func (*Subway) ProcessMessageComponentInteraction

func (sub *Subway) ProcessMessageComponentInteraction(ctx context.Context, interaction discord.Interaction) (*discord.InteractionResponse, error)

ProcessMessageComponentInteraction processes the message component that has been received.

func (*Subway) RegisterCog

func (sub *Subway) RegisterCog(cog Cog) error

func (*Subway) RegisterCogInteractionCommandable

func (sub *Subway) RegisterCogInteractionCommandable(cog Cog, interactionCommandable *InteractionCommandable)

func (*Subway) SetupPrometheus

func (sub *Subway) SetupPrometheus() error

SetupPrometheus sets up prometheus.

func (*Subway) SyncCommands

func (sub *Subway) SyncCommands(ctx context.Context, token string, applicationID discord.Snowflake) error

SyncCommands syncs all registered commands with the discord API. Use sandwichClient.FetchIdentifier to get the token for an identifier. Token must have "Bot " added.

type SubwayContextKey

type SubwayContextKey int
const (
	SubwayKey SubwayContextKey = iota
	InteractionKey
	InteractionCommandKey
	ArgumentsKey
	RawOptionsKey
	CommandBranchKey
	CommandTreeKey
	IdentifierKey
	ComponentListenerKey
)

type SubwayOptions

type SubwayOptions struct {
	SandwichClient protobuf.SandwichClient
	RESTInterface  discord.RESTInterface
	Logger         zerolog.Logger

	OnBeforeInteraction InteractionRequestHandler
	OnAfterInteraction  InteractionResponseHandler

	PublicKey         string
	PrometheusAddress string

	// Maximum age for component listeners. Defaults to 15 minutes.
	// This is the absolute maximum age of a component listener,
	// ignoring a listener with a longer age.
	MaximumInteractionAge time.Duration
}

SubwayOptions represents the options to create a new subway service.

Jump to

Keyboard shortcuts

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