gommand

package module
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2020 License: GPL-2.0 Imports: 14 Imported by: 2

README

gommand

Want to write your first bot? Start here.

Welcome to Gommand! Gommand has a lot of built in functionality to allow for a higher level commands experience:

  • Custom prefix support: Gommand allows you to easily set a custom prefix. Gommand has various helper functions for this such as static prefix and mention support.

  • Command alias support: Out ot the box, gommand features support for command aliases. This allows for the ability to easily write commands that have several wordings. This is very useful for bots where you have command names which are changing during migration.

  • Custom commands support: Gommand allows you to easily set a handler for custom commands if this is something which you require for your bot.

  • Custom argument support: Out of the box, gommand features many different argument converters for functionality such as integers and users. Should you need it, gommand also allows for the creation of custom converters through a very simple function.

  • Argument formatting: Gommand supports required, optional, remainder and greedy processors for commands along with many different argument transformers.

  • Middleware support: Need to run something before a bunch of commands which requires repeating yourself? No problem! Gommand supports middleware on both a global (through the router object) and local (through the command object) scale. Simply add the function and it will be executed. There is also a map within the context called MiddlewareParams in which middleware can very easily store data for the commands to run.

  • Permission validators support: If you need to validate permissions, you can simply use permission validators. If false is returned, a IncorrectPermissions will be sent to the error handlers with the string specified.

  • Ease of use: We pride this library on ease of use. The idea is to build a higher level wrapper around handling commands using disgord, and whilst doing this we add in helper functions. Additionally, we patch the member object into messages, meaning that you do not need to get this, solving potential code repetition.

  • Advanced error handling: Gommand features an advanced error handling system. The error is passed through all inserted error handlers in the order which the handlers were inserted. If a handler is able to solve an issue, it will simply return true and gommand will stop iterating through the list. If no handlers return true, it will be passed through to the disgord logger which you set.

  • Battle tested: The Gommand library is heavily unit tested. Feel free to submit a pull request if you feel there is something important which we are not testing, we will accept it. Find a bug? Feel free to file an issue and we will fix it.

Contributing

Do you have something which you wish to contribute? Feel free to make a pull request. The following simple criteria applies:

  • Is it useful to everyone?: If this is a domain specific edit, you probably want to keep this as middleware since it will not be accepted into the main project.
  • Does it slow down parsing by >1ms?: This will likely be denied. We want to keep parsing as high performance as possible.
  • Have you ran go generate, gofmt -w . and golangci-lint?: We like to stick to using Go standards within this project, therefore if this is not done you may be asked to do this for it to be acccepted.

Have you experienced a bug? If so, please make an issue! We take bugs seriously and this will be a large priority for us.

Documentation

Overview

Package gommand is a package with a lot of built in functionality to allow for a higher level commands experience. Read README.md to read the getting started documentation:

- Custom prefix support: Gommand allows you to easily set a custom prefix. Gommand has various helper functions for this such as static prefix and mention support.

- Command alias support: Out ot the box, gommand features support for command aliases. This allows for the ability to easily write commands that have several wordings. This is very useful for bots where you have command names which are changing during migration.

- Custom commands support: Gommand allows you to easily set a handler for custom commands if this is something which you require for your bot.

- Custom argument support: Out of the box, gommand features many different argument converters for functionality such as integers and users. Should you need it, gommand also allows for the creation of custom converters through a very simple function.

- Argument formatting: Gommand supports required, optional, remainder and greedy processors for commands along with many different argument transformers.

- Middleware support: Need to run something before a bunch of commands which requires repeating yourself? No problem! Gommand supports middleware on both a global (through the router object) and local (through the command object) scale. Simply add the function and it will be executed. There is also a map within the context called `MiddlewareParams` in which middleware can very easily store data for the commands to run.

- Permission validators support: If you need to validate permissions, you can simply use permission validators. If false is returned, a `IncorrectPermissions` will be sent to the error handlers with the string specified.

- Ease of use: We pride this library on ease of use. The idea is to build a higher level wrapper around handling commands using disgord, and whilst doing this we add in helper functions. Additionally, we patch the member object into messages, meaning that you do not need to get this, solving potential code repetition.

- Advanced error handling: Gommand features an advanced error handling system. The error is passed through all inserted error handlers in the order which the handlers were inserted. If a handler is able to solve an issue, it will simply return true and gommand will stop iterating through the list. If no handlers return true, it will be passed through to the disgord logger which you set.

- Battle tested: The Gommand library is heavily unit tested. Feel free to submit a pull request if you feel there is something important which we are not testing, we will accept it. Find a bug? Feel free to file an issue and we will fix it.

Code generated by gommand. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

View Source
var ADD_REACTIONS = permissionsWrapper("Add Reactions", 0x00000040)

ADD_REACTIONS is a wrapper for the Discord permission.

View Source
var ADMINISTRATOR = permissionsWrapper("Administrator", 0x00000008)

ADMINISTRATOR is a wrapper for the Discord permission.

View Source
var ATTACH_FILES = permissionsWrapper("Attach Files", 0x00008000)

ATTACH_FILES is a wrapper for the Discord permission.

View Source
var BAN_MEMBERS = permissionsWrapper("Ban Members", 0x00000004)

BAN_MEMBERS is a wrapper for the Discord permission.

View Source
var CHANGE_NICKNAME = permissionsWrapper("Change Nickname", 0x04000000)

CHANGE_NICKNAME is a wrapper for the Discord permission.

View Source
var CONNECT = permissionsWrapper("Connect", 0x00100000)

CONNECT is a wrapper for the Discord permission.

View Source
var CREATE_INSTANT_INVITE = permissionsWrapper("Create Instant Invite", 0x00000001)

CREATE_INSTANT_INVITE is a wrapper for the Discord permission.

View Source
var DEAFEN_MEMBERS = permissionsWrapper("Deafen Members", 0x00800000)

DEAFEN_MEMBERS is a wrapper for the Discord permission.

View Source
var EMBED_LINKS = permissionsWrapper("Embed Links", 0x00004000)

EMBED_LINKS is a wrapper for the Discord permission.

View Source
var KICK_MEMBERS = permissionsWrapper("Kick Members", 0x00000002)

KICK_MEMBERS is a wrapper for the Discord permission.

View Source
var MANAGE_CHANNELS = permissionsWrapper("Manage Channels", 0x00000010)

MANAGE_CHANNELS is a wrapper for the Discord permission.

