mtn_go_discord_framework

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	EphemeralFlag = 64
)

Variables

View Source
var (
	ErrInvalidOptionType     = errors.New("invalid option type")
	ErrMissingRequiredOption = errors.New("missing required option")
)

declare errors

Functions

func BusySleep

func BusySleep()

busySleep pauses execution for up to 10 seconds if the system is busy

func CheckForRoles

func CheckForRoles(s *discordgo.Session, i *discordgo.InteractionCreate, roles ...string) bool

checkForRoles checks if a member has one of the provided roles

func InitFramework

func InitFramework(debugMode bool, testingGuildId string, botToken string) *discordgo.Session

Initializes the framework and returns a discord session, needed for the other functions

func RegisterButtonHandlerWithFramework

func RegisterButtonHandlerWithFramework(handler ButtonHandler)

Registers a button handler with the framework

func RegisterButtonHandlersWithFramework added in v0.1.3

func RegisterButtonHandlersWithFramework(handlers []ButtonHandler)

Registers multiple button handlers with the framework

func RegisterSlashCommandWithFramework

func RegisterSlashCommandWithFramework(command SlashCommand)

Registers a slash command with the framework

func RegisterSlashCommandsWithFramework added in v0.1.3

func RegisterSlashCommandsWithFramework(commands []SlashCommand)

Registers multiple slash commands with the framework

func ReleaseSystem

func ReleaseSystem()

Set systemBusy to false. Should be deferred after a successful tryAcquireSystem.

func SendDeferResponse

func SendDeferResponse(s *discordgo.Session, i *discordgo.InteractionCreate)

sendDeferResponse sends a deferred response to an interaction

func SendEphemeralEmbed added in v0.1.4

func SendEphemeralEmbed(s *discordgo.Session, i *discordgo.InteractionCreate, embed *discordgo.MessageEmbed)

func SendEphemeralResponse

func SendEphemeralResponse(s *discordgo.Session, i *discordgo.InteractionCreate, msg string)

sendEphemeralResponse sends a response to an interaction that only the user can see

func ShutdownFramework

func ShutdownFramework()

Shuts down the framework and closes the discord session

func StartFramework

func StartFramework()

Launches the framework and registers all commands and handlers

func TryAcquireSystem

func TryAcquireSystem() bool

Check if the system is busy. If not, set it to busy and return true. If it is busy, return false.

Types

type BooleanOption added in v0.1.6

type BooleanOption struct {
	Value bool
	Name  string
}

func (BooleanOption) GetName added in v0.1.6

func (s BooleanOption) GetName() string

func (BooleanOption) GetValue added in v0.1.6

func (s BooleanOption) GetValue() interface{}

type ButtonHandler

type ButtonHandler struct {
	CustomID string
	Handler  func(s *discordgo.Session, i *discordgo.InteractionCreate, args ...string)
}

type ChannelOption added in v0.1.6

type ChannelOption struct {
	Value *discordgo.Channel
	Name  string
}

func (ChannelOption) GetName added in v0.1.6

func (s ChannelOption) GetName() string

func (ChannelOption) GetValue added in v0.1.6

func (s ChannelOption) GetValue() interface{}

type CommandOption added in v0.1.6

type CommandOption interface {
	GetValue() interface{}
	GetName() string
}

type FloatOption added in v0.1.6

type FloatOption struct {
	Value float64
	Name  string
}

func (FloatOption) GetName added in v0.1.6

func (s FloatOption) GetName() string

func (FloatOption) GetValue added in v0.1.6

func (s FloatOption) GetValue() interface{}

type IntegerOption added in v0.1.6

type IntegerOption struct {
	Value int64
	Name  string
}

func (IntegerOption) GetName added in v0.1.6

func (s IntegerOption) GetName() string

func (IntegerOption) GetValue added in v0.1.6

func (s IntegerOption) GetValue() interface{}

type OptionContainer added in v0.1.6

type OptionContainer struct {
	Options map[string]CommandOption
}

type OptionRequirement added in v0.1.6

type OptionRequirement struct {
	Required    bool
	Name        string
	Description string
	Type        discordgo.ApplicationCommandOptionType
}

type RoleOption added in v0.1.6

type RoleOption struct {
	Value *discordgo.Role
	Name  string
}

func (RoleOption) GetName added in v0.1.6

func (s RoleOption) GetName() string

func (RoleOption) GetValue added in v0.1.6

func (s RoleOption) GetValue() interface{}

type SlashCommand added in v0.1.4

type SlashCommand struct {
	Name            string
	Description     string
	Handler         func(s *discordgo.Session, i *discordgo.InteractionCreate, options *OptionContainer)
	RequiredOptions []OptionRequirement
	// contains filtered or unexported fields
}

type StringOption added in v0.1.6

type StringOption struct {
	Value string
	Name  string
}

func (StringOption) GetName added in v0.1.6

func (s StringOption) GetName() string

func (StringOption) GetValue added in v0.1.6

func (s StringOption) GetValue() interface{}

type UnsignedIntergerOption added in v0.1.6

type UnsignedIntergerOption struct {
	Value uint64
	Name  string
}

func (UnsignedIntergerOption) GetName added in v0.1.6

func (s UnsignedIntergerOption) GetName() string

func (UnsignedIntergerOption) GetValue added in v0.1.6

func (s UnsignedIntergerOption) GetValue() interface{}

type UserOption added in v0.1.6

type UserOption struct {
	Value *discordgo.User
	Name  string
}

func (UserOption) GetName added in v0.1.6

func (s UserOption) GetName() string

func (UserOption) GetValue added in v0.1.6

func (s UserOption) GetValue() interface{}

Jump to

Keyboard shortcuts

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