2020-01-02 19:53:08 +00:00
|
|
|
package discord
|
|
|
|
|
2020-05-22 12:02:18 +00:00
|
|
|
// https://discord.com/developers/docs/resources/guild#guild-object
|
2020-01-04 04:19:24 +00:00
|
|
|
type Guild struct {
|
2020-05-22 12:02:12 +00:00
|
|
|
// ID is the guild id.
|
2020-07-21 20:27:59 +00:00
|
|
|
ID GuildID `json:"id,string"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// Name is the guild name (2-100 characters, excluding trailing and leading
|
|
|
|
// 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"`
|
2020-01-02 19:53:08 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Owner is true if the user is the owner of the guild.
|
|
|
|
Owner bool `json:"owner,omitempty"`
|
|
|
|
// OwnerID is the id of owner.
|
2020-07-21 20:27:59 +00:00
|
|
|
OwnerID UserID `json:"owner_id,string"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Permissions are the total permissions for the user in the guild
|
|
|
|
// (excludes overrides).
|
2020-10-28 21:08:29 +00:00
|
|
|
Permissions Permissions `json:"permissions,omitempty,string"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// VoiceRegion is the voice region id for the guild.
|
2020-01-04 04:19:24 +00:00
|
|
|
VoiceRegion string `json:"region"`
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// AFKChannelID is the id of the afk channel.
|
2020-07-21 20:27:59 +00:00
|
|
|
AFKChannelID ChannelID `json:"afk_channel_id,string,omitempty"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// AFKTimeout is the afk timeout in seconds.
|
|
|
|
AFKTimeout Seconds `json:"afk_timeout"`
|
|
|
|
|
|
|
|
// Verification is the verification level required for the guild.
|
|
|
|
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.
|
2020-01-04 04:19:24 +00:00
|
|
|
ExplicitFilter ExplicitFilter `json:"explicit_content_filter"`
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Roles are the roles in the guild.
|
|
|
|
Roles []Role `json:"roles"`
|
|
|
|
// Emojis are the custom guild emojis.
|
|
|
|
Emojis []Emoji `json:"emojis"`
|
|
|
|
// Features are the enabled guild features.
|
2020-01-04 04:19:24 +00:00
|
|
|
Features []GuildFeature `json:"guild_features"`
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// MFA is the required MFA level for the guild.
|
2020-01-04 04:19:24 +00:00
|
|
|
MFA MFALevel `json:"mfa"`
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// AppID is the application id of the guild creator if it is bot-created.
|
|
|
|
//
|
|
|
|
// This field is nullable.
|
2020-07-21 20:27:59 +00:00
|
|
|
AppID AppID `json:"application_id,string,omitempty"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 14:22:33 +00:00
|
|
|
// Widget is true if the server widget is enabled.
|
|
|
|
Widget bool `json:"widget_enabled,omitempty"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// WidgetChannelID is the channel id that the widget will generate an
|
|
|
|
// invite to, or null if set to no invite.
|
2020-07-21 20:27:59 +00:00
|
|
|
WidgetChannelID ChannelID `json:"widget_channel_id,string,omitempty"`
|
2020-05-22 12:02:12 +00:00
|
|
|
|
|
|
|
// SystemChannelID is the the id of the channel where guild notices such as
|
|
|
|
// welcome messages and boost events are posted.
|
2020-07-21 20:27:59 +00:00
|
|
|
SystemChannelID ChannelID `json:"system_channel_id,string,omitempty"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// SystemChannelFlags are the system channel flags.
|
|
|
|
SystemChannelFlags SystemChannelFlags `json:"system_channel_flags"`
|
|
|
|
|
|
|
|
// RulesChannelID is the id of the channel where guilds with the "PUBLIC"
|
|
|
|
// feature can display rules and/or guidelines.
|
2020-07-21 20:27:59 +00:00
|
|
|
RulesChannelID ChannelID `json:"rules_channel_id"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// 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).
|
2020-01-04 04:19:24 +00:00
|
|
|
MaxPresences uint64 `json:"max_presences,omitempty"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// MaxMembers the maximum number of members for the guild.
|
|
|
|
MaxMembers uint64 `json:"max_members,omitempty"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// VanityURL is the the vanity url code for the guild.
|
2020-01-04 04:19:24 +00:00
|
|
|
VanityURLCode string `json:"vanity_url_code,omitempty"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// Description is the description for the guild, if the guild is
|
|
|
|
// discoverable.
|
|
|
|
Description string `json:"description,omitempty"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Banner is the banner hash.
|
|
|
|
Banner Hash `json:"banner,omitempty"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// 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".
|
2020-01-04 04:19:24 +00:00
|
|
|
PreferredLocale string `json:"preferred_locale"`
|
2020-05-09 21:59:39 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// PublicUpdatesChannelID is the id of the channel where admins and
|
|
|
|
// moderators of guilds with the "PUBLIC" feature receive notices from
|
|
|
|
// Discord.
|
2020-07-21 20:27:59 +00:00
|
|
|
PublicUpdatesChannelID ChannelID `json:"public_updates_channel_id"`
|
2020-05-22 12:02:12 +00:00
|
|
|
|
|
|
|
// 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.
|
2020-05-09 21:59:39 +00:00
|
|
|
ApproximatePresences uint64 `json:"approximate_presence_count,omitempty"`
|
2020-01-04 04:19:24 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 20:07:27 +00:00
|
|
|
// IconURL returns the URL to the guild icon and auto detects a suitable type.
|
|
|
|
// An empty string is returned if there's no icon.
|
2020-02-07 00:51:29 +00:00
|
|
|
func (g Guild) IconURL() string {
|
2020-05-15 20:07:27 +00:00
|
|
|
return g.IconURLWithType(AutoImage)
|
|
|
|
}
|
|
|
|
|
2020-05-23 17:17:30 +00:00
|
|
|
// IconURLWithType returns the URL to the guild icon using the passed
|
|
|
|
// ImageType. An empty string is returned if there's no icon.
|
2020-05-15 20:07:27 +00:00
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG, JPEG, WebP, GIF
|
|
|
|
func (g Guild) IconURLWithType(t ImageType) string {
|
2020-02-07 00:51:29 +00:00
|
|
|
if g.Icon == "" {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2020-05-15 20:07:27 +00:00
|
|
|
return "https://cdn.discordapp.com/icons/" + g.ID.String() + "/" + t.format(g.Icon)
|
2020-02-07 00:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// BannerURL returns the URL to the banner, which is the image on top of the
|
2020-05-15 20:07:27 +00:00
|
|
|
// channels list. This will always return a link to a PNG file.
|
2020-02-07 00:51:29 +00:00
|
|
|
func (g Guild) BannerURL() string {
|
2020-05-15 20:07:27 +00:00
|
|
|
return g.BannerURLWithType(PNGImage)
|
|
|
|
}
|
|
|
|
|
2020-05-23 17:17:30 +00:00
|
|
|
// BannerURLWithType returns the URL to the banner, which is the image on top
|
|
|
|
// of the channels list using the passed image type.
|
2020-05-15 20:07:27 +00:00
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG, JPEG, WebP
|
|
|
|
func (g Guild) BannerURLWithType(t ImageType) string {
|
2020-02-07 00:51:29 +00:00
|
|
|
if g.Banner == "" {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return "https://cdn.discordapp.com/banners/" +
|
2020-05-15 20:07:27 +00:00
|
|
|
g.ID.String() + "/" + t.format(g.Banner)
|
2020-02-07 00:51:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SplashURL returns the URL to the guild splash, which is the invite page's
|
2020-05-15 20:07:27 +00:00
|
|
|
// background. This will always return a link to a PNG file.
|
2020-02-07 00:51:29 +00:00
|
|
|
func (g Guild) SplashURL() string {
|
2020-05-23 17:17:30 +00:00
|
|
|
return g.SplashURLWithType(PNGImage)
|
2020-02-07 00:51:29 +00:00
|
|
|
}
|
|
|
|
|
2020-05-23 17:17:30 +00:00
|
|
|
// SplashURLWithType returns the URL to the guild splash, which is the invite
|
|
|
|
// page's background, using the passed ImageType.
|
2020-05-15 20:07:27 +00:00
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG, JPEG, WebP
|
|
|
|
func (g Guild) SplashURLWithType(t ImageType) string {
|
|
|
|
if g.Splash == "" {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return "https://cdn.discordapp.com/splashes/" +
|
|
|
|
g.ID.String() + "/" + t.format(g.Splash)
|
|
|
|
}
|
|
|
|
|
2020-05-24 15:17:01 +00:00
|
|
|
// DiscoverySplashURL returns the URL to the guild discovery splash.
|
|
|
|
// This will always return a link to a PNG file.
|
2020-05-23 21:14:18 +00:00
|
|
|
func (g Guild) DiscoverySplashURL() string {
|
|
|
|
return g.DiscoverySplashURLWithType(PNGImage)
|
|
|
|
}
|
|
|
|
|
2020-05-24 15:17:01 +00:00
|
|
|
// DiscoverySplashURLWithType returns the URL to the guild discovery splash,
|
|
|
|
// using the passed ImageType.
|
2020-05-23 21:14:18 +00:00
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG, JPEG, WebP
|
|
|
|
func (g Guild) DiscoverySplashURLWithType(t ImageType) string {
|
2020-05-24 15:17:01 +00:00
|
|
|
if g.DiscoverySplash == "" {
|
2020-05-23 21:14:18 +00:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return "https://cdn.discordapp.com/splashes/" +
|
2020-05-25 00:22:39 +00:00
|
|
|
g.ID.String() + "/" + t.format(g.DiscoverySplash)
|
2020-05-23 21:14:18 +00:00
|
|
|
}
|
|
|
|
|
2020-05-15 18:02:49 +00:00
|
|
|
// https://discord.com/developers/docs/resources/guild#guild-preview-object
|
|
|
|
type GuildPreview struct {
|
|
|
|
// ID is the guild id.
|
2020-07-21 20:27:59 +00:00
|
|
|
ID GuildID `json:"id"`
|
2020-05-15 18:02:49 +00:00
|
|
|
// Name is the guild name (2-100 characters).
|
|
|
|
Name string `json:"name"`
|
|
|
|
|
|
|
|
// Icon is the icon hash.
|
|
|
|
Icon Hash `json:"icon"`
|
|
|
|
// Splash is the splash hash.
|
|
|
|
Splash Hash `json:"splash"`
|
|
|
|
// DiscoverySplash is the discovery splash hash.
|
|
|
|
DiscoverySplash Hash `json:"discovery_splash"`
|
|
|
|
|
|
|
|
// Emojis are the custom guild emojis.
|
|
|
|
Emojis []Emoji `json:"emojis"`
|
|
|
|
// Features are the enabled guild features.
|
|
|
|
Features []GuildFeature `json:"guild_features"`
|
|
|
|
|
|
|
|
// ApproximateMembers is the approximate number of members in this guild.
|
|
|
|
ApproximateMembers uint64 `json:"approximate_member_count"`
|
|
|
|
// ApproximatePresences is the approximate number of online members in this
|
|
|
|
// guild.
|
|
|
|
ApproximatePresences uint64 `json:"approximate_presence_count"`
|
|
|
|
|
|
|
|
// Description is the description for the guild.
|
|
|
|
Description string `json:"description,omitempty"`
|
|
|
|
}
|
|
|
|
|
2020-05-15 20:07:27 +00:00
|
|
|
// IconURL returns the URL to the guild icon and auto detects a suitable type.
|
|
|
|
// An empty string is returned if there's no icon.
|
2020-05-15 18:02:49 +00:00
|
|
|
func (g GuildPreview) IconURL() string {
|
2020-05-15 20:07:27 +00:00
|
|
|
return g.IconURLWithType(AutoImage)
|
|
|
|
}
|
|
|
|
|
2020-05-23 17:17:30 +00:00
|
|
|
// IconURLWithType returns the URL to the guild icon using the passed
|
|
|
|
// ImageType. An empty string is returned if there's no icon.
|
2020-05-15 20:07:27 +00:00
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG, JPEG, WebP, GIF
|
|
|
|
func (g GuildPreview) IconURLWithType(t ImageType) string {
|
2020-05-15 18:02:49 +00:00
|
|
|
if g.Icon == "" {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2020-05-15 20:07:27 +00:00
|
|
|
return "https://cdn.discordapp.com/icons/" + g.ID.String() + "/" + t.format(g.Icon)
|
|
|
|
}
|
2020-05-15 18:02:49 +00:00
|
|
|
|
2020-05-15 20:07:27 +00:00
|
|
|
// SplashURL returns the URL to the guild splash, which is the invite page's
|
|
|
|
// background. This will always return a link to a PNG file.
|
|
|
|
func (g GuildPreview) SplashURL() string {
|
2020-05-23 17:17:30 +00:00
|
|
|
return g.SplashURLWithType(PNGImage)
|
2020-05-15 18:02:49 +00:00
|
|
|
}
|
|
|
|
|
2020-05-23 17:17:30 +00:00
|
|
|
// SplashURLWithType returns the URL to the guild splash, which is the invite
|
|
|
|
// page's background, using the passed ImageType.
|
2020-05-15 20:07:27 +00:00
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG, JPEG, WebP
|
|
|
|
func (g GuildPreview) SplashURLWithType(t ImageType) string {
|
2020-05-15 18:02:49 +00:00
|
|
|
if g.Splash == "" {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2020-05-15 20:07:27 +00:00
|
|
|
return "https://cdn.discordapp.com/splashes/" +
|
|
|
|
g.ID.String() + "/" + t.format(g.Splash)
|
2020-05-15 18:02:49 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 15:17:01 +00:00
|
|
|
// DiscoverySplashURL returns the URL to the guild discovery splash.
|
|
|
|
// This will always return a link to a PNG file.
|
2020-05-15 18:02:49 +00:00
|
|
|
func (g GuildPreview) DiscoverySplashURL() string {
|
2020-05-23 17:17:30 +00:00
|
|
|
return g.DiscoverySplashURLWithType(PNGImage)
|
2020-05-15 20:07:27 +00:00
|
|
|
}
|
|
|
|
|
2020-05-24 15:17:01 +00:00
|
|
|
// DiscoverySplashURLWithType returns the URL to the guild discovery splash,
|
|
|
|
// using the passed ImageType.
|
2020-05-15 20:07:27 +00:00
|
|
|
//
|
|
|
|
// Supported ImageTypes: PNG, JPEG, WebP
|
|
|
|
func (g GuildPreview) DiscoverySplashURLWithType(t ImageType) string {
|
2020-05-24 15:17:01 +00:00
|
|
|
if g.DiscoverySplash == "" {
|
2020-05-15 20:07:27 +00:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
return "https://cdn.discordapp.com/splashes/" +
|
2020-05-25 00:22:39 +00:00
|
|
|
g.ID.String() + "/" + t.format(g.DiscoverySplash)
|
2020-05-15 18:02:49 +00:00
|
|
|
}
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// https://discord.com/developers/docs/topics/permissions#role-object
|
2020-01-04 04:19:24 +00:00
|
|
|
type Role struct {
|
2020-05-22 12:02:12 +00:00
|
|
|
// ID is the role id.
|
2020-07-21 20:27:59 +00:00
|
|
|
ID RoleID `json:"id,string"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// Name is the role name.
|
|
|
|
Name string `json:"name"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Color is the integer representation of hexadecimal color code.
|
|
|
|
Color Color `json:"color"`
|
|
|
|
// 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"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Permissions is the permission bit set.
|
2020-10-28 21:08:29 +00:00
|
|
|
Permissions Permissions `json:"permissions,string"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Manages specifies whether this role is managed by an integration.
|
|
|
|
Managed bool `json:"managed"`
|
|
|
|
// Mentionable specifies whether this role is mentionable.
|
2020-01-04 04:19:24 +00:00
|
|
|
Mentionable bool `json:"mentionable"`
|
|
|
|
}
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Mention returns the mention of the Role.
|
2020-01-24 05:45:47 +00:00
|
|
|
func (r Role) Mention() string {
|
2020-09-24 18:43:20 +00:00
|
|
|
return r.ID.Mention()
|
2020-01-24 05:45:47 +00:00
|
|
|
}
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// https://discord.com/developers/docs/topics/gateway#presence-update
|
2020-01-04 04:19:24 +00:00
|
|
|
type Presence struct {
|
2020-05-22 12:02:12 +00:00
|
|
|
// User is the user presence is being updated for.
|
|
|
|
User User `json:"user"`
|
|
|
|
// RoleIDs are the roles this user is in.
|
2020-07-21 20:27:59 +00:00
|
|
|
RoleIDs []RoleID `json:"roles"`
|
2020-01-18 21:04:12 +00:00
|
|
|
|
|
|
|
// These fields are only filled in gateway events, according to the
|
|
|
|
// documentation.
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// GuildID is the id of the guild
|
2020-07-21 20:27:59 +00:00
|
|
|
GuildID GuildID `json:"guild_id"`
|
2020-01-18 21:04:12 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Status is either "idle", "dnd", "online", or "offline".
|
|
|
|
Status Status `json:"status"`
|
|
|
|
// Activities are the user's current activities.
|
2020-01-18 21:04:12 +00:00
|
|
|
Activities []Activity `json:"activities"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// ClientStaus is the user's platform-dependent status.
|
|
|
|
//
|
|
|
|
// https://discord.com/developers/docs/topics/gateway#client-status-object
|
2020-01-18 21:04:12 +00:00
|
|
|
ClientStatus struct {
|
2020-05-22 12:02:12 +00:00
|
|
|
// Desktop is the user's status set for an active desktop (Windows,
|
|
|
|
// Linux, Mac) application session.
|
2020-02-23 17:56:16 +00:00
|
|
|
Desktop Status `json:"desktop,omitempty"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// Mobile is the user's status set for an active mobile (iOS, Android)
|
|
|
|
// 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"`
|
2020-01-18 21:04:12 +00:00
|
|
|
} `json:"client_status"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// 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"`
|
2020-01-04 04:19:24 +00:00
|
|
|
}
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// 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.
|
2020-01-04 04:19:24 +00:00
|
|
|
type Member struct {
|
2020-05-22 12:02:12 +00:00
|
|
|
// User is the user this guild member represents.
|
|
|
|
User User `json:"user"`
|
|
|
|
// Nick is this users guild nickname.
|
|
|
|
Nick string `json:"nick,omitempty"`
|
|
|
|
// RoleIDs is an array of role object ids.
|
2020-07-21 20:27:59 +00:00
|
|
|
RoleIDs []RoleID `json:"roles"`
|
2020-01-04 04:19:24 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Joined specifies when the user joined the guild.
|
|
|
|
Joined Timestamp `json:"joined_at"`
|
|
|
|
// BoostedSince specifies when the user started boosting the guild.
|
2020-01-04 04:19:24 +00:00
|
|
|
BoostedSince Timestamp `json:"premium_since,omitempty"`
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Deaf specifies whether the user is deafened in voice channels.
|
2020-01-04 04:19:24 +00:00
|
|
|
Deaf bool `json:"deaf"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// Mute specifies whether the user is muted in voice channels.
|
2020-01-04 04:19:24 +00:00
|
|
|
Mute bool `json:"mute"`
|
|
|
|
}
|
2020-01-05 07:50:22 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Mention returns the mention of the role.
|
2020-01-24 05:45:47 +00:00
|
|
|
func (m Member) Mention() string {
|
2020-09-24 18:43:20 +00:00
|
|
|
return m.User.Mention()
|
2020-01-24 05:45:47 +00:00
|
|
|
}
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// https://discord.com/developers/docs/resources/guild#ban-object
|
2020-01-05 07:50:22 +00:00
|
|
|
type Ban struct {
|
2020-05-22 12:02:12 +00:00
|
|
|
// Reason is the reason for the ban.
|
2020-01-05 07:50:22 +00:00
|
|
|
Reason string `json:"reason,omitempty"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// User is the banned user.
|
|
|
|
User User `json:"user"`
|
2020-01-05 07:50:22 +00:00
|
|
|
}
|
2020-01-06 03:48:39 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// https://discord.com/developers/docs/resources/guild#integration-object
|
2020-01-06 03:48:39 +00:00
|
|
|
type Integration struct {
|
2020-05-22 12:02:12 +00:00
|
|
|
// ID is the integration id.
|
2020-07-21 20:27:59 +00:00
|
|
|
ID IntegrationID `json:"id"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// Name is the integration name.
|
|
|
|
Name string `json:"name"`
|
|
|
|
// Type is the integration type (twitch, youtube, etc).
|
|
|
|
Type Service `json:"type"`
|
2020-01-06 03:48:39 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// Enables specifies if the integration is enabled.
|
2020-01-06 03:48:39 +00:00
|
|
|
Enabled bool `json:"enabled"`
|
2020-05-22 12:02:12 +00:00
|
|
|
// Syncing specifies if the integration is syncing.
|
2020-01-06 03:48:39 +00:00
|
|
|
Syncing bool `json:"syncing"`
|
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// RoleID is the id that this integration uses for "subscribers".
|
2020-07-21 20:27:59 +00:00
|
|
|
RoleID RoleID `json:"role_id"`
|
2020-01-06 03:48:39 +00:00
|
|
|
|
2020-05-22 12:02:12 +00:00
|
|
|
// EnableEmoticons specifies whether emoticons should be synced for this
|
|
|
|
// integration (twitch only currently).
|
|
|
|
EnableEmoticons bool `json:"enable_emoticons,omitempty"`
|
|
|
|
|
|
|
|
// 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
|
2020-01-06 03:48:39 +00:00
|
|
|
Account struct {
|
2020-05-22 12:02:12 +00:00
|
|
|
// ID is the id of the account.
|
|
|
|
ID string `json:"id"`
|
|
|
|
// Name is the name of the account.
|
2020-01-06 03:48:39 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
} `json:"account"`
|
|
|
|
|
2020-05-22 12:02:18 +00:00
|
|
|
// SyncedAt specifies when this integration was last synced.
|
2020-01-06 03:48:39 +00:00
|
|
|
SyncedAt Timestamp `json:"synced_at"`
|
|
|
|
}
|
|
|
|
|
2020-05-16 15:57:25 +00:00
|
|
|
// https://discord.com/developers/docs/resources/guild#guild-widget-object
|
|
|
|
type GuildWidget struct {
|
|
|
|
// Enabled specifies whether the widget is enabled.
|
|
|
|
Enabled bool `json:"enabled"`
|
|
|
|
// ChannelID is the widget channel id.
|
2020-07-21 20:27:59 +00:00
|
|
|
ChannelID ChannelID `json:"channel_id,omitempty"`
|
2020-01-06 03:48:39 +00:00
|
|
|
}
|
2020-01-20 23:22:34 +00:00
|
|
|
|
|
|
|
// DefaultMemberColor is the color used for members without colored roles.
|
|
|
|
var DefaultMemberColor Color = 0x0
|
|
|
|
|
2020-05-22 12:02:18 +00:00
|
|
|
// MemberColor computes the effective color of the Member, taking into account
|
|
|
|
// the role colors.
|
2020-01-20 23:22:34 +00:00
|
|
|
func MemberColor(guild Guild, member Member) Color {
|
|
|
|
var c = DefaultMemberColor
|
|
|
|
var pos int
|
|
|
|
|
|
|
|
for _, r := range guild.Roles {
|
2020-02-11 04:26:22 +00:00
|
|
|
for _, mr := range member.RoleIDs {
|
|
|
|
if mr != r.ID {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if r.Color > 0 && r.Position > pos {
|
|
|
|
c = r.Color
|
|
|
|
pos = r.Position
|
|
|
|
}
|
2020-01-20 23:22:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return c
|
|
|
|
}
|