Documentation ¶
Index ¶
- func Handler(key string, commands []*Command) (http.Handler, error)
- type ApplicationCommand
- type ApplicationCommandInteractionData
- type ApplicationCommandInteractionDataOption
- type ApplicationCommandOption
- type ApplicationCommandOptionChoice
- type ApplicationCommandOptionType
- type CallbackFlags
- type Client
- func (c *Client) BulkOverwriteGlobalApplicationCommands(ctx context.Context, cmd []*CreateApplicationCommand) ([]*ApplicationCommand, error)
- func (c *Client) BulkOverwriteGuildApplicationCommands(ctx context.Context, guildID string, cmd []*CreateApplicationCommand) ([]*ApplicationCommand, error)
- func (c *Client) CreateFollowupMessage(ctx context.Context, interactionToken string, interaction *webhook.Webhook) error
- func (c *Client) CreateGlobalApplicationCommand(ctx context.Context, cmd *CreateApplicationCommand) (*ApplicationCommand, error)
- func (c *Client) CreateGuildApplicationCommand(ctx context.Context, guildID string, cmd *CreateApplicationCommand) (*ApplicationCommand, error)
- func (c *Client) CreateInteractionResponse(ctx context.Context, interactionID, interactionToken string, ...) error
- func (c *Client) DeleteFollowupMessage(ctx context.Context, interactionToken, messageID string) error
- func (c *Client) DeleteGlobalApplicationCommand(ctx context.Context, cmdID string) error
- func (c *Client) DeleteGuildApplicationCommand(ctx context.Context, guildID, cmdID string) error
- func (c *Client) DeleteInteractionResponse(ctx context.Context, interactionToken string) error
- func (c *Client) EditFollowupMessage(ctx context.Context, interactionToken, messageID string, ...) error
- func (c *Client) EditInteractionResponse(ctx context.Context, interactionToken string, interaction *webhook.WebhookEdit) error
- func (c *Client) GetGlobalApplicationCommand(ctx context.Context, cmdID string) (*ApplicationCommand, error)
- func (c *Client) GetGlobalApplicationCommands(ctx context.Context) ([]*ApplicationCommand, error)
- func (c *Client) GetGuildApplicationCommand(ctx context.Context, guildID, cmdID string) (*ApplicationCommand, error)
- func (c *Client) GetGuildApplicationCommands(ctx context.Context, guildID string) ([]*ApplicationCommand, error)
- func (c *Client) OAuthURL() string
- func (c *Client) UpdateGlobalApplicationCommand(ctx context.Context, cmdID string, cmd *CreateApplicationCommand) (*ApplicationCommand, error)
- func (c *Client) UpdateGuildApplicationCommand(ctx context.Context, guildID, cmdID string, cmd *CreateApplicationCommand) (*ApplicationCommand, error)
- type ClientOption
- type Command
- type CommandHandleFunc
- type CreateApplicationCommand
- type Interaction
- type InteractionApplicationCommandCallbackData
- type InteractionResponse
- type InteractionResponseType
- type InteractionType
- type Member
- type PremiumType
- type User
- type UserFlags
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplicationCommand ¶
type ApplicationCommand struct { ID string `json:"id"` ApplicationID string `json:"application_id"` CreateApplicationCommand }
ApplicationCommand https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
type ApplicationCommandInteractionData ¶
type ApplicationCommandInteractionData struct { ID string `json:"id"` Name string `json:"name"` Options []*ApplicationCommandInteractionDataOption `json:"options"` }
ApplicationCommandInteractionData https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondata
type ApplicationCommandInteractionDataOption ¶
type ApplicationCommandInteractionDataOption struct { Name string `json:"name"` Value interface{} `json:"value"` Options []*ApplicationCommandInteractionDataOption `json:"options"` }
ApplicationCommandInteractionDataOption https://discord.com/developers/docs/interactions/slash-commands#interaction-applicationcommandinteractiondataoption
func (ApplicationCommandInteractionDataOption) ValueBool ¶
func (o ApplicationCommandInteractionDataOption) ValueBool() bool
ValueBool returns the boolean or false
func (ApplicationCommandInteractionDataOption) ValueInt ¶
func (o ApplicationCommandInteractionDataOption) ValueInt() int
ValueInt returns the int (forced from JSON float64) or 0
func (ApplicationCommandInteractionDataOption) ValueString ¶
func (o ApplicationCommandInteractionDataOption) ValueString() string
ValueString returns the string or ""
type ApplicationCommandOption ¶
type ApplicationCommandOption struct { Type ApplicationCommandOptionType `json:"type"` Name string `json:"name"` Description string `json:"description"` Required bool `json:"required,omitempty"` Choices []*ApplicationCommandOptionChoice `json:"choices,omitempty"` Options []*ApplicationCommandOption `json:"options,omitempty"` }
ApplicationCommandOption https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoption
type ApplicationCommandOptionChoice ¶
type ApplicationCommandOptionChoice struct { Name string `json:"name"` Value interface{} `json:"value"` }
ApplicationCommandOptionChoice https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptionchoice
type ApplicationCommandOptionType ¶
type ApplicationCommandOptionType int
ApplicationCommandOptionType (ACOT)
const ( SubCommandACOT ApplicationCommandOptionType = iota + 1 SubCommandGroupACOT StringACOT IntegerACOT BooleanACOT UserACOT ChannelACOT RoleACOT )
https://discord.com/developers/docs/interactions/slash-commands#applicationcommandoptiontype
type CallbackFlags ¶
type CallbackFlags int
CallbackFlags (CF)
const ( NoneCF CallbackFlags = 0 EphemeralCF CallbackFlags = 64 )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a slash client
func NewClient ¶
func NewClient(clientID, clientSecret string, opts ...ClientOption) *Client
NewClient creates a new Client for working with slash commands
func (*Client) BulkOverwriteGlobalApplicationCommands ¶
func (c *Client) BulkOverwriteGlobalApplicationCommands(ctx context.Context, cmd []*CreateApplicationCommand) ([]*ApplicationCommand, error)
BulkOverwriteGlobalApplicationCommands bulk overwrites global slash commands
func (*Client) BulkOverwriteGuildApplicationCommands ¶
func (c *Client) BulkOverwriteGuildApplicationCommands(ctx context.Context, guildID string, cmd []*CreateApplicationCommand) ([]*ApplicationCommand, error)
BulkOverwriteGuildApplicationCommands bulk overwrites slash commands for a guild
func (*Client) CreateFollowupMessage ¶
func (c *Client) CreateFollowupMessage(ctx context.Context, interactionToken string, interaction *webhook.Webhook) error
CreateFollowupMessage creates a followup message
func (*Client) CreateGlobalApplicationCommand ¶
func (c *Client) CreateGlobalApplicationCommand(ctx context.Context, cmd *CreateApplicationCommand) (*ApplicationCommand, error)
CreateGlobalApplicationCommand creates a global slash command
Creating a global application command is an upsert, meaning creating a command with the same name will update it rather than return an error
func (*Client) CreateGuildApplicationCommand ¶
func (c *Client) CreateGuildApplicationCommand(ctx context.Context, guildID string, cmd *CreateApplicationCommand) (*ApplicationCommand, error)
CreateGuildApplicationCommand creates a slash command for a guild
Creating a guild application command is an upsert, meaning creating a command with the same name will update it rather than return an error
func (*Client) CreateInteractionResponse ¶
func (c *Client) CreateInteractionResponse(ctx context.Context, interactionID, interactionToken string, interaction *InteractionResponse) error
CreateInteractionResponse creates an interaction response
func (*Client) DeleteFollowupMessage ¶
func (c *Client) DeleteFollowupMessage(ctx context.Context, interactionToken, messageID string) error
DeleteFollowupMessage deletes a followup message
func (*Client) DeleteGlobalApplicationCommand ¶
DeleteGlobalApplicationCommand deletes a global slash command
func (*Client) DeleteGuildApplicationCommand ¶
DeleteGuildApplicationCommand deletes a slash command for a guild
func (*Client) DeleteInteractionResponse ¶
DeleteInteractionResponse deletes an interaction response
func (*Client) EditFollowupMessage ¶
func (c *Client) EditFollowupMessage(ctx context.Context, interactionToken, messageID string, interaction *webhook.WebhookEdit) error
EditFollowupMessage edits a followup message
func (*Client) EditInteractionResponse ¶
func (c *Client) EditInteractionResponse(ctx context.Context, interactionToken string, interaction *webhook.WebhookEdit) error
EditInteractionResponse edits an interaction response
func (*Client) GetGlobalApplicationCommand ¶
func (c *Client) GetGlobalApplicationCommand(ctx context.Context, cmdID string) (*ApplicationCommand, error)
GetGlobalApplicationCommand gets a global slash command by its ID
func (*Client) GetGlobalApplicationCommands ¶
func (c *Client) GetGlobalApplicationCommands(ctx context.Context) ([]*ApplicationCommand, error)
GetGlobalApplicationCommands gets all global slash commands
func (*Client) GetGuildApplicationCommand ¶
func (c *Client) GetGuildApplicationCommand(ctx context.Context, guildID, cmdID string) (*ApplicationCommand, error)
GetGuildApplicationCommand gets a slash command for a guild by its ID
func (*Client) GetGuildApplicationCommands ¶
func (c *Client) GetGuildApplicationCommands(ctx context.Context, guildID string) ([]*ApplicationCommand, error)
GetGuildApplicationCommands gets all slash commands for a guild
func (*Client) OAuthURL ¶
OAuthURL returns a URL suitable for giving an app slash command scope
func (*Client) UpdateGlobalApplicationCommand ¶
func (c *Client) UpdateGlobalApplicationCommand(ctx context.Context, cmdID string, cmd *CreateApplicationCommand) (*ApplicationCommand, error)
UpdateGlobalApplicationCommand updates a global slash command
func (*Client) UpdateGuildApplicationCommand ¶
func (c *Client) UpdateGuildApplicationCommand(ctx context.Context, guildID, cmdID string, cmd *CreateApplicationCommand) (*ApplicationCommand, error)
UpdateGuildApplicationCommand updates a slash command for a guild
type ClientOption ¶
type ClientOption func(*Client)
ClientOption is options for a Client
func WithHTTP ¶
func WithHTTP(client *http.Client) ClientOption
WithHTTP sets the http.Client for a Client
type Command ¶
type Command struct { ID string Handle CommandHandleFunc }
Command is used when creating a Handler
ID should map to a corresponding ApplicationCommand Handle is the func to be called whenever the Handler receives a request for the ApplicationCommand
type CommandHandleFunc ¶
type CommandHandleFunc func(*Interaction) (*InteractionResponse, error)
CommandHandleFunc is a func for Command.Handle
type CreateApplicationCommand ¶
type CreateApplicationCommand struct { Name string `json:"name"` Description string `json:"description"` Options []*ApplicationCommandOption `json:"options,omitempty"` }
CreateApplicationCommand https://discord.com/developers/docs/interactions/slash-commands#applicationcommand
type Interaction ¶
type Interaction struct { ID string `json:"id"` Type InteractionType `json:"type"` Data *ApplicationCommandInteractionData `json:"data"` GuildID string `json:"guild_id"` ChannelID string `json:"channel_id"` Member *Member `json:"member"` User *User `json:"user"` Token string `json:"token"` Version int `json:"version"` }
https://discord.com/developers/docs/interactions/slash-commands#interaction
type InteractionApplicationCommandCallbackData ¶
type InteractionApplicationCommandCallbackData struct { TTS bool `json:"tts"` Content string `json:"content"` Embeds []*embed.Embed `json:"embeds"` AllowedMentions *embed.AllowedMentions `json:"allowed_mentions"` Flags CallbackFlags `json:"flags"` }
InteractionApplicationCommandCallbackData https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata
type InteractionResponse ¶
type InteractionResponse struct { Type InteractionResponseType `json:"type"` Data *InteractionApplicationCommandCallbackData `json:"data"` }
InteractionResponse https://discord.com/developers/docs/interactions/slash-commands#interaction-response
type InteractionResponseType ¶
type InteractionResponseType int
InteractionResponseType (IRT)
const ( PongIRT InteractionResponseType = iota + 1 ChannelMessageWithSourceIRT DeferredChannelMessageWithSourceIRT )
type InteractionType ¶
type InteractionType int
InteractionType (IT)
const ( PingIT InteractionType = iota + 1 ApplicationCommandIT )
https://discord.com/developers/docs/interactions/slash-commands#interaction-interactiontype
type Member ¶
type Member struct { User *User `json:"user"` Nick string `json:"nick"` Roles []string `json:"roles"` JoinedAt string `json:"joined_at"` PremiumSince string `json:"premium_since"` Deaf bool `json:"deaf"` Mute bool `json:"mute"` Pending bool `json:"pending"` Permissions string `json:"permissions"` }
Member https://discord.com/developers/docs/resources/guild#guild-member-object
type PremiumType ¶
type PremiumType int
PremiumType (PT)
const ( NonePT PremiumType = iota NitroClassic Nitro )
https://discord.com/developers/docs/resources/user#user-object-premium-types
type User ¶
type User struct { ID string `json:"id"` Username string `json:"username"` Discriminator string `json:"discriminator"` Avatar string `json:"avatar"` Bot bool `json:"bot"` System bool `json:"system"` MFAEnabled bool `json:"mfa_enabled"` Locale string `json:"locale"` Verified bool `json:"verified"` Email string `json:"email"` Flags UserFlags `json:"flags"` PremiumType PremiumType `json:"premium_type"` PublicFlags UserFlags `json:"public_flags"` }
User https://discord.com/developers/docs/resources/user#user-object
type UserFlags ¶
type UserFlags int
UserFlags (UF)
const ( NoneUF UserFlags = 0 DiscordEmployeeUF UserFlags = 1 << iota PartneredServerOwnerUF HypeSquadEventsUF BugHunterLevel1UF HouseBraveryUF HouseBrillianceUF HouseBalanceUF EarlySupporterUF TeamUserUF SystemUF BugHunterLevel2UF VerifiedBotUF EarlyVerifiedBotDeveloperUF )
https://discord.com/developers/docs/resources/user#user-object-user-flags