interactions

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EndpointApplicationNoOauth       = func(aID string) string { return discordgo.EndpointAPI + "/applications/" + aID }
	EndpointApplicationCommands      = func(aID string) string { return EndpointApplicationNoOauth(aID) + "/commands" }
	EndpointApplicationGuildCommands = func(aID string, gID string) string {
		return EndpointApplicationNoOauth(aID) + "/guilds/" + gID + "/commands"
	}
	EndpointInteractionResponse = func(iID string, iToken string) string {
		return discordgo.EndpointAPI + "/interactions/" + iID + "/" + iToken + "/callback"
	}
)

Functions

func GlobalCommandCreate

func GlobalCommandCreate(s *discordgo.Session, aID string, command Command) (err error)

GlobalCommandCreate returns an error, it posts your command to all servers your bot is in.

func GuildCommandCreate

func GuildCommandCreate(s *discordgo.Session, aID string, gID string, command Command) (err error)

GuildCommandCreate returns an error, it posts your command to specified guild.

Types

type Command

type Command struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	Options     []CommandOption `json:"options,omitempty"`
}

Command structure

type CommandOption

type CommandOption struct {
	Type        CommandOptionType     `json:"type"`
	Name        string                `json:"name"`
	Description string                `json:"description"`
	Default     bool                  `json:"default"`
	Required    bool                  `json:"required"`
	Choices     []CommandOptionChoice `json:"choices,omitempty"`
	Options     []CommandOption       `json:"options,omitempty"`
}

CommandOption structure

type CommandOptionChoice

type CommandOptionChoice struct {
	Name  string      `json:"name"`
	Value interface{} `json:"value"`
}

CommandOptionChoice structure

type CommandOptionType

type CommandOptionType int

CommandOptionType int

const (
	OptionTypeSubCommand CommandOptionType = iota + 1
	OptionTypeSubCommandGroup
	OptionTypeString
	OptionTypeInteger
	OptionTypeBoolean
	OptionTypeUser
	OptionTypeChannel
	OptionTypeRole
)

type Interaction

type Interaction struct {
	ID        string           `json:"id"`
	Type      InteractionType  `json:"type"`
	Data      InteractionData  `json:"data"`
	GuildID   string           `json:"guild_id"`
	ChannelID string           `json:"channel_id"`
	Member    discordgo.Member `json:"member"`
	Token     string           `json:"token"`
	Version   int              `json:"version"`
}

Interaction structure

func InteractionFromRaw

func InteractionFromRaw(raw json.RawMessage) (inter Interaction, err error)

InteractionFromRaw is a function to get interaction from raw data

func (*Interaction) Respond

func (interaction *Interaction) Respond(s *discordgo.Session, resp InteractionResponse) (err error)

Respond send a response to interaction, returns to error

type InteractionData

type InteractionData struct {
	ID      string                  `json:"id"`
	Name    string                  `json:"name"`
	Options []InteractionDataOption `json:"options"`
}

InteractionData structure

type InteractionDataOption

type InteractionDataOption struct {
	Name    string                  `json:"name"`
	Value   interface{}             `json:"value"`
	Options []InteractionDataOption `json:"options"`
}

InteractionDataOption structure

type InteractionResponse

type InteractionResponse struct {
	Type InteractionResponseType `json:"type"`
	Data InteractionResponseData `json:"data,omitempty"`
}

InteractionResponse structure

type InteractionResponseData

type InteractionResponseData struct {
	TTS             bool                         `json:"tts"`
	Content         string                       `json:"content"`
	Embeds          []discordgo.MessageEmbed     `json:"embeds,omitempty"`
	AllowedMentions discordgo.AllowedMentionType `json:"allowed_mentions,omitempty"`
}

InteractionResponseData structure

type InteractionResponseType

type InteractionResponseType int

InteractionResponseType int

const (
	InteractionResponseTypePong InteractionResponseType = iota + 1
	InteractionResponseTypeAcknowledge
	InteractionResponseTypeChannelMessage
	InteractionResponseTypeChannelMessageWithSource
	InteractionResponseTypeACKWithSource
)

type InteractionType

type InteractionType int

InteractionType int

const (
	InteractionTypePing InteractionType = iota + 1
	InteractionTypeApplicationCommand
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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