Browse Source

Optimized some structs to reduce their runtime size.

Bruce Marriner 9 years ago
parent
commit
9b8e880744
2 changed files with 22 additions and 22 deletions
  1. 6 6
      message.go
  2. 16 16
      structs.go

+ 6 - 6
message.go

@@ -17,16 +17,16 @@ import (
 // A Message stores all data related to a specific Discord message.
 type Message struct {
 	ID              string        `json:"id"`
-	Author          *User         `json:"author"`
+	ChannelID       string        `json:"channel_id"`
 	Content         string        `json:"content"`
-	Attachments     []*Attachment `json:"attachments"`
-	Tts             bool          `json:"tts"`
-	Embeds          []*Embed      `json:"embeds"`
 	Timestamp       string        `json:"timestamp"`
-	MentionEveryone bool          `json:"mention_everyone"`
 	EditedTimestamp string        `json:"edited_timestamp"`
+	Tts             bool          `json:"tts"`
+	MentionEveryone bool          `json:"mention_everyone"`
+	Author          *User         `json:"author"`
+	Attachments     []*Attachment `json:"attachments"`
+	Embeds          []*Embed      `json:"embeds"`
 	Mentions        []*User       `json:"mentions"`
-	ChannelID       string        `json:"channel_id"`
 }
 
 // An Attachment stores data for message attachments.

+ 16 - 16
structs.go

@@ -115,17 +115,17 @@ type ICEServer struct {
 
 // A Invite stores all data related to a specific Discord Guild or Channel invite.
 type Invite struct {
-	MaxAge    int      `json:"max_age"`
-	Code      string   `json:"code"`
 	Guild     *Guild   `json:"guild"`
-	Revoked   bool     `json:"revoked"`
+	Channel   *Channel `json:"channel"`
+	Inviter   *User    `json:"inviter"`
+	Code      string   `json:"code"`
 	CreatedAt string   `json:"created_at"` // TODO make timestamp
-	Temporary bool     `json:"temporary"`
+	MaxAge    int      `json:"max_age"`
 	Uses      int      `json:"uses"`
 	MaxUses   int      `json:"max_uses"`
-	Inviter   *User    `json:"inviter"`
 	XkcdPass  bool     `json:"xkcdpass"`
-	Channel   *Channel `json:"channel"`
+	Revoked   bool     `json:"revoked"`
+	Temporary bool     `json:"temporary"`
 }
 
 // A Channel holds all data related to an individual Discord channel.
@@ -153,11 +153,11 @@ type PermissionOverwrite struct {
 
 // Emoji struct holds data related to Emoji's
 type Emoji struct {
-	Roles         []string `json:"roles"`
-	RequireColons bool     `json:"require_colons"`
+	ID            string   `json:"id"`
 	Name          string   `json:"name"`
+	Roles         []string `json:"roles"`
 	Managed       bool     `json:"managed"`
-	ID            string   `json:"id"`
+	RequireColons bool     `json:"require_colons"`
 }
 
 // A Guild holds all data related to a specific Discord Guild.  Guilds are also
@@ -167,14 +167,14 @@ type Guild struct {
 	Name           string        `json:"name"`
 	Icon           string        `json:"icon"`
 	Region         string        `json:"region"`
-	AfkTimeout     int           `json:"afk_timeout"`
 	AfkChannelID   string        `json:"afk_channel_id"`
 	EmbedChannelID string        `json:"embed_channel_id"`
-	EmbedEnabled   bool          `json:"embed_enabled"`
 	OwnerID        string        `json:"owner_id"`
-	Large          bool          `json:"large"`     // ??
 	JoinedAt       string        `json:"joined_at"` // make this a timestamp
 	Splash         string        `json:"splash"`
+	AfkTimeout     int           `json:"afk_timeout"`
+	EmbedEnabled   bool          `json:"embed_enabled"`
+	Large          bool          `json:"large"` // ??
 	Roles          []*Role       `json:"roles"`
 	Emojis         []*Emoji      `json:"emojis"`
 	Members        []*Member     `json:"members"`
@@ -188,8 +188,8 @@ type Role struct {
 	ID          string `json:"id"`
 	Name        string `json:"name"`
 	Managed     bool   `json:"managed"`
-	Color       int    `json:"color"`
 	Hoist       bool   `json:"hoist"`
+	Color       int    `json:"color"`
 	Position    int    `json:"position"`
 	Permissions int    `json:"permissions"`
 }
@@ -197,13 +197,13 @@ type Role struct {
 // A VoiceState stores the voice states of Guilds
 type VoiceState struct {
 	UserID    string `json:"user_id"`
-	Suppress  bool   `json:"suppress"`
 	SessionID string `json:"session_id"`
+	ChannelID string `json:"channel_id"`
+	Suppress  bool   `json:"suppress"`
 	SelfMute  bool   `json:"self_mute"`
 	SelfDeaf  bool   `json:"self_deaf"`
 	Mute      bool   `json:"mute"`
 	Deaf      bool   `json:"deaf"`
-	ChannelID string `json:"channel_id"`
 }
 
 // A Presence stores the online, offline, or idle and game status of Guild members.
@@ -254,8 +254,8 @@ type Settings struct {
 	InlineEmbedMedia      bool     `json:"inline_embed_media"`
 	EnableTtsCommand      bool     `json:"enable_tts_command"`
 	MessageDisplayCompact bool     `json:"message_display_compact"`
-	Locale                string   `json:"locale"`
 	ShowCurrentGame       bool     `json:"show_current_game"`
+	Locale                string   `json:"locale"`
 	Theme                 string   `json:"theme"`
 	MutedChannels         []string `json:"muted_channels"`
 }