View Source
var MANAGE_EMOJIS = permissionsWrapper("Manage Emojis", 0x40000000)

MANAGE_EMOJIS is a wrapper for the Discord permission.

View Source
var MANAGE_GUILD = permissionsWrapper("Manage Guild", 0x00000020)

MANAGE_GUILD is a wrapper for the Discord permission.

View Source
var MANAGE_MESSAGES = permissionsWrapper("Manage Messages", 0x00002000)

MANAGE_MESSAGES is a wrapper for the Discord permission.

View Source
var MANAGE_NICKNAMES = permissionsWrapper("Manage Nicknames", 0x08000000)

MANAGE_NICKNAMES is a wrapper for the Discord permission.

View Source
var MANAGE_ROLES = permissionsWrapper("Manage Roles", 0x10000000)

MANAGE_ROLES is a wrapper for the Discord permission.

View Source
var MANAGE_WEBHOOKS = permissionsWrapper("Manage Webhooks", 0x20000000)

MANAGE_WEBHOOKS is a wrapper for the Discord permission.

View Source
var MENTION_EVERYONE = permissionsWrapper("Mention Everyone", 0x00020000)

MENTION_EVERYONE is a wrapper for the Discord permission.

View Source
var MOVE_MEMBERS = permissionsWrapper("Move Members", 0x01000000)

MOVE_MEMBERS is a wrapper for the Discord permission.

View Source
var MUTE_MEMBERS = permissionsWrapper("Mute Members", 0x00400000)

MUTE_MEMBERS is a wrapper for the Discord permission.

View Source
var PRIORITY_SPEAKER = permissionsWrapper("Priority Speaker", 0x00000100)

PRIORITY_SPEAKER is a wrapper for the Discord permission.

View Source
var READ_MESSAGE_HISTORY = permissionsWrapper("Read Message History", 0x00010000)

READ_MESSAGE_HISTORY is a wrapper for the Discord permission.

View Source
var SEND_MESSAGES = permissionsWrapper("Send Messages", 0x00000800)

SEND_MESSAGES is a wrapper for the Discord permission.

View Source
var SEND_TTS_MESSAGES = permissionsWrapper("Send TTS Messages", 0x00001000)

SEND_TTS_MESSAGES is a wrapper for the Discord permission.

View Source
var SPEAK = permissionsWrapper("Speak", 0x00200000)

SPEAK is a wrapper for the Discord permission.

View Source
var STREAM = permissionsWrapper("Stream", 0x00000200)

STREAM is a wrapper for the Discord permission.

View Source
var USE_EXTERNAL_EMOJIS = permissionsWrapper("Use External Emojis", 0x00040000)

USE_EXTERNAL_EMOJIS is a wrapper for the Discord permission.

View Source
var USE_VAD = permissionsWrapper("Use Vad", 0x02000000)

USE_VAD is a wrapper for the Discord permission.

View Source
var VIEW_AUDIT_LOG = permissionsWrapper("View Audit Log", 0x00000080)

VIEW_AUDIT_LOG is a wrapper for the Discord permission.

View Source
var VIEW_CHANNEL = permissionsWrapper("View Channel", 0x00000400)

VIEW_CHANNEL is a wrapper for the Discord permission.

Functions

func AnyTransformer

func AnyTransformer(Transformers ...func(ctx *Context, Arg string) (interface{}, error)) func(ctx *Context, Arg string) (item interface{}, err error)

AnyTransformer takes multiple transformers and tries to find one which works.

func BooleanTransformer

func BooleanTransformer(_ *Context, Arg string) (interface{}, error)

BooleanTransformer is used to transform an argument into a boolean if possible.

func ChannelTransformer

func ChannelTransformer(ctx *Context, Arg string) (channel interface{}, err error)

ChannelTransformer is used to transform a channel if possible.

func CommandHasPermission

func CommandHasPermission(ctx *Context, c CommandInterface) error

CommandHasPermission is used to run through the permission validators and check if the user has permission. The error will be of the IncorrectPermissions type if they do not have permission.

func DurationTransformer

func DurationTransformer(_ *Context, Arg string) (duration interface{}, err error)

DurationTransformer is used to transform a duration if possible.

func EmbedsPaginator

func EmbedsPaginator(ctx *Context, Pages []*disgord.Embed, InitialPage uint, NoButtonTextContent string) error

EmbedsPaginator is used to paginate together several embeds.

func EmbedsPaginatorWithLifetime added in v1.11.0

func EmbedsPaginatorWithLifetime(ctx *Context, Pages []*disgord.Embed, InitialPage uint, NoButtonTextContent string, Lifetime *EmbedLifetimeOptions) (err error)

EmbedsPaginatorWithLifetime is used to paginate together several embeds, but with an optional *EmbedLifetimeOptions parameter to control the embed lifetime. Passing nil to this parameter indicates no maximum lifetime.

func GuildTransformer added in v1.11.0

func GuildTransformer(ctx *Context, Arg string) (guild interface{}, err error)

GuildTransformer is used to transform a guild if possible.

func IntTransformer

func IntTransformer(_ *Context, Arg string) (interface{}, error)

IntTransformer is used to transform an arg to a integer if possible.

func MemberTransformer

func MemberTransformer(ctx *Context, Arg string) (member interface{}, err error)

MemberTransformer is used to transform a member if possible.

func MentionPrefix

func MentionPrefix(ctx *Context, r io.ReadSeeker) bool

MentionPrefix is used to handle a mention which is being used as a prefix.

func MessageURLTransformer

func MessageURLTransformer(ctx *Context, Arg string) (message interface{}, err error)

MessageURLTransformer is used to transform a message URL to a message if possible.

func MultiplePrefixCheckers

func MultiplePrefixCheckers(Handlers ...PrefixCheck) func(ctx *Context, r io.ReadSeeker) bool

MultiplePrefixCheckers is used to handle multiple prefix checkers.

func RoleTransformer

func RoleTransformer(ctx *Context, Arg string) (role interface{}, err error)

RoleTransformer is used to transform a role if possible.

func StaticPrefix

func StaticPrefix(Prefix string) func(_ *Context, r io.ReadSeeker) bool

StaticPrefix is used for simple static prefixes.

func StringTransformer

func StringTransformer(_ *Context, Arg string) (interface{}, error)

StringTransformer just takes the argument and returns it.

func UIntTransformer

func UIntTransformer(_ *Context, Arg string) (interface{}, error)

