mirror of
https://github.com/diamondburned/arikawa.git
synced 2025-02-12 22:43:32 +00:00
Discord: add missing fields to Guild struct
This commit is contained in:
parent
9da01cccb3
commit
f4be7971ee
225
discord/guild.go
225
discord/guild.go
|
@ -1,57 +1,123 @@
|
||||||
package discord
|
package discord
|
||||||
|
|
||||||
type Guild struct {
|
type Guild struct {
|
||||||
ID Snowflake `json:"id,string"`
|
// ID is the guild id.
|
||||||
Name string `json:"name"`
|
ID Snowflake `json:"id,string"`
|
||||||
Icon Hash `json:"icon"`
|
// Name is the guild name (2-100 characters, excluding trailing and leading
|
||||||
Splash Hash `json:"splash,omitempty"` // server invite bg
|
// whitespace).
|
||||||
|
Name string `json:"name"`
|
||||||
|
// Icon is the icon hash.&nullableUint64{}
|
||||||
|
Icon Hash `json:"icon"`
|
||||||
|
// Splash is the splash hash.
|
||||||
|
Splash Hash `json:"splash,omitempty"`
|
||||||
|
// DiscoverySplash is the discovery splash hash.
|
||||||
|
//
|
||||||
|
// Only present for guilds with the "DISCOVERABLE" feature.
|
||||||
|
DiscoverySplash Hash `json:"discovery_splash,omitempty"`
|
||||||
|
|
||||||
Owner bool `json:"owner,omitempty"` // self is owner
|
// Owner is true if the user is the owner of the guild.
|
||||||
|
Owner bool `json:"owner,omitempty"`
|
||||||
|
// OwnerID is the id of owner.
|
||||||
OwnerID Snowflake `json:"owner_id,string"`
|
OwnerID Snowflake `json:"owner_id,string"`
|
||||||
|
|
||||||
|
// Permissions are the total permissions for the user in the guild
|
||||||
|
// (excludes overrides).
|
||||||
Permissions Permissions `json:"permissions,omitempty"`
|
Permissions Permissions `json:"permissions,omitempty"`
|
||||||
|
|
||||||
|
// VoiceRegion is the voice region id for the guild.
|
||||||
VoiceRegion string `json:"region"`
|
VoiceRegion string `json:"region"`
|
||||||
|
|
||||||
|
// AFKChannelID is the id of the afk channel.
|
||||||
AFKChannelID Snowflake `json:"afk_channel_id,string,omitempty"`
|
AFKChannelID Snowflake `json:"afk_channel_id,string,omitempty"`
|
||||||
AFKTimeout Seconds `json:"afk_timeout"`
|
// AFKTimeout is the afk timeout in seconds.
|
||||||
|
AFKTimeout Seconds `json:"afk_timeout"`
|
||||||
|
|
||||||
Embeddable bool `json:"embed_enabled,omitempty"`
|
// Embeddable is true if the server widget is enabled.
|
||||||
|
//
|
||||||
|
// Deprecated: replaced with WidgetEnabled
|
||||||
|
Embeddable bool `json:"embed_enabled,omitempty"`
|
||||||
|
// EmbedChannelID is the channel id that the widget will generate an invite
|
||||||
|
// to, or null if set to no invite .
|
||||||
|
//
|
||||||
|
// Deprecated: replaced with WidgetChannelID
|
||||||
EmbedChannelID Snowflake `json:"embed_channel_id,string,omitempty"`
|
EmbedChannelID Snowflake `json:"embed_channel_id,string,omitempty"`
|
||||||
|
|
||||||
Verification Verification `json:"verification_level"`
|
// Verification is the verification level required for the guild.
|
||||||
Notification Notification `json:"default_message_notifications"`
|
Verification Verification `json:"verification_level"`
|
||||||
|
// Notification is the default message notifications level.
|
||||||
|
Notification Notification `json:"default_message_notifications"`
|
||||||
|
// ExplicitFilter is the explicit content filter level.
|
||||||
ExplicitFilter ExplicitFilter `json:"explicit_content_filter"`
|
ExplicitFilter ExplicitFilter `json:"explicit_content_filter"`
|
||||||
|
|
||||||
Roles []Role `json:"roles"`
|
// Roles are the roles in the guild.
|
||||||
Emojis []Emoji `json:"emojis"`
|
Roles []Role `json:"roles"`
|
||||||
|
// Emojis are the custom guild emojis.
|
||||||
|
Emojis []Emoji `json:"emojis"`
|
||||||
|
// Features are the enabled guild features.
|
||||||
Features []GuildFeature `json:"guild_features"`
|
Features []GuildFeature `json:"guild_features"`
|
||||||
|
|
||||||
|
// MFA is the required MFA level for the guild.
|
||||||
MFA MFALevel `json:"mfa"`
|
MFA MFALevel `json:"mfa"`
|
||||||
|
|
||||||
|
// AppID is the application id of the guild creator if it is bot-created.
|
||||||
|
//
|
||||||
|
// This field is nullable.
|
||||||
AppID Snowflake `json:"application_id,string,omitempty"`
|
AppID Snowflake `json:"application_id,string,omitempty"`
|
||||||
|
|
||||||
Widget bool `json:"widget_enabled,omitempty"`
|
// WidgetEnabled is true if the server widget is enabled.
|
||||||
|
WidgetEnabled bool `json:"widget_enabled,omitempty"`
|
||||||
|
// WidgetChannelID is the channel id that the widget will generate an
|
||||||
|
// invite to, or null if set to no invite.
|
||||||
WidgetChannelID Snowflake `json:"widget_channel_id,string,omitempty"`
|
WidgetChannelID Snowflake `json:"widget_channel_id,string,omitempty"`
|
||||||
|
|
||||||
|
// SystemChannelID is the the id of the channel where guild notices such as
|
||||||
|
// welcome messages and boost events are posted.
|
||||||
SystemChannelID Snowflake `json:"system_channel_id,string,omitempty"`
|
SystemChannelID Snowflake `json:"system_channel_id,string,omitempty"`
|
||||||
|
// SystemChannelFlags are the system channel flags.
|
||||||
|
SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"`
|
||||||
|
|
||||||
// It's DefaultMaxPresences when MaxPresences is 0.
|
// RulesChannelID is the id of the channel where guilds with the "PUBLIC"
|
||||||
|
// feature can display rules and/or guidelines.
|
||||||
|
RulesChannelID Snowflake `json:"rules_channel_id"`
|
||||||
|
|
||||||
|
// MaxPresences is the maximum number of presences for the guild (the
|
||||||
|
// default value, currently 25000, is in effect when null is returned, so
|
||||||
|
// effectively when this field is 0).
|
||||||
MaxPresences uint64 `json:"max_presences,omitempty"`
|
MaxPresences uint64 `json:"max_presences,omitempty"`
|
||||||
MaxMembers uint64 `json:"max_members,omitempty"`
|
// MaxMembers the maximum number of members for the guild.
|
||||||
|
MaxMembers uint64 `json:"max_members,omitempty"`
|
||||||
|
|
||||||
|
// VanityURL is the the vanity url code for the guild.
|
||||||
VanityURLCode string `json:"vanity_url_code,omitempty"`
|
VanityURLCode string `json:"vanity_url_code,omitempty"`
|
||||||
Description string `json:"description,omitempty"`
|
// Description is the description for the guild, if the guild is
|
||||||
Banner Hash `json:"banner,omitempty"`
|
// discoverable.
|
||||||
|
Description string `json:"description,omitempty"`
|
||||||
|
|
||||||
NitroBoost NitroBoost `json:"premium_tier"`
|
// Banner is the banner hash.
|
||||||
NitroBoosters uint64 `json:"premium_subscription_count,omitempty"`
|
Banner Hash `json:"banner,omitempty"`
|
||||||
|
|
||||||
// Defaults to en-US, only set if guild has DISCOVERABLE
|
// NitroBoost is the premium tier (Server Boost level).
|
||||||
|
NitroBoost NitroBoost `json:"premium_tier"`
|
||||||
|
// NitroBoosters is the number of boosts this guild currently has.
|
||||||
|
NitroBoosters uint64 `json:"premium_subscription_count,omitempty"`
|
||||||
|
|
||||||
|
// PreferredLocale is the the preferred locale of a guild with the "PUBLIC"
|
||||||
|
// feature; used in server discovery and notices from Discord. Defaults to
|
||||||
|
// "en-US".
|
||||||
PreferredLocale string `json:"preferred_locale"`
|
PreferredLocale string `json:"preferred_locale"`
|
||||||
|
|
||||||
// Only presented if WithCounts is true.
|
// PublicUpdatesChannelID is the id of the channel where admins and
|
||||||
ApproximateMembers uint64 `json:"approximate_member_count,omitempty"`
|
// moderators of guilds with the "PUBLIC" feature receive notices from
|
||||||
|
// Discord.
|
||||||
|
PublicUpdatesChannelID Snowflake `json:"public_updates_channel_id"`
|
||||||
|
|
||||||
|
// MaxVideoChannelUsers is the maximum amount of users in a video channel.
|
||||||
|
MaxVideoChannelUsers uint64 `json:"max_video_channel_users,omitempty"`
|
||||||
|
|
||||||
|
// ApproximateMembers is the approximate number of members in this guild, returned from the GET /guild/<id> endpoint when with_counts is true
|
||||||
|
ApproximateMembers uint64 `json:"approximate_member_count,omitempty"`
|
||||||
|
// ApproximatePresences is the approximate number of non-offline members in
|
||||||
|
// this guild, returned by the GuildWithCount method.
|
||||||
ApproximatePresences uint64 `json:"approximate_presence_count,omitempty"`
|
ApproximatePresences uint64 `json:"approximate_presence_count,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,85 +277,146 @@ func (g GuildPreview) DiscoverySplashURLWithType(t ImageType) string {
|
||||||
g.ID.String() + "/" + t.format(g.Splash)
|
g.ID.String() + "/" + t.format(g.Splash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/topics/permissions#role-object
|
||||||
type Role struct {
|
type Role struct {
|
||||||
ID Snowflake `json:"id,string"`
|
// ID is the role id.
|
||||||
Name string `json:"name"`
|
ID Snowflake `json:"id,string"`
|
||||||
|
// Name is the role name.
|
||||||
|
Name string `json:"name"`
|
||||||
|
|
||||||
Color Color `json:"color"`
|
// Color is the integer representation of hexadecimal color code.
|
||||||
Hoist bool `json:"hoist"` // if the role is separated
|
Color Color `json:"color"`
|
||||||
Position int `json:"position"`
|
// Hoist specifies if this role is pinned in the user listing.
|
||||||
|
Hoist bool `json:"hoist"`
|
||||||
|
// Position is the position of this role.
|
||||||
|
Position int `json:"position"`
|
||||||
|
|
||||||
|
// Permissions is the permission bit set.
|
||||||
Permissions Permissions `json:"permissions"`
|
Permissions Permissions `json:"permissions"`
|
||||||
|
|
||||||
Managed bool `json:"managed"`
|
// Manages specifies whether this role is managed by an integration.
|
||||||
|
Managed bool `json:"managed"`
|
||||||
|
// Mentionable specifies whether this role is mentionable.
|
||||||
Mentionable bool `json:"mentionable"`
|
Mentionable bool `json:"mentionable"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mention returns the mention of the Role.
|
||||||
func (r Role) Mention() string {
|
func (r Role) Mention() string {
|
||||||
return "<&" + r.ID.String() + ">"
|
return "<&" + r.ID.String() + ">"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/topics/gateway#presence-update
|
||||||
type Presence struct {
|
type Presence struct {
|
||||||
User User `json:"user"`
|
// User is the user presence is being updated for.
|
||||||
|
User User `json:"user"`
|
||||||
|
// RoleIDs are the roles this user is in.
|
||||||
RoleIDs []Snowflake `json:"roles"`
|
RoleIDs []Snowflake `json:"roles"`
|
||||||
|
|
||||||
// These fields are only filled in gateway events, according to the
|
// These fields are only filled in gateway events, according to the
|
||||||
// documentation.
|
// documentation.
|
||||||
|
|
||||||
Nick string `json:"nick"`
|
// Game is null, or the user's current activity.
|
||||||
|
Game *Activity `json:"game"`
|
||||||
|
|
||||||
|
// GuildID is the id of the guild
|
||||||
GuildID Snowflake `json:"guild_id"`
|
GuildID Snowflake `json:"guild_id"`
|
||||||
|
|
||||||
PremiumSince Timestamp `json:"premium_since,omitempty"`
|
// Status is either "idle", "dnd", "online", or "offline".
|
||||||
|
Status Status `json:"status"`
|
||||||
Game *Activity `json:"game"`
|
// Activities are the user's current activities.
|
||||||
Activities []Activity `json:"activities"`
|
Activities []Activity `json:"activities"`
|
||||||
|
// ClientStaus is the user's platform-dependent status.
|
||||||
Status Status `json:"status"`
|
//
|
||||||
|
// https://discord.com/developers/docs/topics/gateway#client-status-object
|
||||||
ClientStatus struct {
|
ClientStatus struct {
|
||||||
|
// Desktop is the user's status set for an active desktop (Windows,
|
||||||
|
// Linux, Mac) application session.
|
||||||
Desktop Status `json:"desktop,omitempty"`
|
Desktop Status `json:"desktop,omitempty"`
|
||||||
Mobile Status `json:"mobile,omitempty"`
|
// Mobile is the user's status set for an active mobile (iOS, Android)
|
||||||
Web Status `json:"web,omitempty"`
|
// application session.
|
||||||
|
Mobile Status `json:"mobile,omitempty"`
|
||||||
|
// Web is the user's status set for an active web (browser, bot
|
||||||
|
// account) application session.
|
||||||
|
Web Status `json:"web,omitempty"`
|
||||||
} `json:"client_status"`
|
} `json:"client_status"`
|
||||||
|
// Premium since specifies when the user started boosting the guild.
|
||||||
|
PremiumSince Timestamp `json:"premium_since,omitempty"`
|
||||||
|
// Nick is this users guild nickname (if one is set).
|
||||||
|
Nick string `json:"nick,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/guild#guild-member-object
|
||||||
|
//
|
||||||
|
// The field user won't be included in the member object attached to
|
||||||
|
// MESSAGE_CREATE and MESSAGE_UPDATE gateway events.
|
||||||
type Member struct {
|
type Member struct {
|
||||||
User User `json:"user"`
|
// User is the user this guild member represents.
|
||||||
Nick string `json:"nick,omitempty"`
|
User User `json:"user"`
|
||||||
|
// Nick is this users guild nickname.
|
||||||
|
Nick string `json:"nick,omitempty"`
|
||||||
|
// RoleIDs is an array of role object ids.
|
||||||
RoleIDs []Snowflake `json:"roles"`
|
RoleIDs []Snowflake `json:"roles"`
|
||||||
|
|
||||||
Joined Timestamp `json:"joined_at"`
|
// Joined specifies when the user joined the guild.
|
||||||
|
Joined Timestamp `json:"joined_at"`
|
||||||
|
// BoostedSince specifies when the user started boosting the guild.
|
||||||
BoostedSince Timestamp `json:"premium_since,omitempty"`
|
BoostedSince Timestamp `json:"premium_since,omitempty"`
|
||||||
|
|
||||||
|
// Deaf specifies whether the user is deafened in voice channels.
|
||||||
Deaf bool `json:"deaf"`
|
Deaf bool `json:"deaf"`
|
||||||
|
// Mute specifies whether the user is muted in voice channels.
|
||||||
Mute bool `json:"mute"`
|
Mute bool `json:"mute"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mention returns the mention of the role.
|
||||||
func (m Member) Mention() string {
|
func (m Member) Mention() string {
|
||||||
return "<@!" + m.User.ID.String() + ">"
|
return "<@!" + m.User.ID.String() + ">"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/guild#ban-object
|
||||||
type Ban struct {
|
type Ban struct {
|
||||||
|
// Reason is the reason for the ban.
|
||||||
Reason string `json:"reason,omitempty"`
|
Reason string `json:"reason,omitempty"`
|
||||||
User User `json:"user"`
|
// User is the banned user.
|
||||||
|
User User `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://discord.com/developers/docs/resources/guild#integration-object
|
||||||
type Integration struct {
|
type Integration struct {
|
||||||
ID Snowflake `json:"id"`
|
// ID is the integration id.
|
||||||
Name string `json:"name"`
|
ID Snowflake `json:"id"`
|
||||||
Type Service `json:"type"`
|
// Name is the integration name.
|
||||||
|
Name string `json:"name"`
|
||||||
|
// Type is the integration type (twitch, youtube, etc).
|
||||||
|
Type Service `json:"type"`
|
||||||
|
|
||||||
|
// Enables specifies if the integration is enabled.
|
||||||
Enabled bool `json:"enabled"`
|
Enabled bool `json:"enabled"`
|
||||||
|
// Syncing specifies if the integration is syncing.
|
||||||
Syncing bool `json:"syncing"`
|
Syncing bool `json:"syncing"`
|
||||||
|
|
||||||
// used for subscribers
|
// RoleID is the id that this integration uses for "subscribers".
|
||||||
RoleID Snowflake `json:"role_id"`
|
RoleID Snowflake `json:"role_id"`
|
||||||
|
|
||||||
ExpireBehavior ExpireBehavior `json:"expire_behavior"`
|
// EnableEmoticons specifies whether emoticons should be synced for this
|
||||||
ExpireGracePeriod int `json:"expire_grace_period"`
|
// integration (twitch only currently).
|
||||||
|
EnableEmoticons bool `json:"enable_emoticons,omitempty"`
|
||||||
|
|
||||||
User User `json:"user"`
|
// ExpireBehavior is the behavior of expiring subscribers
|
||||||
|
ExpireBehavior ExpireBehavior `json:"expire_behavior"`
|
||||||
|
// ExpireGracePeriod is the grace period (in days) before expiring
|
||||||
|
// subscribers.
|
||||||
|
ExpireGracePeriod int `json:"expire_grace_period"`
|
||||||
|
|
||||||
|
// User is the user for this integration.
|
||||||
|
User User `json:"user"`
|
||||||
|
// Account is the integration account information.
|
||||||
|
//
|
||||||
|
// https://discord.com/developers/docs/resources/guild#integration-account-object
|
||||||
Account struct {
|
Account struct {
|
||||||
ID string `json:"id"`
|
// ID is the id of the account.
|
||||||
|
ID string `json:"id"`
|
||||||
|
// Name is the name of the account.
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
} `json:"account"`
|
} `json:"account"`
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue