commander

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: MIT Imports: 6 Imported by: 0

README

Commander


A lightweight command handler for discordgo

Information


The Commander is a lightweight command handler build for discordgo. You can use it to control the command execution of your commands. It is easy to setup and use. Test it out yourself!

Documentation

Install the library with:

go get -t github.com/MathisBurger/commander

Example:

// Init command handler
handler := commander.New(";;", "826378911444500501")

// add command to handler
handler.Register("example", "Example command", ExampleCommand, 100)

// add handler to discord session
session.AddHandler(handler.Execute)

Note: The permission system is not working in v0.0.1

Examples


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Command     string
	Description string
	Executor    func(s *discordgo.Session, m *discordgo.MessageCreate)
	Permission  int
}

The command struct it defines the data to register a command

type Commander

type Commander struct {
	Prefix         string
	CommandChannel string
	Commands       map[string]Command
}

/////////////////////////////////////////////////////////// Main command handler struct. The whole library // is based on it. It takes all required params // needed to execute a command and handle it // ///////////////////////////////////////////////////////////

func New

func New(prefix string, cmdChannel string) *Commander

creates a new instance of the command handler returns the instance which can be used for registration and execution

func (*Commander) Execute

func (c *Commander) Execute(s *discordgo.Session, m *discordgo.MessageCreate)

executes a command with given parameters and sends not found, if the command was not found

func (*Commander) Register

func (c *Commander) Register(
	command string,
	description string,
	executor func(s *discordgo.Session, m *discordgo.MessageCreate),
	permission int,
)

register a new command

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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