Documentation
¶
Index ¶
- Constants
- type API
- type ApplicationCommand
- type ApplicationCommandOption
- type ApplicationCommandOptionChoice
- type Client
- func (c *Client) BotUser() *User
- func (c *Client) Close() error
- func (c *Client) OnInteraction(handler func(*Interaction))
- func (c *Client) Open() error
- func (c *Client) RegisterCommands(commands []*ApplicationCommand) error
- func (c *Client) RespondToInteraction(interactionID, interactionToken string, response *InteractionResponse) error
- type Gateway
- type GatewayBotResponse
- type GatewayPayload
- type HelloData
- type IdentifyData
- type IdentifyProperties
- type Interaction
- type InteractionData
- type InteractionDataOption
- type InteractionResponse
- type InteractionResponseData
- type MessageEmbed
- type MessageEmbedField
- type MessageEmbedFooter
- type ReadyData
- type ResumeData
- type User
Constants ¶
const ( OpcodeDispatch = 0 OpcodeHeartbeat = 1 OpcodeIdentify = 2 OpcodePresenceUpdate = 3 OpcodeVoiceStateUpdate = 4 OpcodeResume = 6 OpcodeReconnect = 7 OpcodeRequestGuildMembers = 8 OpcodeInvalidSession = 9 OpcodeHello = 10 OpcodeHeartbeatACK = 11 )
const ( InteractionTypePing = 1 InteractionTypeApplicationCommand = 2 InteractionTypeMessageComponent = 3 InteractionTypeAutocomplete = 4 InteractionTypeModalSubmit = 5 )
InteractionType 定数
const ( InteractionCallbackPong = 1 InteractionCallbackChannelMessageWithSource = 4 InteractionCallbackDeferredChannelMessage = 5 InteractionCallbackDeferredUpdateMessage = 6 InteractionCallbackUpdateMessage = 7 )
InteractionCallbackType 定数
const ( OptionTypeSubCommand = 1 OptionTypeSubCommandGroup = 2 OptionTypeString = 3 OptionTypeInteger = 4 OptionTypeBoolean = 5 OptionTypeUser = 6 OptionTypeChannel = 7 OptionTypeRole = 8 OptionTypeMentionable = 9 OptionTypeNumber = 10 )
ApplicationCommandOptionType 定数
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API はDiscord APIクライアント
func (*API) BulkOverwriteGlobalCommands ¶
func (r *API) BulkOverwriteGlobalCommands(appID string, commands []*ApplicationCommand) ([]*ApplicationCommand, error)
BulkOverwriteGlobalCommands はグローバルコマンドを一括登録する
func (*API) CreateInteractionResponse ¶
func (r *API) CreateInteractionResponse(interactionID, interactionToken string, response *InteractionResponse) error
CreateInteractionResponse はインタラクションに応答する
func (*API) GetGatewayBot ¶
func (r *API) GetGatewayBot() (*GatewayBotResponse, error)
GetGatewayBot は Gateway Bot URL を取得する
type ApplicationCommand ¶
type ApplicationCommand struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Description string `json:"description"`
Options []*ApplicationCommandOption `json:"options,omitempty"`
}
ApplicationCommand はスラッシュコマンド定義
type ApplicationCommandOption ¶
type ApplicationCommandOption struct {
Name string `json:"name"`
Description string `json:"description"`
Type int `json:"type"`
Required bool `json:"required,omitempty"`
Options []*ApplicationCommandOption `json:"options,omitempty"`
Choices []*ApplicationCommandOptionChoice `json:"choices,omitempty"`
}
ApplicationCommandOption はコマンドオプション定義
type ApplicationCommandOptionChoice ¶
type ApplicationCommandOptionChoice struct {
Name string `json:"name"`
Value interface{} `json:"value"`
}
ApplicationCommandOptionChoice はオプションの選択肢
type Client ¶
Client はDiscord API統合クライアント
func (*Client) OnInteraction ¶
func (c *Client) OnInteraction(handler func(*Interaction))
OnInteraction はインタラクションハンドラーを登録する
func (*Client) RegisterCommands ¶
func (c *Client) RegisterCommands(commands []*ApplicationCommand) error
RegisterCommands はスラッシュコマンドを一括登録する
func (*Client) RespondToInteraction ¶
func (c *Client) RespondToInteraction(interactionID, interactionToken string, response *InteractionResponse) error
RespondToInteraction はインタラクションに応答する
type Gateway ¶
type Gateway struct {
// contains filtered or unexported fields
}
Gateway はDiscord Gateway WebSocket接続を管理する
func NewGateway ¶
NewGateway は新しいGatewayを作成する
type GatewayBotResponse ¶
GatewayBotResponse は GET /gateway/bot のレスポンス
type GatewayPayload ¶
type GatewayPayload struct {
Op int `json:"op"`
D json.RawMessage `json:"d,omitempty"`
S *int64 `json:"s,omitempty"`
T string `json:"t,omitempty"`
}
GatewayPayload はGateway WebSocketのメッセージ
type HelloData ¶
type HelloData struct {
HeartbeatInterval int `json:"heartbeat_interval"`
}
HelloData は opcode 10 (Hello) のデータ
type IdentifyData ¶
type IdentifyData struct {
Token string `json:"token"`
Intents int `json:"intents"`
Properties IdentifyProperties `json:"properties"`
}
IdentifyData は opcode 2 (Identify) のデータ
type IdentifyProperties ¶
type IdentifyProperties struct {
OS string `json:"os"`
Browser string `json:"browser"`
Device string `json:"device"`
}
IdentifyProperties はIdentifyのプロパティ
type Interaction ¶
type Interaction struct {
ID string `json:"id"`
Type int `json:"type"`
Token string `json:"token"`
GuildID string `json:"guild_id,omitempty"`
ChannelID string `json:"channel_id,omitempty"`
Data *InteractionData `json:"data,omitempty"`
AppID string `json:"application_id,omitempty"`
}
Interaction はDiscordインタラクションを表す
type InteractionData ¶
type InteractionData struct {
ID string `json:"id"`
Name string `json:"name"`
Options []*InteractionDataOption `json:"options,omitempty"`
}
InteractionData はインタラクションのデータ
type InteractionDataOption ¶
type InteractionDataOption struct {
Name string `json:"name"`
Type int `json:"type"`
Value interface{} `json:"value,omitempty"`
Options []*InteractionDataOption `json:"options,omitempty"`
}
InteractionDataOption はインタラクションオプション
func (*InteractionDataOption) IntValue ¶
func (o *InteractionDataOption) IntValue() int64
IntValue はオプションの整数値を返す
func (*InteractionDataOption) StringValue ¶
func (o *InteractionDataOption) StringValue() string
StringValue はオプションの文字列値を返す
type InteractionResponse ¶
type InteractionResponse struct {
Type int `json:"type"`
Data *InteractionResponseData `json:"data,omitempty"`
}
InteractionResponse はインタラクションレスポンス
type InteractionResponseData ¶
type InteractionResponseData struct {
Content string `json:"content,omitempty"`
Embeds []*MessageEmbed `json:"embeds,omitempty"`
}
InteractionResponseData はインタラクションレスポンスのデータ
type MessageEmbed ¶
type MessageEmbed struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Color int `json:"color,omitempty"`
Fields []*MessageEmbedField `json:"fields,omitempty"`
}
MessageEmbed はメッセージ埋め込み
type MessageEmbedField ¶
type MessageEmbedField struct {
Name string `json:"name"`
Value string `json:"value"`
Inline bool `json:"inline,omitempty"`
}
MessageEmbedField は埋め込みフィールド
type ReadyData ¶
type ReadyData struct {
V int `json:"v"`
User User `json:"user"`
SessionID string `json:"session_id"`
ResumeURL string `json:"resume_gateway_url"`
}
ReadyData は READY イベントのデータ
type ResumeData ¶
type ResumeData struct {
Token string `json:"token"`
SessionID string `json:"session_id"`
Seq int64 `json:"seq"`
}
ResumeData は opcode 6 (Resume) のデータ