UIntTransformer is used to transform an arg to a unsigned integer if possible.

func UserTransformer

func UserTransformer(ctx *Context, Arg string) (user interface{}, err error)

UserTransformer is used to transform a user if possible.

Types

type ArgTransformer

type ArgTransformer struct {
	// Greedy defines if the parser should keep going until an argument fails.
	Greedy bool

	// Optional defines if the argument is optional. This can be mixed with greedy or remainder.
	// This has to be either at the end of the argument list or followed by other optional arguments (if you don't combine with Remainder).
	Optional bool

	// Remainder defines if it should just parse the rest of the arguments.
	// Remainders need to be at the end of a command.
	Remainder bool

	// Function is used to transform the argument. The function should error if this is not possible.
	Function func(ctx *Context, Arg string) (interface{}, error)

	// Default is the value the arg will have if it isn't supplied by the user.
	// This will not be used in case of an error from the transformer function, only when no argument is passed by the user.
	// Similarly to optional, this either has to be one of the end arguments (or followed by other default arguments only).
	Default interface{}
}

ArgTransformer defines a transformer which is to be used on arguments.

type Category

type Category struct {
	Name                 string                `json:"name"`
	Description          string                `json:"description"`
	Cooldown             Cooldown              `json:"cooldown"`
	PermissionValidators []PermissionValidator `json:"-"`
	Middleware           []Middleware          `json:"-"`
}

Category is the generic category struct which uses the category interface.

func (*Category) GetCooldown added in v1.8.0

func (c *Category) GetCooldown() Cooldown

GetCooldown is used to get the cooldown from the category.

func (*Category) GetDescription

func (c *Category) GetDescription() string

GetDescription is used to get the description of the category.

func (*Category) GetMiddleware

func (c *Category) GetMiddleware() []Middleware

GetMiddleware is used to get the middleware of the category.

func (*Category) GetName

func (c *Category) GetName() string

GetName is used to get the name of the category.

func (*Category) GetPermissionValidators

func (c *Category) GetPermissionValidators() []PermissionValidator

GetPermissionValidators is used to get the permission validators of the category.

type CategoryInterface

type CategoryInterface interface {
	GetName() string
	GetDescription() string
	GetPermissionValidators() []func(ctx *Context) (string, bool) // If I change this to the PermissionValidator type, it triggers #25838 in Go.
	GetMiddleware() []Middleware
	GetCooldown() Cooldown
}

CategoryInterface is the interface which is used for categories. This can be used to write your own category handler if you wish.

type ChannelCooldown added in v1.8.0

type ChannelCooldown struct {

	// MaxRuns is the maximum amount of times a command can be ran by a channel until each usage expires.
	MaxRuns uint

	// UsageExpires is used to define how long until a usage expires (and is therefore not counted in the cooldown).
	UsageExpires time.Duration
	// contains filtered or unexported fields
}

ChannelCooldown implements the Cooldown interface and is used to handle channel level ratelimits.

func (*ChannelCooldown) Check added in v1.8.0

func (c *ChannelCooldown) Check(ctx *Context) (string, bool)

Check is used to check if the command should run and add 1 to the channel count.

func (*ChannelCooldown) Clear added in v1.8.0

func (c *ChannelCooldown) Clear()

Clear is used to clear all cooldowns.

func (*ChannelCooldown) Init added in v1.8.0

func (c *ChannelCooldown) Init()

Init is used to initialise the channel cooldowns.

type ChildMenuOptions

type ChildMenuOptions struct {
	Embed        *disgord.Embed `json:"embed"`
	Button       *MenuButton    `json:"button"`
	BeforeAction func()         `json:"-"`
	AfterAction  func()         `json:"-"`
}

ChildMenuOptions are options which can be set when creating a child menu.

type Command

type Command struct {
	Name                 string                   `json:"name"`
	Aliases              []string                 `json:"aliases"`
	Description          string                   `json:"description"`
	Usage                string                   `json:"usage"`
	Category             CategoryInterface        `json:"category"`
	Cooldown             Cooldown                 `json:"cooldown"`
	CommandAttributes    interface{}              `json:"commandAttributes"`
	PermissionValidators []PermissionValidator    `json:"-"`
	ArgTransformers      []ArgTransformer         `json:"-"`
	Middleware           []Middleware             `json:"-"`
	Function             func(ctx *Context) error `json:"-"`
	// contains filtered or unexported fields
}

Command defines a command which can be used within the Router.

func (*Command) CommandFunction

func (c *Command) CommandFunction(ctx *Context) error

CommandFunction is used to run the command function.

func (Command) GetAliases

func (obj Command) GetAliases() []string

GetAliases is used to get the aliases.

func (Command) GetArgTransformers

func (obj Command) GetArgTransformers() []ArgTransformer

GetArgTransformers is used to get the arg transformers.

func (Command) GetCategory

func (obj Command) GetCategory() CategoryInterface

GetCategory is used to get the category.

func (Command) GetCooldown added in v1.8.0

func (obj Command) GetCooldown() Cooldown

GetCooldown is used to get the cooldown.

func (Command) GetDescription

func (obj Command) GetDescription() string

GetDescription is used to get the description.

func (Command) GetMiddleware

func (obj Command) GetMiddleware() []Middleware

GetMiddleware is used to get the middleware.

func (Command) GetName

func (obj Command) GetName() string

GetName is used to get the name.

func (Command) GetPermissionValidators

func (obj Command) GetPermissionValidators() []PermissionValidator

GetPermissionValidators is used to get the permission validators.

func (Command) GetUsage

func (obj Command) GetUsage() string

GetUsage is used to get the usage.

func (*Command) HasPermission

func (c *Command) HasPermission(ctx *Context) error

HasPermission is a shorthand for running CommandHasPermission on the command. This is here to prevent a breaking change.

func (*Command) Init

func (c *Command) Init()

Init is used to initialise the command.

type CommandBasics

type CommandBasics = commandBasics

CommandBasics is the basic command structure minus Init and CommandFunction. The objective is that you can inherit this with your structs if you wish to make your own.

type CommandBlank

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

CommandBlank is the error which is thrown when the command is blank.

func (*CommandBlank) Error

func (c *CommandBlank) Error() string

Error is used to give the error description.

type CommandGroup added in v1.20.0

