disgo

package module
v0.0.0-...-b7e432b Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: MIT Imports: 13 Imported by: 0

README

disgo

DiscordGo commands extension

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NilCommand = &Command{
	Handler: func(ctx *Context) error { return nil },
}
View Source
var NilContext = &Context{
	Command: NilCommand,
}

Functions

func ExecuteSafely

func ExecuteSafely(callback func() error) (err error)

func GetArgs

func GetArgs(s string) []string

func GetFunctionName

func GetFunctionName(i interface{}) string

func GetShardCount

func GetShardCount(token string) (int, error)

func RecoverAndLog

func RecoverAndLog()

Types

type AutoShardedBot

type AutoShardedBot struct {
	*Bot
	Shards map[int]*Shard
}

func NewAutoShardedBot

func NewAutoShardedBot(prefix, token string, shardIDs []int, shardCount int) (*AutoShardedBot, error)

func (*AutoShardedBot) AddHandler

func (bot *AutoShardedBot) AddHandler(handler interface{}) func()

func (*AutoShardedBot) CommandMessageCreateHandler

func (bot *AutoShardedBot) CommandMessageCreateHandler() func(*discordgo.Session, *discordgo.MessageCreate)

func (*AutoShardedBot) GetContext

func (bot *AutoShardedBot) GetContext(event *discordgo.MessageCreate) (*Context, bool)

func (*AutoShardedBot) GetShard

func (bot *AutoShardedBot) GetShard(guildID string) (*Shard, error)

func (*AutoShardedBot) Run

func (bot *AutoShardedBot) Run()

type Bot

type Bot struct {
	Prefix          string
	CaseInsensitive bool
	Session         *discordgo.Session
	Commands        []*Command
	Cogs            []*Cog
	HelpCommand     *HelpCommand
	ErrorHandler    ErrorHandler
	PanicHandler    PanicHandler
}

func NewBot

func NewBot(prefix, token string) (*Bot, error)

func (*Bot) AddCommand

func (bot *Bot) AddCommand(command *Command) error

func (*Bot) Command

func (bot *Bot) Command(name string, desc string, callback CommandHandler) (*Command, error)

func (*Bot) CommandMessageCreateHandler

func (bot *Bot) CommandMessageCreateHandler() func(*discordgo.Session, *discordgo.MessageCreate)

func (*Bot) ExecuteSafely

func (bot *Bot) ExecuteSafely(callback func() error) (recovered interface{}, returned error)

func (*Bot) GetCommand

func (bot *Bot) GetCommand(name string) (*Command, bool)

func (*Bot) GetContext

func (bot *Bot) GetContext(event *discordgo.MessageCreate) (*Context, bool)

func (*Bot) Me

func (bot *Bot) Me() (*discordgo.User, error)

func (*Bot) RemoveCommand

func (bot *Bot) RemoveCommand(name string)

func (*Bot) Run

func (bot *Bot) Run()

func (*Bot) SetHelpCommand

func (bot *Bot) SetHelpCommand(help HelpCommand) error

func (*Bot) WaitForChannelCreate

func (bot *Bot) WaitForChannelCreate(check func(*discordgo.ChannelCreate) bool) *discordgo.ChannelCreate

func (*Bot) WaitForChannelDelete

func (bot *Bot) WaitForChannelDelete(check func(*discordgo.ChannelDelete) bool) *discordgo.ChannelDelete

func (*Bot) WaitForChannelPinsUpdate

func (bot *Bot) WaitForChannelPinsUpdate(check func(*discordgo.ChannelPinsUpdate) bool) *discordgo.ChannelPinsUpdate

func (*Bot) WaitForChannelUpdate

func (bot *Bot) WaitForChannelUpdate(check func(*discordgo.ChannelUpdate) bool) *discordgo.ChannelUpdate

func (*Bot) WaitForConnect

func (bot *Bot) WaitForConnect(check func(*discordgo.Connect) bool) *discordgo.Connect

func (*Bot) WaitForDisconnect

func (bot *Bot) WaitForDisconnect(check func(*discordgo.Disconnect) bool) *discordgo.Disconnect

func (*Bot) WaitForEvent

func (bot *Bot) WaitForEvent(check func(*discordgo.Event) bool) *discordgo.Event

func (*Bot) WaitForGuildBanAdd

func (bot *Bot) WaitForGuildBanAdd(check func(*discordgo.GuildBanAdd) bool) *discordgo.GuildBanAdd

func (*Bot) WaitForGuildBanRemove

func (bot *Bot) WaitForGuildBanRemove(check func(*discordgo.GuildBanRemove) bool) *discordgo.GuildBanRemove

func (*Bot) WaitForGuildCreate

func (bot *Bot) WaitForGuildCreate(check func(*discordgo.GuildCreate) bool) *discordgo.GuildCreate

func (*Bot) WaitForGuildDelete

func (bot *Bot) WaitForGuildDelete(check func(*discordgo.GuildDelete) bool) *discordgo.GuildDelete

func (*Bot) WaitForGuildEmojisUpdate

