discord

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptionTypeString = iota << 1
	OptionTypeNumber
	OptionTypeBoolean
)

Variables

View Source
var (
	ErrNotInVoiceChannel = fmt.Errorf("user is not in a voice channel")
)

Functions

func PlayAction

func PlayAction(ctx *Context, conn *Conn) (string, error)

func QueueAction

func QueueAction(ctx *Context, conn *Conn) (string, error)

func QueuedAction

func QueuedAction(ctx *Context, conn *Conn) (string, error)

func RecentAction

func RecentAction(ctx *Context, conn *Conn) (string, error)

func SkipAction

func SkipAction(ctx *Context, conn *Conn) (string, error)

func StopAction

func StopAction(ctx *Context, conn *Conn) (string, error)

func SuggestAction

func SuggestAction(ctx *Context, conn *Conn) (string, error)

func SuggestionsAction

func SuggestionsAction(ctx *Context, conn *Conn) (string, error)

Types

type Command

type Command struct {
	Name        string
	Description string
	Options     []Option
	// Action is the function to invoke whenever the command is invoked.
	// The action returns the response as a string, or an error if an unexpected
	// failure occurs.
	Action func(*Context, *Conn) (string, error)
	// EnabledFunc returns true if the command is enabled.
	// A nil EnabledFunc implicitly enables the command.
	EnabledFunc func(*state.State, *bot.Bot) bool
}

Command exposes functionality as a Discord command.

type Conn

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

Conn is a Discord bot connection.

func Dial

func Dial(state *state.State, bot *bot.Bot) (*Conn, error)

Dial connects to Discord. Returns the open connection or an error if connecting fails.

func (*Conn) Bot

func (c *Conn) Bot() *bot.Bot

Bot returns the Bot this connection is for.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection.

func (*Conn) Play

func (c *Conn) Play(guildID string, voiceChannelID string)

Play starts playing in the specified channel.

func (*Conn) Ready

func (c *Conn) Ready() bool

Ready returns whether or not the

func (*Conn) State

func (c *Conn) State() *state.State

State returns the global state.

type Context

type Context struct {
	context.Context
	// contains filtered or unexported fields
}

Context holds the context of a command invocation.

func (*Context) Boolean

func (c *Context) Boolean(key string) (bool, bool)

Boolean returns a boolean parameter by key.

func (*Context) Entity

func (c *Context) Entity() state.Entity

Entity returns the entity that invoked the command.

func (*Context) Number

func (c *Context) Number(key string) (float64, bool)

Number returns a number parameter by key.

func (*Context) String

func (c *Context) String(key string) (string, bool)

String returns a string parameter by key.

func (*Context) VoiceChannel

func (c *Context) VoiceChannel() (string, string, error)

VoiceChannel returns the guild id and voice channel id of the voice channel the requesting user is currently in. Returns ErrNotInVoiceChannel if the user is not in a voice channel.

type Option

type Option struct {
	Name        string
	Description string
	// Type defaults to string.
	Type     OptionType
	Required bool
	// EnabledFunc returns true if the option is enabled.
	// A nil EnabledFunc implicitly enables the option.
	EnableFunc func(*state.State, *bot.Bot) bool
}

Option defines an option to a command.

type OptionType

type OptionType int

Jump to

Keyboard shortcuts

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