type CommandGroup struct {
	// Name is used to define the category name.
	Name string `json:"name"`

	// Aliases is used to define aliases for this command group.
	Aliases []string `json:"aliases"`

	// Description is used to define a group description.
	Description string `json:"description"`

	// Category is used to define a group category.
	Category CategoryInterface `json:"category"`

	// Cooldown is used to define a group cooldown.
	Cooldown Cooldown `json:"cooldown"`

	// PermissionValidators defines the permission validators for this group.
	PermissionValidators []PermissionValidator `json:"-"`

	// Middleware is used to define the sub-command middleware. Note that this applies to all items in the group.
	Middleware []Middleware `json:"-"`

	// NoCommandSpecified is the command to call when no command is specified.
	NoCommandSpecified CommandInterface
	// contains filtered or unexported fields
}

CommandGroup is used to have a group of commands which will be executed as sub-commands.

func (*CommandGroup) AddCommand added in v1.20.0

func (g *CommandGroup) AddCommand(cmd CommandInterface)

AddCommand is used to add a command to the group.

func (*CommandGroup) CommandFunction added in v1.20.0

func (g *CommandGroup) CommandFunction(ctx *Context) error

CommandFunction is the command function which will be called.

func (*CommandGroup) GetAliases added in v1.20.0

func (g *CommandGroup) GetAliases() []string

GetAliases is used to get the aliases.

func (*CommandGroup) GetArgTransformers added in v1.20.0

func (g *CommandGroup) GetArgTransformers() []ArgTransformer

GetArgTransformers is used to get the arg transformers.

func (*CommandGroup) GetCategory added in v1.20.0

func (g *CommandGroup) GetCategory() CategoryInterface

GetCategory is used to get the category.

func (*CommandGroup) GetCooldown added in v1.20.0

func (g *CommandGroup) GetCooldown() Cooldown

GetCooldown is used to get the cooldown.

func (*CommandGroup) GetDescription added in v1.20.0

func (g *CommandGroup) GetDescription() string

GetDescription is used to get the description.

func (*CommandGroup) GetMiddleware added in v1.20.0

func (g *CommandGroup) GetMiddleware() []Middleware

GetMiddleware is used to get the middleware.

func (*CommandGroup) GetName added in v1.20.0

func (g *CommandGroup) GetName() string

GetName is used to get the name.

func (*CommandGroup) GetPermissionValidators added in v1.20.0

func (g *CommandGroup) GetPermissionValidators() []PermissionValidator

GetPermissionValidators is used to get the permission validators.

func (*CommandGroup) GetSubcommands added in v1.20.0

func (g *CommandGroup) GetSubcommands() []CommandInterface

GetSubcommands is used to get all the sub-commands of this group.

func (*CommandGroup) GetUsage added in v1.20.0

func (g *CommandGroup) GetUsage() string

GetUsage is used to get the usage.

func (*CommandGroup) Init added in v1.20.0

func (g *CommandGroup) Init()

Init is used to initialise the commands group.

type CommandInterface

type CommandInterface interface {
	// Get the attributes of the command.
	GetName() string
	GetAliases() []string
	GetDescription() string
	GetUsage() string
	GetCooldown() Cooldown
	GetCategory() CategoryInterface
	GetPermissionValidators() []PermissionValidator
	GetArgTransformers() []ArgTransformer
	GetMiddleware() []Middleware

	// Initialisation function and command.
	Init()
	CommandFunction(ctx *Context) error
}

CommandInterface is used to define a interface which is used for commands.

type CommandNotFound

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

CommandNotFound is the error which is thrown when a command is not found.

func (*CommandNotFound) Error

func (c *CommandNotFound) Error() string

Error is used to give the error description.

type CommandOnCooldown added in v1.8.0

type CommandOnCooldown struct {
	Message string
}

CommandOnCooldown is the error which is thrown when a command is on cooldown.

func (*CommandOnCooldown) Error added in v1.8.0

func (c *CommandOnCooldown) Error() string

Error is used to give the error description.

type Context

type Context struct {
	ShardID          uint                   `json:"shardId"`
	Prefix           string                 `json:"prefix"`
	Message          *disgord.Message       `json:"message"`
	BotUser          *disgord.User          `json:"botUser"`
	Router           *Router                `json:"-"`
	Session          disgord.Session        `json:"session"`
	Command          CommandInterface       `json:"command"`
	RawArgs          string                 `json:"rawArgs"`
	Args             []interface{}          `json:"args"`
	WaitManager      *WaitManager           `json:"-"`
	MiddlewareParams map[string]interface{} `json:"middlewareParams"`
	State            interface{}            `json:"state"`
}

Context defines the information which might be required to run the command.

func (*Context) BotMember

func (c *Context) BotMember() (*disgord.Member, error)

BotMember is used to get the bot as a member of the server this was within.

func (*Context) Channel

func (c *Context) Channel() (*disgord.Channel, error)

Channel is used to get the channel if the bot needs it.

func (*Context) DisplayEmbedMenu

func (c *Context) DisplayEmbedMenu(m *EmbedMenu) error

DisplayEmbedMenu is used to allow you to easily display a embed menu.

func (*Context) DisplayEmbedMenuWithLifetime added in v1.11.0

func (c *Context) DisplayEmbedMenuWithLifetime(m *EmbedMenu, lifetime *EmbedLifetimeOptions) error

DisplayEmbedMenuWithLifetime is used to easily display an embed menu with a lifetime.

func (*Context) EmbedTextFailover added in v1.9.0

func (c *Context) EmbedTextFailover(EmbedGenerator func() *disgord.Embed, TextGenerator func() string) (*disgord.Message, error)

EmbedTextFailover is used to check the permissions when sending a message and failover to sending text if we cannot send an embed but can send a message. If the bot doesn't have permissions to send a message, we return an error. If the bot has permission to send an embed, we use the embed generator, and if we don't we use the text generator.

func (*Context) Guild added in v1.3.0

func (c *Context) Guild() (*disgord.Guild, error)

Guild is used to get the guild if the bot needs it.

func (*Context) PermissionVerifiedReply added in v1.3.0

func (c *Context) PermissionVerifiedReply(data ...interface{}) (*disgord.Message, error)

PermissionVerifiedReply is used to reply to a command with a message. This is slower than the standard reply command since it checks it has permission first, but it also reduces the risk of a Cloudflare ban from the API.

func (*Context) Replay

func (c *Context) Replay() error

Replay is used to replay a command.

func (*Context) Reply

func (c *Context) Reply(data ...interface{}) (*disgord.Message, error)

