framework

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasPermission

func HasPermission(s *discordgo.Session, userID string, channelID string, reqPerm int64) (bool, error)

func ParseArgs

func ParseArgs(s string) []string

Types

type Command

type Command struct {
	Name               string
	PermissionRequired int64
	OwnerOnly          bool
	Help               string
	Exec               func(ctx *Context) error
	Setup              func() error
}

type Context

type Context struct {
	Hanamaru *Hanamaru
	Command  *Command
	*discordgo.MessageCreate
	Args []string
}

func NewContext

func NewContext(h *Hanamaru, cmd *Command, m *discordgo.MessageCreate) *Context

func (*Context) GetArgIndex

func (c *Context) GetArgIndex(idx int) (string, error)

func (*Context) GetArgIndexDefault

func (c *Context) GetArgIndexDefault(idx int, def string) string

func (*Context) GetImage

func (c *Context) GetImage(idx uint) (image.Image, error)

func (*Context) GetMember

func (c *Context) GetMember(idx int) (*discordgo.Member, error)

func (*Context) GetPreviousMessage

func (c *Context) GetPreviousMessage() (*discordgo.Message, error)

func (*Context) GetSenderVoiceChannel

func (c *Context) GetSenderVoiceChannel() (*discordgo.Channel, error)

func (*Context) GetUser

func (c *Context) GetUser(idx int) (*discordgo.User, error)

func (*Context) Reply

func (c *Context) Reply(m string) (*discordgo.Message, error)

func (*Context) ReplyEmbed

func (c *Context) ReplyEmbed(embed *discordgo.MessageEmbed) (*discordgo.Message, error)

func (*Context) ReplyFile

func (c *Context) ReplyFile(name string, r io.Reader) (*discordgo.Message, error)

func (*Context) ReplyGIFImg

func (c *Context) ReplyGIFImg(img *gif.GIF, name string) (*discordgo.Message, error)

func (*Context) ReplyJPGImg

func (c *Context) ReplyJPGImg(img image.Image, name string) (*discordgo.Message, error)

This is name without extension btw, the following function will add it by itself

func (*Context) ReplyPNGImg

func (c *Context) ReplyPNGImg(img image.Image, name string) (*discordgo.Message, error)

ReplyPNGImg Sends img into the chat where the command is executed. Name excludes the extension

func (*Context) TakeRest

func (c *Context) TakeRest() string

type ErrAddCommand

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

func (ErrAddCommand) Error

func (e ErrAddCommand) Error() string

type EventListener

type EventListener struct {
	// Name of the event listener.
	Name string
	// HandlerConstructor is a function that depends on a Hanamaru pointer and must return an event listener
	HandlerConstructor func(h *Hanamaru) interface{}
}

type Hanamaru

type Hanamaru struct {
	Prefix string

	*discordgo.Session
	VoiceContext   *voice.Context
	Commands       []*Command
	EventListeners []*EventListener
	Db             *sql.DB
	// contains filtered or unexported fields
}

func New

func New(token, prefix, ownerid string) (bot *Hanamaru)

func (*Hanamaru) AddCommand

func (h *Hanamaru) AddCommand(cmd *Command) error

func (*Hanamaru) AddEventListener

func (h *Hanamaru) AddEventListener(listener *EventListener) error

AddEventListener adds and event listener to the bot.

func (*Hanamaru) AddEventListenerOnce

func (h *Hanamaru) AddEventListenerOnce(listener *EventListener) error

func (*Hanamaru) Close

func (h *Hanamaru) Close()

func (*Hanamaru) EnableHelpCommand

func (h *Hanamaru) EnableHelpCommand()

func (*Hanamaru) SetupDB

func (h *Hanamaru) SetupDB() (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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