discom

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: MIT Imports: 5 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

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	//Re the regex pattern when a message matches it will call the Handler func
	Re *regexp.Regexp
	//CaseInsensitive will to lower the incomming message before checking if it matches
	CaseInsensitive bool
	//Handler The handler function which is called on a message matching the regex
	Handler     CommandHandler
	Description string
	Example     string
}

Command Represents a Command to the discord bot.

type CommandHandler

type CommandHandler func(*discordgo.Session, *discordgo.MessageCreate)

CommandHandler A callback function which is triggered when a command is ran

type CommandSet

type CommandSet struct {
	PrefixRe *regexp.Regexp
	// 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(prefixRe *regexp.Regexp) *CommandSet

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 Regsiter this with discordgo.AddHandler will be called every time a new message is sent on a guild.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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