Reply is used to quickly reply to a command with a message.

func (*Context) WaitForMessage

func (c *Context) WaitForMessage(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.Message) bool) *disgord.Message

WaitForMessage allows you to wait for a message. This function uses WaitForMessageCreate internally and is mainly here for simplicity and compatibility. You should NOT block during the check function.

type Cooldown added in v1.8.0

type Cooldown interface {
	// Init is ran on the insertion of the cooldown bucket into a command/category/attribute which has been added to the router.
	// Note that your struct should implement logic to make sure that Init only modifies the struct once since a cooldown might be shared across objects!
	Init()

	// Check should add one X (where X is what you're measuring) to the cooldown bucket and return true if the command should run.
	Check(ctx *Context) (message string, ok bool)

	// Clear should clear any command related ratelimits.
	Clear()
}

Cooldown is used to define the interface which is used to handle command cooldowns.

func MultipleCooldowns added in v1.8.0

func MultipleCooldowns(cooldowns ...Cooldown) Cooldown

MultipleCooldowns is used to chain multiple cooldowns together.

type CustomCommandsHandler

type CustomCommandsHandler = func(ctx *Context, cmdname string, parser *fastparse.Parser) (bool, error)

CustomCommandsHandler is the handler which is used for custom commands. An error being returned by the custom commands handler will return in that being passed through to the error handler instead. true here represents this being a custom command. This means the Router will not go through the errors handler unless an error is set. You should NOT call Done on the parser since this is done internally.

type EmbedLifetimeOptions added in v1.11.0

type EmbedLifetimeOptions struct {
	// The maximum time after which an embed is created for which it can exist.
	// After this time has passed, if it hasn't already then the menu will be deleted.
	MaximumLifetime time.Duration

	// The maximum time after an embed was last interacted with (reacted to) that it can exist for.
	// After this time has passed, if it hasn't already then the menu will be deleted.
	InactiveLifetime time.Duration

	// The function called before the menu should be deleted.
	BeforeDelete func()

	// The function called after the message is deleted (only if deleted through exceeded lifetime).
	// Called regardless of errors returned when deleting the message.
	AfterDelete func()
	// contains filtered or unexported fields
}

EmbedLifetimeOptions represents the options used to control the lifetime of a menu, all fields are optional.

func (*EmbedLifetimeOptions) Start added in v1.11.0

func (l *EmbedLifetimeOptions) Start(ChannelID, MessageID disgord.Snowflake, client disgord.Session)

Start inits the timers for the lifetime.

type EmbedMenu

type EmbedMenu struct {
	Reactions *MenuReactions

	Embed    *disgord.Embed
	MenuInfo *MenuInfo
	// contains filtered or unexported fields
}

EmbedMenu is the base menu.

func NewEmbedMenu

func NewEmbedMenu(embed *disgord.Embed, ctx *Context) *EmbedMenu

NewEmbedMenu is used to create a new menu handler.

func (*EmbedMenu) AddBackButton

func (e *EmbedMenu) AddBackButton()

AddBackButton is used to add a back Button to the page.

func (*EmbedMenu) AddExitButton added in v1.11.0

func (e *EmbedMenu) AddExitButton()

AddExitButton is used to add an Exit button to the page, deleting the menu if pressed.

func (*EmbedMenu) AddParentMenu

func (e *EmbedMenu) AddParentMenu(Menu *EmbedMenu)

AddParentMenu is used to add a new parent menu.

func (*EmbedMenu) Display

func (e *EmbedMenu) Display(ChannelID, MessageID disgord.Snowflake, client disgord.Session) error

Display is used to show a menu. This is un-protected so that people can write their own things on top of embed menus, but you probably want to use ctx.DisplayEmbedMenu(menu).

func (*EmbedMenu) NewChildMenu

func (e *EmbedMenu) NewChildMenu(options *ChildMenuOptions) *EmbedMenu

NewChildMenu is used to create a new child menu.

type ErrorHandler

type ErrorHandler = func(ctx *Context, err error) bool

ErrorHandler is a function which is used to handle errors. true here means that the error was handled by this handler. If this is false, the processor will go to the next handler.

type GetState added in v1.20.0

type GetState = func(ctx *Context) error

GetState is the function used to set the state on the Context. Any errors returned from this function will simply get passed through the error handler.

type GuildChannelRelationshipManagement added in v1.2.0

type GuildChannelRelationshipManagement interface {
	GetAllChannelIDs(GuildID disgord.Snowflake) []disgord.Snowflake
	AddChannelID(GuildID, ChannelID disgord.Snowflake)
	RemoveChannelID(GuildID, ChannelID disgord.Snowflake)
}

GuildChannelRelationshipManagement are an optional set of functions which a struct implementing MessageCacheStorageAdapter can use to manage channel/guild ID relationships.

type GuildCooldown added in v1.8.0

type GuildCooldown struct {

	// MaxRuns is the maximum amount of times a command can be ran in a guild until each usage expires.
	MaxRuns uint

	// UsageExpires is used to define how long until a usage expires (and is therefore not counted in the cooldown).
	UsageExpires time.Duration
	// contains filtered or unexported fields
}

GuildCooldown implements the Cooldown interface and is used to handle guild level ratelimits.

func (*GuildCooldown) Check added in v1.8.0

func (g *GuildCooldown) Check(ctx *Context) (string, bool)

Check is used to check if the command should run and add 1 to the guild count.

func (*GuildCooldown) Clear added in v1.8.0

func (g *GuildCooldown) Clear()

Clear is used to clear all cooldowns.

func (*GuildCooldown) Init added in v1.8.0

func (g *GuildCooldown) Init()

Init is used to initialise the guild cooldowns.

type InMemoryMessageCacheStorageAdapter

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

InMemoryMessageCacheStorageAdapter is used to hold cached messages in RAM. This is extremely fast, but will lead to increased RAM usage.

func (*InMemoryMessageCacheStorageAdapter) AddChannelID

func (c *InMemoryMessageCacheStorageAdapter) AddChannelID(GuildID, ChannelID disgord.Snowflake)

AddChannelID is used to add a channel ID to the guild.

func (*InMemoryMessageCacheStorageAdapter) BulkGetAndDelete added in v1.11.0

func (c *InMemoryMessageCacheStorageAdapter) BulkGetAndDelete(ChannelID disgord.Snowflake, MessageIDs []disgord.Snowflake) []*disgord.Message

