discom

package module
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2023 License: MIT Imports: 8 Imported by: 3

README

discom

A basic command handler for discordgo refer to the main/main.go

What is this?

This is just a bare bones lib to make it easier to add commands and update the help command for a discord bot, It also means you don't need to remember to add the handler.

How to use this?

Refer to example/main.go or my chessbot

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTooManyArgs = fmt.Errorf("more args given then options")
	ErrInvalidArg  = fmt.Errorf("invalid arg")
)

Functions

func ApplicationCommandOptionToString added in v1.3.0

func ApplicationCommandOptionToString(option discordgo.ApplicationCommandOptionType) string

Types

type Command

type Command struct {
	// Name the name of the command commands should not have spaces
	Name string
	// Handler The handler function which is called on a message matching the regex
	Handler     CommandHandler
	Description string
	Version     string
	Options     []*discordgo.ApplicationCommandOption
}

Command Represents a Command to the discord bot.

type CommandHandler

type CommandHandler func(*discordgo.Session, Interaction) error

CommandHandler A callback function which is triggered when a command is ran Error should only return data your fine with the user seeing

type CommandSet

type CommandSet struct {
	Prefix       string
	ErrorHandler ErrorHandler
	// contains filtered or unexported fields
}

CommandSet Use this to regsiter commands and get the handler to pass to discordgo. This should be created with CreateCommandSet.

func CreateCommandSet

func CreateCommandSet(prefix string, errorHandler ErrorHandler) (*CommandSet, error)

CreateCommandSet Creates a command set

func (*CommandSet) AddCommand

func (cs *CommandSet) AddCommand(com Command) error

AddCommand Use this to add a command to a command set

func (*CommandSet) Handler

func (cs *CommandSet) Handler(s *discordgo.Session, m *discordgo.MessageCreate)

Handler Register this with discordgo.AddHandler will be called every time a new message is sent on a guild.

func (*CommandSet) IntreactionHandler added in v1.3.0

func (cs *CommandSet) IntreactionHandler(s *discordgo.Session, i *discordgo.InteractionCreate)

func (*CommandSet) SyncAppCommands added in v1.3.0

func (cs *CommandSet) SyncAppCommands(s *discordgo.Session) error

type ErrorHandler added in v1.1.4

type ErrorHandler func(*discordgo.Session, Interaction, error)

ErrorHandler called if a command handler returns an error

type Interaction added in v1.3.0

type Interaction interface {
	Respond(*discordgo.Session, Response) error
	GetPayload() *InteractionPayload
	Option(name string) *discordgo.ApplicationCommandInteractionDataOption
}

Interaction any interfaction with the commands

type InteractionPayload added in v1.3.1

type InteractionPayload struct {
	Message   string
	AuthorId  string
	GuildId   string
	ChannelId string
}

type Response added in v1.3.0

type Response struct {
	Content string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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