func (bot *Bot) WaitForGuildEmojisUpdate(check func(*discordgo.GuildEmojisUpdate) bool) *discordgo.GuildEmojisUpdate

func (*Bot) WaitForGuildIntegrationsUpdate

func (bot *Bot) WaitForGuildIntegrationsUpdate(check func(*discordgo.GuildIntegrationsUpdate) bool) *discordgo.GuildIntegrationsUpdate

func (*Bot) WaitForGuildMemberAdd

func (bot *Bot) WaitForGuildMemberAdd(check func(*discordgo.GuildMemberAdd) bool) *discordgo.GuildMemberAdd

func (*Bot) WaitForGuildMemberRemove

func (bot *Bot) WaitForGuildMemberRemove(check func(*discordgo.GuildMemberRemove) bool) *discordgo.GuildMemberRemove

func (*Bot) WaitForGuildMemberUpdate

func (bot *Bot) WaitForGuildMemberUpdate(check func(*discordgo.GuildMemberUpdate) bool) *discordgo.GuildMemberUpdate

func (*Bot) WaitForGuildMembersChunk

func (bot *Bot) WaitForGuildMembersChunk(check func(*discordgo.GuildMembersChunk) bool) *discordgo.GuildMembersChunk

func (*Bot) WaitForGuildRoleCreate

func (bot *Bot) WaitForGuildRoleCreate(check func(*discordgo.GuildRoleCreate) bool) *discordgo.GuildRoleCreate

func (*Bot) WaitForGuildRoleDelete

func (bot *Bot) WaitForGuildRoleDelete(check func(*discordgo.GuildRoleDelete) bool) *discordgo.GuildRoleDelete

func (*Bot) WaitForGuildRoleUpdate

func (bot *Bot) WaitForGuildRoleUpdate(check func(*discordgo.GuildRoleUpdate) bool) *discordgo.GuildRoleUpdate

func (*Bot) WaitForGuildUpdate

func (bot *Bot) WaitForGuildUpdate(check func(*discordgo.GuildUpdate) bool) *discordgo.GuildUpdate

func (*Bot) WaitForMessageAck

func (bot *Bot) WaitForMessageAck(check func(*discordgo.MessageAck) bool) *discordgo.MessageAck

func (*Bot) WaitForMessageCreate

func (bot *Bot) WaitForMessageCreate(check func(*discordgo.MessageCreate) bool) *discordgo.MessageCreate

func (*Bot) WaitForMessageDelete

func (bot *Bot) WaitForMessageDelete(check func(*discordgo.MessageDelete) bool) *discordgo.MessageDelete

func (*Bot) WaitForMessageDeleteBulk

func (bot *Bot) WaitForMessageDeleteBulk(check func(*discordgo.MessageDeleteBulk) bool) *discordgo.MessageDeleteBulk

func (*Bot) WaitForMessageReactionAdd

func (bot *Bot) WaitForMessageReactionAdd(check func(*discordgo.MessageReactionAdd) bool) *discordgo.MessageReactionAdd

func (*Bot) WaitForMessageReactionRemove

func (bot *Bot) WaitForMessageReactionRemove(check func(*discordgo.MessageReactionRemove) bool) *discordgo.MessageReactionRemove

func (*Bot) WaitForMessageReactionRemoveAll

func (bot *Bot) WaitForMessageReactionRemoveAll(check func(*discordgo.MessageReactionRemoveAll) bool) *discordgo.MessageReactionRemoveAll

func (*Bot) WaitForMessageUpdate

func (bot *Bot) WaitForMessageUpdate(check func(*discordgo.MessageUpdate) bool) *discordgo.MessageUpdate

func (*Bot) WaitForPresenceUpdate

func (bot *Bot) WaitForPresenceUpdate(check func(*discordgo.PresenceUpdate) bool) *discordgo.PresenceUpdate

func (*Bot) WaitForPresencesReplace

func (bot *Bot) WaitForPresencesReplace(check func(*discordgo.PresencesReplace) bool) *discordgo.PresencesReplace

func (*Bot) WaitForRateLimit

func (bot *Bot) WaitForRateLimit(check func(*discordgo.RateLimit) bool) *discordgo.RateLimit

func (*Bot) WaitForReady

func (bot *Bot) WaitForReady(check func(*discordgo.Ready) bool) *discordgo.Ready

func (*Bot) WaitForRelationshipAdd

func (bot *Bot) WaitForRelationshipAdd(check func(*discordgo.RelationshipAdd) bool) *discordgo.RelationshipAdd

func (*Bot) WaitForRelationshipRemove

func (bot *Bot) WaitForRelationshipRemove(check func(*discordgo.RelationshipRemove) bool) *discordgo.RelationshipRemove

func (*Bot) WaitForResumed

func (bot *Bot) WaitForResumed(check func(*discordgo.Resumed) bool) *discordgo.Resumed

func (*Bot) WaitForTypingStart

func (bot *Bot) WaitForTypingStart(check func(*discordgo.TypingStart) bool) *discordgo.TypingStart

func (*Bot) WaitForUserGuildSettingsUpdate