BulkGetAndDelete is used to delete a slice of message IDs in the cache. Returns the deleted messages.

func (*InMemoryMessageCacheStorageAdapter) Delete

func (c *InMemoryMessageCacheStorageAdapter) Delete(ChannelID, MessageID disgord.Snowflake)

Delete is used to delete a specific message from the cache.

func (*InMemoryMessageCacheStorageAdapter) DeleteChannelsMessages

func (c *InMemoryMessageCacheStorageAdapter) DeleteChannelsMessages(ChannelID disgord.Snowflake)

DeleteChannelsMessages is used to delete a channels messages from a cache.

func (*InMemoryMessageCacheStorageAdapter) GetAllChannelIDs

func (c *InMemoryMessageCacheStorageAdapter) GetAllChannelIDs(GuildID disgord.Snowflake) []disgord.Snowflake

GetAllChannelIDs is used to get all of the channel ID's.

func (*InMemoryMessageCacheStorageAdapter) GetAndDelete

func (c *InMemoryMessageCacheStorageAdapter) GetAndDelete(ChannelID, MessageID disgord.Snowflake) *disgord.Message

GetAndDelete is used to get and delete from the cache where this is possible.

func (*InMemoryMessageCacheStorageAdapter) Init

Init is used to initialise the in-memory message cache.

func (*InMemoryMessageCacheStorageAdapter) RemoveChannelID

func (c *InMemoryMessageCacheStorageAdapter) RemoveChannelID(GuildID, ChannelID disgord.Snowflake)

RemoveChannelID is used to remove a channel ID to the guild.

func (*InMemoryMessageCacheStorageAdapter) RemoveGuild

func (c *InMemoryMessageCacheStorageAdapter) RemoveGuild(GuildID disgord.Snowflake)

RemoveGuild is used to remove a guild from the cache.

func (*InMemoryMessageCacheStorageAdapter) Set

func (c *InMemoryMessageCacheStorageAdapter) Set(ChannelID, MessageID disgord.Snowflake, Message *disgord.Message, Limit uint)

Set is used to set a item in the cache.

func (*InMemoryMessageCacheStorageAdapter) Update added in v1.10.0

func (c *InMemoryMessageCacheStorageAdapter) Update(ChannelID, MessageID disgord.Snowflake, Message *disgord.Message) (old *disgord.Message)

Update is used to update an item in the cache. Return the old message.

type IncorrectPermissions

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

IncorrectPermissions is the error which is thrown when the user does not have enough permissions.

func (*IncorrectPermissions) Error

func (c *IncorrectPermissions) Error() string

Error is used to give the error description.

type InvalidArgCount

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

InvalidArgCount is the error when the arg count is not correct.

func (*InvalidArgCount) Error

func (c *InvalidArgCount) Error() string

Error is used to give the error description.

type InvalidTransformation

type InvalidTransformation struct {
	Description string
}

InvalidTransformation is the error argument parsers should use when they can't transform.

func (*InvalidTransformation) Error

func (c *InvalidTransformation) Error() string

Error is used to give the error description.

type MenuButton struct {
	Emoji       string
	Name        string
	Description string
}

MenuButton is the datatype containing information about the button.

type MenuInfo struct {
	Author string
	Info   []string
}

MenuInfo contains the information about the menu.

type MenuReaction struct {
	Button   *MenuButton
	Function func(ChannelID, MessageID disgord.Snowflake, _ *EmbedMenu, client disgord.Session)
}

MenuReaction represents the button and the function which it triggers.

type MenuReactions struct {
	ReactionSlice []MenuReaction
}

MenuReactions are all of the reactions which the menu has.

func (mr *MenuReactions) Add(reaction MenuReaction)

Add is used to add a menu reaction.

type MessageCacheHandler added in v1.10.0

type MessageCacheHandler struct {
	MessageCacheStorageAdapter MessageCacheStorageAdapter                                                        `json:"-"`
	BulkDeletedCallback        func(s disgord.Session, channelID disgord.Snowflake, messages []*disgord.Message) `json:""`
	DeletedCallback            func(s disgord.Session, msg *disgord.Message)                                     `json:"-"`
	UpdatedCallback            func(s disgord.Session, before, after *disgord.Message)                           `json:"-"`

	// Limit defines the amount of messages.
	// -1 = unlimited (not suggested if it's in-memory since it'll lead to memory leaks), 0 = default, >0 = user set maximum
	Limit int `json:"limit"`

	// IgnoreBots is whether or not messages from bots should be excluded from the message cache.
	IgnoreBots bool `json:"ignoreBots"`
}

MessageCacheHandler is used to handle dispatching events for deleted/edited messages. It does this by using the storage adapter to log messages, then the message is deleted from the database at the message limit or when the deleted message handler is called.

type MessageCacheStorageAdapter

type MessageCacheStorageAdapter interface {
	// Called when the router is created.
	Init()

	// Related to message caching.
	BulkGetAndDelete(ChannelID disgord.Snowflake, MessageIDs []disgord.Snowflake) []*disgord.Message
	GetAndDelete(ChannelID, MessageID disgord.Snowflake) *disgord.Message
	Delete(ChannelID, MessageID disgord.Snowflake)
	DeleteChannelsMessages(ChannelID disgord.Snowflake)
	Set(ChannelID, MessageID disgord.Snowflake, Message *disgord.Message, Limit uint)
	Update(ChannelID, MessageID disgord.Snowflake, Message *disgord.Message) (old *disgord.Message)

	// Handles guild removal. The behaviour of this changes depending on if GuildChannelRelationshipManagement is implemented.
	// If it is, this will just be used to remove all guild/channel relationships but not messages from the cache (that'll be done by running DeleteChannelsMessages with each channel ID).
	// If it isn't, it will remove all of the guilds messages from the cache.
	RemoveGuild(GuildID disgord.Snowflake)
}

MessageCacheStorageAdapter is the interface which is used for message cache storage adapters.

type Middleware

type Middleware = func(ctx *Context) error

Middleware is used to handle setting data within the context before the command is ran. This is useful if there is stuff you want to do, but you don't want to type on every command. If this errors, it will just get passed through to the error handler.

type PanicError

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

PanicError is used when a string is returned from a panic. If it isn't a string, the error will just be pushed into the handler.

func (*PanicError) Error

func (c *PanicError) Error() string

Error is used to give the error description.

type PermissionCheckSettings added in v1.4.0

