Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Invite Create/Delete #1105

Merged
merged 6 commits into from Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
48 changes: 48 additions & 0 deletions eventhandlers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions events.go
Expand Up @@ -341,3 +341,17 @@ type InteractionCreate struct {
func (i *InteractionCreate) UnmarshalJSON(b []byte) error {
return json.Unmarshal(b, &i.Interaction)
}

// InviteCreate is the data for a InviteCreate event
type InviteCreate struct {
*Invite
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
}

// InviteDelete is the data for a InviteDelete event
type InviteDelete struct {
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
Code string `json:"code"`
}
45 changes: 23 additions & 22 deletions structs.go
Expand Up @@ -191,36 +191,37 @@ type ICEServer struct {
Credential string `json:"credential"`
}

// InviteTargetType indicates the type of target of an invite
// https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types
type InviteTargetType uint8

// Invite target types
const (
InviteTargetStream InviteTargetType = 1
InviteTargetEmbeddedAppliction InviteTargetType = 2
)

// A Invite stores all data related to a specific Discord Guild or Channel invite.
type Invite struct {
Guild *Guild `json:"guild"`
Channel *Channel `json:"channel"`
Inviter *User `json:"inviter"`
Code string `json:"code"`
CreatedAt time.Time `json:"created_at"`
MaxAge int `json:"max_age"`
Uses int `json:"uses"`
MaxUses int `json:"max_uses"`
Revoked bool `json:"revoked"`
Temporary bool `json:"temporary"`
Unique bool `json:"unique"`
TargetUser *User `json:"target_user"`
TargetUserType TargetUserType `json:"target_user_type"`
FedorLap2006 marked this conversation as resolved.
Show resolved Hide resolved
Guild *Guild `json:"guild"`
Channel *Channel `json:"channel"`
Inviter *User `json:"inviter"`
Code string `json:"code"`
CreatedAt time.Time `json:"created_at"`
MaxAge int `json:"max_age"`
Uses int `json:"uses"`
MaxUses int `json:"max_uses"`
Revoked bool `json:"revoked"`
Temporary bool `json:"temporary"`
Unique bool `json:"unique"`
TargetUser *User `json:"target_user"`
TargetUserType InviteTargetType `json:"target_type"`
FedorLap2006 marked this conversation as resolved.
Show resolved Hide resolved

// will only be filled when using InviteWithCounts
ApproximatePresenceCount int `json:"approximate_presence_count"`
ApproximateMemberCount int `json:"approximate_member_count"`
}

// TargetUserType is the type of the target user
// https://discord.com/developers/docs/resources/invite#invite-object-target-user-types
type TargetUserType int

// Block contains known TargetUserType values
const (
TargetUserTypeStream TargetUserType = 1
)

// ChannelType is the type of a Channel
type ChannelType int

Expand Down