criuscommander

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: BSD-3-Clause Imports: 6 Imported by: 0

README

Crius Commander

It handles some discord stuff - mostly commands and also reactions. It'll get updates as I need them for projects.

This means it'll be fairly stable for you to link against for CfDX plugins

It comes with one (1) built-in command - help.

For now, it doesn't support subcommands, but I'm seriously considering it for sometime in the near future for Secret Hitler Bot

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArgsSplitter

func ArgsSplitter(in string) []string

Types

type CCConfig added in v1.1.0

type CCConfig struct {
	Prefix              string
	Token               string
	URL                 *string
	HelpEmbedFooterText *string
	HelpEmbedColour     *int
}

type Command added in v1.1.0

type Command struct {
	Handler CommandHandler
	Help    string
}

type CommandGroup

type CommandGroup interface {
	OnReaction(*discordgo.Session, interface{}) error
	OnGuildJoin(*discordgo.Session, *discordgo.GuildCreate) error
	OnGuildLeave(*discordgo.Session, *discordgo.GuildDelete) error
	OnBotClose() error
}

type CommandGroupContainer added in v1.1.0

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

type CommandHandler

type CommandHandler func(*MessageContext, []string) error

type Commander

type Commander struct {
	OnError func(error)
	// contains filtered or unexported fields
}

func NewCommander

func NewCommander(config *CCConfig) (*Commander, error)

Make a new instance of a commander, which will contain a connection to discord.

func (*Commander) Close

func (c *Commander) Close()

Stop the commander & discord

func (*Commander) GetPlugin

func (c *Commander) GetPlugin(name string) (interface{}, error)

func (*Commander) HandleError

func (c *Commander) HandleError(f func(error))

func (*Commander) Help

func (c *Commander) Help(m *MessageContext, args []string) error

func (*Commander) LoadPlugin

func (c *Commander) LoadPlugin(name string) error

Attempt to load a .so plugin from the disk and set it up

func (*Commander) Open added in v1.1.0

func (c *Commander) Open() error

func (*Commander) RegisterCommand

func (c *Commander) RegisterCommand(groupName string) func(activator string, handler CommandHandler, help string) error

func (*Commander) SetupPlugin

func (c *Commander) SetupPlugin(setup func(RegisterCommand, GetPlugin, *discordgo.Session) (CommandGroup, string), name string)

Register the plugin into the list of 'groups' (read: plugins)

type GetPlugin

type GetPlugin func(string) (interface{}, error)

type MessageContext

type MessageContext struct {
	*discordgo.MessageCreate
	// contains filtered or unexported fields
}

func (*MessageContext) React

func (c *MessageContext) React(add bool, channelID string, messageID string, emoji string) error

func (*MessageContext) Send

func (c *MessageContext) Send(data interface{}) (*discordgo.Message, error)

func (*MessageContext) SendTo

func (c *MessageContext) SendTo(channelID string, data interface{}) (*discordgo.Message, error)

type RegisterCommand

type RegisterCommand func(string, CommandHandler, string) error

Jump to

Keyboard shortcuts

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