func (bot *Bot) WaitForUserGuildSettingsUpdate(check func(*discordgo.UserGuildSettingsUpdate) bool) *discordgo.UserGuildSettingsUpdate

func (*Bot) WaitForUserNoteUpdate

func (bot *Bot) WaitForUserNoteUpdate(check func(*discordgo.UserNoteUpdate) bool) *discordgo.UserNoteUpdate

func (*Bot) WaitForUserSettingsUpdate

func (bot *Bot) WaitForUserSettingsUpdate(check func(*discordgo.UserSettingsUpdate) bool) *discordgo.UserSettingsUpdate

func (*Bot) WaitForUserUpdate

func (bot *Bot) WaitForUserUpdate(check func(*discordgo.UserUpdate) bool) *discordgo.UserUpdate

func (*Bot) WaitForVoiceServerUpdate

func (bot *Bot) WaitForVoiceServerUpdate(check func(*discordgo.VoiceServerUpdate) bool) *discordgo.VoiceServerUpdate

func (*Bot) WaitForVoiceStateUpdate

func (bot *Bot) WaitForVoiceStateUpdate(check func(*discordgo.VoiceStateUpdate) bool) *discordgo.VoiceStateUpdate

func (*Bot) WaitForWebhooksUpdate

func (bot *Bot) WaitForWebhooksUpdate(check func(*discordgo.WebhooksUpdate) bool) *discordgo.WebhooksUpdate

type Cog

type Cog struct {
	Name        string
	Bot         Bot
	CommandList []Command
	// contains filtered or unexported fields
}

func (Cog) CogLoad

func (cog Cog) CogLoad() error

func (Cog) CogUnload

func (cog Cog) CogUnload() error

func (Cog) Command

func (cog Cog) Command(name string, callback CommandHandler) (*Command, error)

func (Cog) Commands

func (cog Cog) Commands() map[string]Command

func (Cog) GetCommand

func (cog Cog) GetCommand(string) Command

func (Cog) GetName

func (cog Cog) GetName() string

func (Cog) Setup

func (cog Cog) Setup(bot Bot)

type Command

type Command struct {
	Name          string
	Desc          string
	QualifiedName string
	Handler       CommandHandler
	Checks        []CommandCheck
	Subcommands   []*Command
	ErrorHandler  ErrorHandler
	PanicHandler  PanicHandler
}

func HelpCommandHandler

func HelpCommandHandler(help HelpCommand) *Command

func (*Command) AddSubcommand

func (cmd *Command) AddSubcommand(subcommand *Command) error

func (*Command) Check

func (cmd *Command) Check(checks ...CommandCheck)

func (*Command) GetSubcommand

func (cmd *Command) GetSubcommand(name string) (*Command, bool)

func (*Command) Info

func (cmd *Command) Info() CommandInfo

func (*Command) Invoke

func (cmd *Command) Invoke(ctx *Context) error

func (*Command) RemoveSubcommand

func (cmd *Command) RemoveSubcommand(name string)

func (*Command) Subcommand

func (cmd *Command) Subcommand(name string, desc string, callback CommandHandler) (*Command, error)

type CommandCheck

type CommandCheck func(*Context) bool

type CommandHandler

type CommandHandler func(*Context) error

type CommandInfo

type CommandInfo struct {
	Name string
	Desc string
}

type Context

type Context struct {
	Bot     *Bot
	Command *Command
	Shard   *Shard

	Session *discordgo.Session
	Message *discordgo.MessageCreate
	Author  *discordgo.User
	Member  *discordgo.Member
	Channel *discordgo.Channel
	Guild   *discordgo.Guild

	Args []string
}

func NewContext

func NewContext(bot *Bot, command *Command, message *discordgo.MessageCreate, author *discordgo.User,
	member *discordgo.Member, channel *discordgo.Channel, guild *discordgo.Guild, args []string) *Context

func (*Context) Invoke

func (ctx *Context) Invoke() error

func (*Context) Send

func (ctx *Context) Send(content string) (*discordgo.Message, error)

type DefaultHelpCommand

type DefaultHelpCommand struct {
	Name string
	Desc string
}

func NewDefaultHelpCommand

func NewDefaultHelpCommand() DefaultHelpCommand

func (DefaultHelpCommand) Info

func (help DefaultHelpCommand) Info() CommandInfo

func (DefaultHelpCommand) SendBotHelp

func (help DefaultHelpCommand) SendBotHelp(ctx *Context) error

func (DefaultHelpCommand) SendCommandHelp

func (help DefaultHelpCommand) SendCommandHelp(ctx *Context, commandName string) error

func (DefaultHelpCommand) SendHelp

func (help DefaultHelpCommand) SendHelp(ctx *Context) error

type ErrorHandler

type ErrorHandler func(*Context, error)

type HelpCommand

type HelpCommand interface {
	//Invoke(Context) error
	SendHelp(ctx *Context) error
	SendBotHelp(ctx *Context) error
	SendCommandHelp(ctx *Context, commandName string) error
	Info() CommandInfo
}

type PanicHandler

type PanicHandler func(*Context, interface{})

type Shard

type Shard struct {
	ID      int
	Session *discordgo.Session
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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