Documentation ¶
Index ¶
- Constants
- type Application
- func (app *Application) AddCommand(command *Command)
- func (app *Application) GetCommand(name string) *Command
- func (app *Application) HandleInteraction(interaction *Interaction) *InteractionResponse
- func (app Application) PostJson(path string, obj interface{}) ([]byte, error)
- func (app *Application) RegisterAllGlobal() error
- func (app *Application) RegisterAllGuild(guildid string) error
- func (app *Application) RegisterGlobal(command *Command) (*Command, error)
- func (app *Application) RegisterGuild(guildid string, command *Command) (*Command, error)
- func (app *Application) SetListener(listener Listener)
- type ApplicationCommand
- type ApplicationCommandInteractionData
- type ApplicationCommandInteractionDataOption
- type ApplicationCommandOption
- func Group(name, description string, options []ApplicationCommandOption) ApplicationCommandOption
- func Int(name, description string, required bool) ApplicationCommandOption
- func Role(name string, description string, required bool) ApplicationCommandOption
- func Str(name, description string, required bool) ApplicationCommandOption
- func SubCmd(name, description string, options []ApplicationCommandOption) ApplicationCommandOption
- func User(name string, description string, required bool) ApplicationCommandOption
- type ApplicationCommandOptionChoice
- type ApplicationCommandOptionType
- type Command
- func (cmd *Command) AddCheck(command CommandHandler) *Command
- func (cmd *Command) AddSubCheck(name string, command CommandHandler) *Command
- func (cmd *Command) GetHandler(name string) CommandHandler
- func (cmd *Command) Handle(interaction *InteractionContext) *InteractionResponse
- func (cmd *Command) IsGlobal() bool
- func (cmd *Command) SetHandler(command CommandHandler) *Command
- func (cmd *Command) SetOptions(options ...ApplicationCommandOption) *Command
- func (cmd *Command) SetSubHandler(name string, command CommandHandler) *Command
- type CommandHandler
- type GuildMember
- type GuildUser
- type Interaction
- type InteractionApplicationCommandCallbackData
- type InteractionContext
- func (ctx *InteractionContext) GetInt(name string) int
- func (ctx *InteractionContext) GetOption(nameToFind string) *ApplicationCommandInteractionDataOption
- func (ctx *InteractionContext) GetString(name string) string
- func (ctx *InteractionContext) Respond(response *InteractionResponse)
- func (ctx *InteractionContext) Send(message *discordgo.WebhookParams) (*discordgo.Message, error)
- type InteractionHandler
- type InteractionResponse
- type InteractionResponseType
- type InteractionType
- type Listener
Constants ¶
View Source
const DISCORD_API_BASE_URL = "https://discord.com/api/v8"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct { http.Client Commands map[string]*Command AuthHeader string ClientID string DefaultResponse *InteractionResponse Session *discordgo.Session // TODO dont depend on discordgo }
func NewApp ¶
func NewApp(clientId, auth string) (*Application, error)
func (*Application) AddCommand ¶
func (app *Application) AddCommand(command *Command)
func (*Application) GetCommand ¶
func (app *Application) GetCommand(name string) *Command
func (*Application) HandleInteraction ¶
func (app *Application) HandleInteraction(interaction *Interaction) *InteractionResponse
func (Application) PostJson ¶
func (app Application) PostJson(path string, obj interface{}) ([]byte, error)
func (*Application) RegisterAllGlobal ¶
func (app *Application) RegisterAllGlobal() error
func (*Application) RegisterAllGuild ¶
func (app *Application) RegisterAllGuild(guildid string) error
func (*Application) RegisterGlobal ¶
func (app *Application) RegisterGlobal(command *Command) (*Command, error)
func (*Application) RegisterGuild ¶
func (app *Application) RegisterGuild(guildid string, command *Command) (*Command, error)
func (*Application) SetListener ¶
func (app *Application) SetListener(listener Listener)
type ApplicationCommand ¶
type ApplicationCommand struct { ID string `json:"id"` ApplicationID string `json:"ApplicationID"` Name string `json:"name"` Description string `json:"description"` Options []ApplicationCommandOption `json:"options"` }
type ApplicationCommandInteractionData ¶
type ApplicationCommandInteractionData struct { ID string `json:"id"` Name string `json:"name"` Options []ApplicationCommandInteractionDataOption `json:"options"` }
type ApplicationCommandInteractionDataOption ¶
type ApplicationCommandInteractionDataOption struct { Name string `json:"name"` Value interface{} `json:"value"` Options []ApplicationCommandInteractionDataOption `json:"options"` }
type ApplicationCommandOption ¶
type ApplicationCommandOption struct { Type ApplicationCommandOptionType `json:"type"` Name string `json:"name"` Description string `json:"description"` Default bool `json:"default"` Required bool `json:"required"` Choices []ApplicationCommandOptionChoice `json:"choices"` Options []ApplicationCommandOption `json:"options"` }
func Group ¶
func Group(name, description string, options []ApplicationCommandOption) ApplicationCommandOption
func Int ¶
func Int(name, description string, required bool) ApplicationCommandOption
func Str ¶
func Str(name, description string, required bool) ApplicationCommandOption
func SubCmd ¶
func SubCmd(name, description string, options []ApplicationCommandOption) ApplicationCommandOption
type ApplicationCommandOptionChoice ¶
type ApplicationCommandOptionChoice struct { Name string `json:"name"` Value interface{} `json:"value"` }
func Choice ¶
func Choice(name string, value string) ApplicationCommandOptionChoice
type ApplicationCommandOptionType ¶
type ApplicationCommandOptionType int
const ( SUB_COMMAND ApplicationCommandOptionType = iota + 1 SUB_COMMAND_GROUP STRING INTEGER BOOLEAN USER CHANNEL ROLE )
type Command ¶
type Command struct { ApplicationCommand // contains filtered or unexported fields }
Command stores an ApplicationCommand and a handler and adds some helper methods
func NewCommand ¶
func (*Command) AddCheck ¶
func (cmd *Command) AddCheck(command CommandHandler) *Command
func (*Command) AddSubCheck ¶
func (cmd *Command) AddSubCheck(name string, command CommandHandler) *Command
func (*Command) GetHandler ¶
func (cmd *Command) GetHandler(name string) CommandHandler
func (*Command) Handle ¶
func (cmd *Command) Handle(interaction *InteractionContext) *InteractionResponse
func (*Command) SetHandler ¶
func (cmd *Command) SetHandler(command CommandHandler) *Command
func (*Command) SetOptions ¶
func (cmd *Command) SetOptions(options ...ApplicationCommandOption) *Command
func (*Command) SetSubHandler ¶
func (cmd *Command) SetSubHandler(name string, command CommandHandler) *Command
type CommandHandler ¶
type CommandHandler func(interaction *InteractionContext) *InteractionResponse
type GuildMember ¶
type GuildMember struct { Deaf bool `json:"deaf"` IsPending bool `json:"is_pending"` JoinedAt time.Time `json:"joined_at"` Mute bool `json:"mute"` Nick interface{} `json:"nick"` Pending bool `json:"pending"` Permissions string `json:"permissions"` PremiumSince interface{} `json:"premium_since"` Roles []string `json:"roles"` User *GuildUser }
type Interaction ¶
type Interaction struct { ID string `json:"id"` Type InteractionType `json:"type"` ChannelID string `json:"channel_id"` Data ApplicationCommandInteractionData `json:"data"` GuildID string `json:"guild_id"` Member *GuildMember `json:"member"` User *GuildUser Token string `json:"token"` Version int `json:"version"` }
func (Interaction) GetUser ¶
func (interaction Interaction) GetUser() *GuildUser
func (Interaction) IsDM ¶
func (interaction Interaction) IsDM() bool
type InteractionApplicationCommandCallbackData ¶
type InteractionApplicationCommandCallbackData struct { TTS bool `json:"tts"` Content string `json:"content"` Embeds []discordgo.MessageEmbed `json:"embeds,omitempty"` AllowedMentions []discordgo.MessageAllowedMentions `json:"allowed_mentions,omitempty"` Flags int `json:"flags"` }
type InteractionContext ¶
type InteractionContext struct { *Interaction App *Application InvokedCommands []string }
InteractionContext contains an Interaction and other relevant information handlers need
func (*InteractionContext) GetInt ¶
func (ctx *InteractionContext) GetInt(name string) int
func (*InteractionContext) GetOption ¶
func (ctx *InteractionContext) GetOption(nameToFind string) *ApplicationCommandInteractionDataOption
InteractionContext.GetOption returns an ApplicationCommandInteractionDataOption from the interactions list of options
func (*InteractionContext) GetString ¶
func (ctx *InteractionContext) GetString(name string) string
func (*InteractionContext) Respond ¶
func (ctx *InteractionContext) Respond(response *InteractionResponse)
func (*InteractionContext) Send ¶
func (ctx *InteractionContext) Send(message *discordgo.WebhookParams) (*discordgo.Message, error)
type InteractionHandler ¶
type InteractionHandler func(interaction *Interaction) *InteractionResponse
type InteractionResponse ¶
type InteractionResponse struct { Type InteractionResponseType `json:"type"` Data *InteractionApplicationCommandCallbackData `json:"data,omitempty"` }
func Acknowledge ¶
func Acknowledge() *InteractionResponse
func Response ¶
func Response(content string) *InteractionResponse
func (*InteractionResponse) Embed ¶
func (resp *InteractionResponse) Embed(embed discordgo.MessageEmbed) *InteractionResponse
func (*InteractionResponse) Ephemeral ¶
func (resp *InteractionResponse) Ephemeral() *InteractionResponse
func (*InteractionResponse) KeepSource ¶
func (resp *InteractionResponse) KeepSource() *InteractionResponse
func (*InteractionResponse) OnlyAuthor ¶
func (resp *InteractionResponse) OnlyAuthor() *InteractionResponse
type InteractionResponseType ¶
type InteractionResponseType int
const ( PONG InteractionResponseType = iota + 1 ACK CHANNEL_MESSAGE CHANNEL_MESSAGE_WITH_SOURCE ACK_WITH_SOURCE )
type InteractionType ¶
type InteractionType int
const ( PING InteractionType = iota + 1 APPLICATION_COMMAND )
type Listener ¶
type Listener interface {
SetHandler(handler InteractionHandler)
}
a Listener handles receiving and responding to an interaction while letting an InteractionHandler decide the response some listeners supported included with goslash are lambda.Listener (for aws lambda), httplistener.Listener and gateway.Listener (for receiving interactions from the discord gateway)
Click to show internal directories.
Click to hide internal directories.