Documentation
¶
Index ¶
- type AppliedCommand
- type CommandContext
- func (cc *CommandContext) DeleteResponse() (err error)
- func (cc *CommandContext) EditResponse(content string) (err error)
- func (cc *CommandContext) FollowupCreate(content string) (FollowupMessage, error)
- func (cc *CommandContext) GetOption(option string) (value *discordgo.ApplicationCommandInteractionDataOption, ok bool)
- func (cc *CommandContext) Respond(content string)
- type DiscordAC
- type DispatchRequest
- type FollowupMessage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AppliedCommand ¶
type AppliedCommand struct { Specification *discordgo.ApplicationCommand // TODO: find a better approach with guild id? GuildId string // Command implementation Handler func(cc *CommandContext) }
AppliedCommand is a command representation inside DiscordAC Wraps command specification described by discordgo.ApplicationCommand and holds a corresponding command handler
func (AppliedCommand) Global ¶
func (sc AppliedCommand) Global() bool
Global determines either SlashCommand is defined to run globally or in AppliedCommand.GuildId
func (AppliedCommand) InternalName ¶
func (sc AppliedCommand) InternalName() string
func (AppliedCommand) Invoke ¶
func (sc AppliedCommand) Invoke(cc *CommandContext)
Invoke calls AppliedCommand.Handler cc : CommandContext around which the command will run
type CommandContext ¶
type CommandContext struct { // Session is a connection to Discord API Session *discordgo.Session // Interaction is what issued the command to execute Interaction *discordgo.Interaction // Options are provided command options to use during execution Options map[string]*discordgo.ApplicationCommandInteractionDataOption }
CommandContext is a command execution context to execute it around It includes everything which is related and is useful to command execution
func (*CommandContext) DeleteResponse ¶
func (cc *CommandContext) DeleteResponse() (err error)
func (*CommandContext) EditResponse ¶
func (cc *CommandContext) EditResponse(content string) (err error)
func (*CommandContext) FollowupCreate ¶
func (cc *CommandContext) FollowupCreate(content string) (FollowupMessage, error)
func (*CommandContext) GetOption ¶
func (cc *CommandContext) GetOption(option string) (value *discordgo.ApplicationCommandInteractionDataOption, ok bool)
func (*CommandContext) Respond ¶
func (cc *CommandContext) Respond(content string)
type DiscordAC ¶
type DiscordAC struct {
// contains filtered or unexported fields
}
DiscordAC represents a high level API to command management
func (*DiscordAC) Init ¶
func (ds *DiscordAC) Init()
Init initializes command dispatcher by adding a new handler which dispatches and invokes commands
func (*DiscordAC) RegisterCommand ¶
func (ds *DiscordAC) RegisterCommand(guildId string, command *AppliedCommand) error
RegisterCommand registers a single command guildId : guild to register the commands in, leave blank to register it globally command : command to register
func (*DiscordAC) RegisterCommands ¶
func (ds *DiscordAC) RegisterCommands(guildId string, commands ...*AppliedCommand) error
RegisterCommands registers a list of commands guildId : guild to register the commands in, leave blank to register it globally commands : commands to register
func (*DiscordAC) UnregisterCommands ¶
func (ds *DiscordAC) UnregisterCommands()
UnregisterCommands unregisters all commands both globally and per guild This should be called during bot shutdown
type DispatchRequest ¶
type DispatchRequest struct { Name string Type discordgo.InteractionType }
type FollowupMessage ¶
type FollowupMessage struct { CommandContext *CommandContext Message *discordgo.Message }
FollowupMessage TODO: move this inside CommandContext
func (FollowupMessage) Delete ¶
func (fm FollowupMessage) Delete() (err error)
func (FollowupMessage) Edit ¶
func (fm FollowupMessage) Edit(content string) (err error)