type PermissionCheckSettings uint8

PermissionCheckSettings is used to define the settings which are used for checking permissions.

const (
	// CheckMembersUserPermissions is used to check the members user permissions.
	CheckMembersUserPermissions PermissionCheckSettings = 1 << iota

	// CheckMembersChannelPermissions is used to check the members channel permissions.
	CheckMembersChannelPermissions

	// CheckBotUserPermissions is used to check the bots user permissions.
	CheckBotUserPermissions

	// CheckBotChannelPermissions is used to check the bots channel permissions.
	CheckBotChannelPermissions
)

type PermissionValidator

type PermissionValidator = func(ctx *Context) (string, bool)

PermissionValidator is a function which is used to validate someones permissions who is running a command. If the boolean is set to true, it means the user has permissions. If it is false, the user does not, and the string will be used as the error with the IncorrectPermissions type.

type PrefixCheck

type PrefixCheck = func(ctx *Context, r io.ReadSeeker) bool

PrefixCheck is the type for a function to check the prefix. true here means the prefix is there and was read. Note that prefix functions cannot see the member object in the message since that is patched in AFTER this is ran.

type Router

type Router struct {
	PrefixCheck           PrefixCheck           `json:"-"`
	CustomCommandsHandler CustomCommandsHandler `json:"-"`

	MessageCacheHandler *MessageCacheHandler
	Cooldown            Cooldown
	GetState            GetState
	// contains filtered or unexported fields
}

Router defines the command router which is being used. Please call NewRouter to initialise this rather than creating a new struct.

func NewRouter

func NewRouter(Config *RouterConfig) *Router

NewRouter creates a new command Router.

func (*Router) AddErrorHandler

func (r *Router) AddErrorHandler(Handler ErrorHandler)

AddErrorHandler is used to add a error handler to the Router. An error handler takes the structure of the ErrorHandler type above. Error handlers are executed in the order in which they are added to the Router.

func (*Router) CommandProcessor

func (r *Router) CommandProcessor(s disgord.Session, ShardID uint, msg *disgord.Message, prefix bool)

CommandProcessor is used to do the message command processing.

func (*Router) GetAllCommands

func (r *Router) GetAllCommands() []CommandInterface

GetAllCommands is used to get all of the commands.

func (*Router) GetCommand

func (r *Router) GetCommand(Name string) CommandInterface

GetCommand is used to get a command from the Router if it exists. If the command doesn't exist, this will be a nil pointer.

func (*Router) GetCommandsOrderedByCategory

func (r *Router) GetCommandsOrderedByCategory() map[CategoryInterface][]CommandInterface

GetCommandsOrderedByCategory is used to order commands by the categories.

func (*Router) Hook

func (r *Router) Hook(s disgord.Session)

Hook is used to hook all required events into the disgord client.

func (*Router) RemoveCommand

func (r *Router) RemoveCommand(c CommandInterface)

RemoveCommand is used to remove a command from the Router.

func (*Router) SetCommand

func (r *Router) SetCommand(c CommandInterface)

SetCommand is used to set a command.

type RouterConfig

type RouterConfig struct {
	MessageCacheHandler  *MessageCacheHandler
	PrefixCheck          PrefixCheck
	ErrorHandlers        []ErrorHandler
	PermissionValidators []PermissionValidator
	Middleware           []Middleware
	Cooldown             Cooldown
	GetState             GetState

	// The number if message pads which will be created in memory to allow for quicker parsing.
	// Please set this to -1 if you do not want any, 0 will default to 100.
	MessagePads int
}

RouterConfig defines the config which will be used for the Router.

type UserCooldown added in v1.8.0

type UserCooldown struct {

	// MaxRuns is the maximum amount of times a command can be ran by a user until each usage expires.
	MaxRuns uint

	// UsageExpires is used to define how long until a usage expires (and is therefore not counted in the cooldown).
	UsageExpires time.Duration
	// contains filtered or unexported fields
}

UserCooldown implements the Cooldown interface and is used to handle user level ratelimits.

func (*UserCooldown) Check added in v1.8.0

func (u *UserCooldown) Check(ctx *Context) (string, bool)

Check is used to check if the command should run and add 1 to the user count.

func (*UserCooldown) Clear added in v1.8.0

func (u *UserCooldown) Clear()

Clear is used to clear all cooldowns.

func (*UserCooldown) Init added in v1.8.0

func (u *UserCooldown) Init()

Init is used to initialise the user cooldowns.

type WaitManager added in v1.5.0

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

WaitManager is used to manage waiting within the context.

func (*WaitManager) WaitForChannelCreate added in v1.5.0

func (w *WaitManager) WaitForChannelCreate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.ChannelCreate) bool) *disgord.ChannelCreate

WaitForChannelCreate allows you to wait for the ChannelCreate event. You should NOT block during the check function.

func (*WaitManager) WaitForChannelDelete added in v1.5.0

func (w *WaitManager) WaitForChannelDelete(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.ChannelDelete) bool) *disgord.ChannelDelete

WaitForChannelDelete allows you to wait for the ChannelDelete event. You should NOT block during the check function.

func (*WaitManager) WaitForChannelPinsUpdate added in v1.5.0

func (w *WaitManager) WaitForChannelPinsUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.ChannelPinsUpdate) bool) *disgord.ChannelPinsUpdate

WaitForChannelPinsUpdate allows you to wait for the ChannelPinsUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForChannelUpdate added in v1.5.0

func (w *WaitManager) WaitForChannelUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.ChannelUpdate) bool) *disgord.ChannelUpdate

WaitForChannelUpdate allows you to wait for the ChannelUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildBanAdd added in v1.5.0

func (w *WaitManager) WaitForGuildBanAdd(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildBanAdd) bool) *disgord.GuildBanAdd

WaitForGuildBanAdd allows you to wait for the GuildBanAdd event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildBanRemove added in v1.5.0

func (w *WaitManager) WaitForGuildBanRemove(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildBanRemove) bool) *disgord.GuildBanRemove

WaitForGuildBanRemove allows you to wait for the GuildBanRemove event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildCreate added in v1.5.0

func (w *WaitManager) WaitForGuildCreate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildCreate) bool) *disgord.GuildCreate

WaitForGuildCreate allows you to wait for the GuildCreate event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildDelete added in v1.5.0

func (w *WaitManager) WaitForGuildDelete(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildDelete) bool) *disgord.GuildDelete

