bot

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: GPL-3.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(args *Arguments, usage string, loc *map[string]interface{})

Types

type Argument

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

A Argument is a argument for a command parsed from a discord message

func (*Argument) ChannelID

func (a *Argument) ChannelID() (string, bool)

ChannelID returns the argument as a channelid

func (*Argument) Int

func (a *Argument) Int() (int, bool)

Int returns the argument as an int

func (*Argument) RoleID

func (a *Argument) RoleID() (string, bool)

RoleID returns the argument as a roleid

func (*Argument) String

func (a *Argument) String() string

String returns the raw input argument

func (*Argument) UserID

func (a *Argument) UserID() (string, bool)

UserID returns the argument as an userid

type Arguments

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

Arguments contains multiple arguments

func ParseArguments

func ParseArguments(s string) *Arguments

ParseArguments splits a string into multiple arguments

func (*Arguments) First

func (a *Arguments) First() *Argument

First returns the first argument Equavalent of a.Get(0)

func (*Arguments) Get

func (a *Arguments) Get(i int) *Argument

Get returns a single argument

func (*Arguments) Last

func (a *Arguments) Last() *Argument

Last returns the last argument Equivalent of a.Get(a.Len()-1)

func (*Arguments) Len

func (a *Arguments) Len() int

Len returns the number of all arguments

func (*Arguments) Next

func (a *Arguments) Next() bool

Next returns true while arguments still contains arguments

func (*Arguments) PopFirst

func (a *Arguments) PopFirst() *Argument

PopFirst splits off the first argument from the argument list and returns it

func (*Arguments) String

func (a *Arguments) String() string

String returns all arguments as a single string

type Command

type Command struct {
	Name        string // DEPRECEATED, use the map key as name instead
	Description string
	Usage       string
	Example     string
	Permissions []string
	Execute     func(*Context) error
}

A Command is a command of a module that responds to a user calling it

type Context

type Context struct {
	Session   *discord.Session
	Event     *discord.Message
	Arguments *Arguments
}

Context contains the context for a function call

func (*Context) DeleteMessage

func (c *Context) DeleteMessage() error

DeleteMessage deletes the message that triggered the command

func (*Context) Failure

func (c *Context) Failure(msg string)

Failure sends a failure message with the given string

func (*Context) InvalidCommandUsage

func (c *Context) InvalidCommandUsage() error

InvalidCommandUsage returns an error that registers the command call to be invalid and an command help will be shown instead The return value from this function should be used as a command handler return value E.g.:

if (condition) {
	return ctx.InvalidCommandUsage()
}

func (*Context) ReplyEmbed

func (c *Context) ReplyEmbed(embed *discord.Embed) error

ReplyEmbed sends a embed in the same channel a message was received DEPRECEATED. use c.RespondEmbed instead

func (*Context) Respond

func (c *Context) Respond(msg string) (*discordgo.Message, error)

Respond responds to a event

func (*Context) RespondEmbed

func (c *Context) RespondEmbed(embed *discord.Embed) error

RespondEmbed sends a embed in the same channel a message was received

func (*Context) RunTask

func (c *Context) RunTask(fn func(*discord.Session, string) error)

RunTask manually runs executes a task for a single guild

func (*Context) Success

func (c *Context) Success(msg string)

Success sends a success message with the given string

func (*Context) Typing

func (c *Context) Typing()

Typing broadcasts the bot as typing

type Module

type Module struct {
	Name        string
	Description string
	GuildOnly   bool
	Commands    map[string]*Command
	Permissions []string
	Tasks       []*Task
	Store       *store.Store
}

A Module is a namespace for creating custom commands and bot functionalities

type Task

type Task struct {
	Name      string
	Interval  time.Duration
	AtTime    string                               // In the format: HH:MM
	AtWeekday time.Weekday                         // Optional weekday for At field
	Execute   func(*discord.Session, string) error // Include the session and the discord guild
}

Task is a background job that should be executed automatically without any user interaction

type Token

type Token struct {
	Type     TokenType
	Name     string
	Optional bool
}

type TokenType

type TokenType uint8
const (
	TokenTypeUnknown TokenType = iota
	TokenTypeString
	TokenTypeInt
)

Jump to

Keyboard shortcuts

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