1
0
Fork 0
mirror of https://github.com/diamondburned/arikawa.git synced 2025-01-05 19:57:02 +00:00

Discord: typed snowflake for Interaction

This commit is contained in:
diamondburned 2021-02-17 17:41:19 -08:00
parent 65d7b8765b
commit 968112fb53
3 changed files with 24 additions and 10 deletions

View file

@ -34,7 +34,7 @@ type InteractionResponseData struct {
// RespondInteraction responds to an incoming interaction. It is also known as
// an "interaction callback".
func (c *Client) RespondInteraction(
id discord.Snowflake, token string, data InteractionResponse) error {
id discord.InteractionID, token string, data InteractionResponse) error {
return c.FastRequest(
"POST",

View file

@ -193,6 +193,20 @@ func (s IntegrationID) Worker() uint8 { return Snowflake(s).Work
func (s IntegrationID) PID() uint8 { return Snowflake(s).PID() }
func (s IntegrationID) Increment() uint16 { return Snowflake(s).Increment() }
type InteractionID Snowflake
const NullInteractionID = InteractionID(NullSnowflake)
func (s InteractionID) MarshalJSON() ([]byte, error) { return Snowflake(s).MarshalJSON() }
func (s *InteractionID) UnmarshalJSON(v []byte) error { return (*Snowflake)(s).UnmarshalJSON(v) }
func (s InteractionID) String() string { return Snowflake(s).String() }
func (s InteractionID) IsValid() bool { return Snowflake(s).IsValid() }
func (s InteractionID) IsNull() bool { return Snowflake(s).IsNull() }
func (s InteractionID) Time() time.Time { return Snowflake(s).Time() }
func (s InteractionID) Worker() uint8 { return Snowflake(s).Worker() }
func (s InteractionID) PID() uint8 { return Snowflake(s).PID() }
func (s InteractionID) Increment() uint16 { return Snowflake(s).Increment() }
type GuildID Snowflake
const NullGuildID = GuildID(NullSnowflake)

View file

@ -371,14 +371,14 @@ type (
// https://discord.com/developers/docs/topics/gateway#interactions
type (
InteractionCreateEvent struct {
ID discord.Snowflake `json:"id"`
Type InteractionType `json:"type"`
Data InteractionData `json:"data"`
GuildID discord.GuildID `json:"guild_id"`
ChannelID discord.ChannelID `json:"channel_id"`
Member discord.Member `json:"member"`
Token string `json:"token"`
Version int `json:"version"`
ID discord.InteractionID `json:"id"`
Type InteractionType `json:"type"`
Data InteractionData `json:"data"`
GuildID discord.GuildID `json:"guild_id"`
ChannelID discord.ChannelID `json:"channel_id"`
Member discord.Member `json:"member"`
Token string `json:"token"`
Version int `json:"version"`
}
)
@ -390,7 +390,7 @@ const (
)
type InteractionData struct {
ID discord.Snowflake `json:"id"`
ID discord.CommandID `json:"id"`
Name string `json:"name"`
Options []InteractionOption `json:"options"`
}