discordgo_command_wrapper

package module
v0.0.0-...-1dd82db Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

README

discordgo-command-wrapper

Command-Wrapper for https://github.com/bwmarrin/discordgo

Documentation

Index

Constants

View Source
const NoPermissionNeeded = -1

Variables

This section is empty.

Functions

func ContainsString

func ContainsString(slice []string, key string, ignoreCase bool) bool

func DefaultAccess

func DefaultAccess() func(ctx *Context) bool

func DefaultMemberPermission

func DefaultMemberPermission() func(ctx *Context, member *discordgo.Member) bool

func DefaultUserPermission

func DefaultUserPermission() func(ctx *Context, user *discordgo.User) bool

func DeregisterCommand

func DeregisterCommand(primaryKey string)

func DeregisterCommands

func DeregisterCommands(primaryKeys ...string)

func EqualsString

func EqualsString(string1, string2 string, ignoreCase bool) bool

func HandleCommandAction

func HandleCommandAction(session *discordgo.Session, compose *ComposedCommandAction)

func IsCommandMessage

func IsCommandMessage(session *discordgo.Session, content string) bool

func IsGuild

func IsGuild(channel *discordgo.Channel) bool

func KeepAlive

func KeepAlive()

func ListenToMessageCreate

func ListenToMessageCreate(session *discordgo.Session)

func ListenToMessageUpdate

func ListenToMessageUpdate(session *discordgo.Session)

func ReceiveCommandCreateMessage

func ReceiveCommandCreateMessage(session *discordgo.Session, event *discordgo.MessageCreate) error

func ReceiveCommandUpdateMessage

func ReceiveCommandUpdateMessage(session *discordgo.Session, event *discordgo.MessageUpdate) error

func RegisterCommand

func RegisterCommand(command Command)

func RegisterCommands

func RegisterCommands(commands ...Command)

func UseConfiguration

func UseConfiguration(configuration *Configuration)

Types

type Command

type Command interface {
	GetPrimaryKey() string
	GetConfiguration() *CommandConfiguration

	IsNamed(name string, ignoreCase bool) bool
	IsAccessibleBy(ctx *Context, user *discordgo.User) bool
	IsValidChannel(ctx *Context, channel *discordgo.Channel) bool
	IsUserPermitted(ctx *Context, user *discordgo.User) bool
	IsMemberPermitted(ctx *Context, member *discordgo.Member) bool

	Run(ctx *Context) error
}

func FindCommand

func FindCommand(primaryKey string, ignoreCase bool) (*Command, error)

func FindCommands

func FindCommands(key string, ignoreCase bool) []*Command

type CommandConfiguration

type CommandConfiguration struct {
	Category string `json:"category"`
	Usage    string `json:"usage"`
}

type CommandHandler

type CommandHandler struct {
	NotPermitted        func(ctx *Context, user *discordgo.User)
	InvalidChannel      func(ctx *Context, channel *discordgo.Channel)
	NotAccessible       func(ctx *Context, user *discordgo.User)
	NoMatches           func(ctx *Context)
	NoPrefixGenerations func(compose *ComposedCommandAction)
	PrefixNotFound      func(compose *ComposedCommandAction)
	Usage               func(cmd Command, ctx *Context, err error)
	UnknownError        func(compose *ComposedCommandAction, err error)
}

type ComposedCommandAction

type ComposedCommandAction struct {
	Session       *discordgo.Session
	MessageCreate *discordgo.MessageCreate
	MessageUpdate *discordgo.MessageUpdate

	Message          *discordgo.Message
	Content          string
	Member           *discordgo.Member
	GuildID          string
	Reactions        []*discordgo.MessageReactions
	Tts              bool
	ChannelID        string
	Application      *discordgo.MessageApplication
	Activity         *discordgo.MessageActivity
	EditedTimestamp  discordgo.Timestamp
	Timestamp        discordgo.Timestamp
	Embeds           []*discordgo.MessageEmbed
	MessageReference *discordgo.MessageReference
	Attachments      []*discordgo.MessageAttachment
	Author           *discordgo.User
	MessageType      discordgo.MessageType
	WebhookID        string
	Mentions         []*discordgo.User
	MentionChannels  []*discordgo.Channel
	MentionRoles     []string
}

func ComposeMessageCreate

func ComposeMessageCreate(session *discordgo.Session, create *discordgo.MessageCreate) *ComposedCommandAction

func ComposeMessageUpdate

func ComposeMessageUpdate(session *discordgo.Session, update *discordgo.MessageUpdate) *ComposedCommandAction

func (ComposedCommandAction) IsCreate

func (event ComposedCommandAction) IsCreate() bool

func (ComposedCommandAction) IsUpdate

func (event ComposedCommandAction) IsUpdate() bool

type Configuration

type Configuration struct {
	PrefixGenerator func(channel *discordgo.Channel) []string
	CommandHandler  CommandHandler
}

type Context

type Context struct {
	Label   string                 `json:"label"`
	Args    []string               `json:"args"`
	Cut     string                 `json:"cut"`
	Channel *discordgo.Channel     `json:"channel"`
	Session *discordgo.Session     `json:"session"`
	Compose *ComposedCommandAction `json:"compose"`
}

type SimpleCommand

type SimpleCommand struct {
	Command
	Keys            []string                                            `json:"keys"`
	Configuration   *CommandConfiguration                               `json:"configuration"`
	Access          func(ctx *Context) bool                             `json:"access"`
	ValidChannel    func(ctx *Context, channel *discordgo.Channel) bool `json:"valid_channel"`
	UserPermitted   func(ctx *Context, user *discordgo.User) bool       `json:"user_permitted"`
	MemberPermitted func(ctx *Context, member *discordgo.Member) bool   `json:"member_permitted"`
	Action          func(ctx *Context) error                            `json:"action"`
}

func (SimpleCommand) GetConfiguration

func (cmd SimpleCommand) GetConfiguration() *CommandConfiguration

func (SimpleCommand) GetPrimaryKey

func (cmd SimpleCommand) GetPrimaryKey() string

func (SimpleCommand) IsAccessibleBy

func (cmd SimpleCommand) IsAccessibleBy(ctx *Context, user *discordgo.User) bool

func (SimpleCommand) IsMemberPermitted

func (cmd SimpleCommand) IsMemberPermitted(ctx *Context, member *discordgo.Member) bool

func (SimpleCommand) IsNamed

func (cmd SimpleCommand) IsNamed(key string, ignoreCase bool) bool

func (SimpleCommand) IsUserPermitted

func (cmd SimpleCommand) IsUserPermitted(ctx *Context, user *discordgo.User) bool

func (SimpleCommand) IsValidChannel

func (cmd SimpleCommand) IsValidChannel(ctx *Context, channel *discordgo.Channel) bool

func (SimpleCommand) Run

func (cmd SimpleCommand) Run(ctx *Context) error

Jump to

Keyboard shortcuts

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