WaitForGuildDelete allows you to wait for the GuildDelete event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildEmojisUpdate added in v1.5.0

func (w *WaitManager) WaitForGuildEmojisUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildEmojisUpdate) bool) *disgord.GuildEmojisUpdate

WaitForGuildEmojisUpdate allows you to wait for the GuildEmojisUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildMemberAdd added in v1.5.0

func (w *WaitManager) WaitForGuildMemberAdd(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildMemberAdd) bool) *disgord.GuildMemberAdd

WaitForGuildMemberAdd allows you to wait for the GuildMemberAdd event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildMemberRemove added in v1.5.0

func (w *WaitManager) WaitForGuildMemberRemove(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildMemberRemove) bool) *disgord.GuildMemberRemove

WaitForGuildMemberRemove allows you to wait for the GuildMemberRemove event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildMemberUpdate added in v1.5.0

func (w *WaitManager) WaitForGuildMemberUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildMemberUpdate) bool) *disgord.GuildMemberUpdate

WaitForGuildMemberUpdate allows you to wait for the GuildMemberUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildRoleCreate added in v1.5.0

func (w *WaitManager) WaitForGuildRoleCreate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildRoleCreate) bool) *disgord.GuildRoleCreate

WaitForGuildRoleCreate allows you to wait for the GuildRoleCreate event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildRoleDelete added in v1.5.0

func (w *WaitManager) WaitForGuildRoleDelete(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildRoleDelete) bool) *disgord.GuildRoleDelete

WaitForGuildRoleDelete allows you to wait for the GuildRoleDelete event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildRoleUpdate added in v1.5.0

func (w *WaitManager) WaitForGuildRoleUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildRoleUpdate) bool) *disgord.GuildRoleUpdate

WaitForGuildRoleUpdate allows you to wait for the GuildRoleUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForGuildUpdate added in v1.5.0

func (w *WaitManager) WaitForGuildUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.GuildUpdate) bool) *disgord.GuildUpdate

WaitForGuildUpdate allows you to wait for the GuildUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForInviteCreate added in v1.5.0

func (w *WaitManager) WaitForInviteCreate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.InviteCreate) bool) *disgord.InviteCreate

WaitForInviteCreate allows you to wait for the InviteCreate event. You should NOT block during the check function.

func (*WaitManager) WaitForInviteDelete added in v1.5.0

func (w *WaitManager) WaitForInviteDelete(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.InviteDelete) bool) *disgord.InviteDelete

WaitForInviteDelete allows you to wait for the InviteDelete event. You should NOT block during the check function.

func (*WaitManager) WaitForMessageCreate added in v1.5.0

func (w *WaitManager) WaitForMessageCreate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.MessageCreate) bool) *disgord.MessageCreate

WaitForMessageCreate allows you to wait for the MessageCreate event. You should NOT block during the check function.

func (*WaitManager) WaitForMessageDelete added in v1.5.0

func (w *WaitManager) WaitForMessageDelete(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.MessageDelete) bool) *disgord.MessageDelete

WaitForMessageDelete allows you to wait for the MessageDelete event. You should NOT block during the check function.

func (*WaitManager) WaitForMessageDeleteBulk added in v1.5.0

func (w *WaitManager) WaitForMessageDeleteBulk(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.MessageDeleteBulk) bool) *disgord.MessageDeleteBulk

WaitForMessageDeleteBulk allows you to wait for the MessageDeleteBulk event. You should NOT block during the check function.

func (*WaitManager) WaitForMessageReactionAdd added in v1.5.0

func (w *WaitManager) WaitForMessageReactionAdd(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.MessageReactionAdd) bool) *disgord.MessageReactionAdd

WaitForMessageReactionAdd allows you to wait for the MessageReactionAdd event. You should NOT block during the check function.

func (*WaitManager) WaitForMessageReactionRemove added in v1.5.0

func (w *WaitManager) WaitForMessageReactionRemove(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.MessageReactionRemove) bool) *disgord.MessageReactionRemove

WaitForMessageReactionRemove allows you to wait for the MessageReactionRemove event. You should NOT block during the check function.

func (*WaitManager) WaitForMessageReactionRemoveAll added in v1.5.0

func (w *WaitManager) WaitForMessageReactionRemoveAll(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.MessageReactionRemoveAll) bool) *disgord.MessageReactionRemoveAll

WaitForMessageReactionRemoveAll allows you to wait for the MessageReactionRemoveAll event. You should NOT block during the check function.

func (*WaitManager) WaitForMessageUpdate added in v1.5.0

func (w *WaitManager) WaitForMessageUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.MessageUpdate) bool) *disgord.MessageUpdate

WaitForMessageUpdate allows you to wait for the MessageUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForPresenceUpdate added in v1.5.0

func (w *WaitManager) WaitForPresenceUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.PresenceUpdate) bool) *disgord.PresenceUpdate

WaitForPresenceUpdate allows you to wait for the PresenceUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForTypingStart added in v1.5.0

func (w *WaitManager) WaitForTypingStart(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.TypingStart) bool) *disgord.TypingStart

WaitForTypingStart allows you to wait for the TypingStart event. You should NOT block during the check function.

func (*WaitManager) WaitForUserUpdate added in v1.5.0

func (w *WaitManager) WaitForUserUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.UserUpdate) bool) *disgord.UserUpdate

WaitForUserUpdate allows you to wait for the UserUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForVoiceServerUpdate added in v1.5.0

func (w *WaitManager) WaitForVoiceServerUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.VoiceServerUpdate) bool) *disgord.VoiceServerUpdate

WaitForVoiceServerUpdate allows you to wait for the VoiceServerUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForVoiceStateUpdate added in v1.5.0

func (w *WaitManager) WaitForVoiceStateUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.VoiceStateUpdate) bool) *disgord.VoiceStateUpdate

WaitForVoiceStateUpdate allows you to wait for the VoiceStateUpdate event. You should NOT block during the check function.

func (*WaitManager) WaitForWebhooksUpdate added in v1.5.0

func (w *WaitManager) WaitForWebhooksUpdate(ctx context.Context, CheckFunc func(s disgord.Session, evt *disgord.WebhooksUpdate) bool) *disgord.WebhooksUpdate

WaitForWebhooksUpdate allows you to wait for the WebhooksUpdate event. You should NOT block during the check function.

Jump to

Keyboard shortcuts

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